Skip to content

Commit

Permalink
Bake in pprof data from production to optimise hot paths
Browse files Browse the repository at this point in the history
This data was collected by setting `COLLECT_METRICS=yes` on production and then running:

```bash
$ while true; do curl http://localhost:6060/debug/pprof/profile?seconds=30 --output profiles/$(date +%s).pprof; sleep 270; done
```

To gather a chunk of metrics every 5 mins for 30 seconds for a couple of hours. The traffic to the server came in bursts, but included lots of visits to jupyter- which is massively asset heavy and makes loads of calls to /api/v1/auth.

At some point we can start thinking about gathering data from loads of instances over many days with lots of requests; at that point this commit will be useful prep
  • Loading branch information
jspc committed Jan 3, 2024
1 parent 46f2d59 commit f906f33
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
littleauth
profiles/*.pprof
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go_build_cmd ?= CGO_ENABLED=1 go build -ldflags="-s -w" -trimpath -race
go_build_cmd ?= CGO_ENABLED=1 go build -ldflags="-s -w" -trimpath -race -pgo merged.pprof

littleauth: *.go go.*
$(go_build_cmd) -o $@
Expand Down
Binary file added merged.pprof
Binary file not shown.
16 changes: 16 additions & 0 deletions pgo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"net/http"
_ "net/http/pprof" //#nosec: G108
"os"
)

func init() {
go func() {
if os.Getenv("COLLECT_METRICS") == "yes" {
//#nosec: G114
print(http.ListenAndServe("localhost:6060", nil), "\n")
}
}()
}
Empty file added profiles/.gitkeep
Empty file.

0 comments on commit f906f33

Please sign in to comment.