We use two tools to measure the performance of slow pages:
- 0x: Profile the application and generate flame graphs.
- autocannon: Load test (send lots of requests) and measure response time (which autocannon calls “latency”) & throughput.
Here’s a step-by-step guide of how to use these tools in Courselore:
-
Run the application normally.
Note: Don’t use a custom
HOSTNAME
, because autocannon may not recognize the self-signed certificate generated by Caddy. -
Setup what you need, for example, create demonstration data.
-
Take note of the information necessary to reproduce the request of interest, including cookies, URL, and so forth, for example:
$ npx autocannon --duration 5 --headers "Cookie: __Host-Session=Vsd6eB9gtfjCuK2TTxiUINfn8PoPMYLMWASxnabSz9XMBGS5sHijmrrUDJ15vUF2aGWlsfPh4hkjclsgXrwir3aqvgtIE2VD5ZeH" https://localhost/courses/4453154610/conversations/33
-
Stop the server and restart it in profile mode:
$ npm run start:profile
-
Create load on the server, for example:
$ mkdir -p ./data/measurements/ $ npx autocannon --duration 120 --latency --renderStatusCodes --json --headers "Cookie: __Host-Session=Vsd6eB9gtfjCuK2TTxiUINfn8PoPMYLMWASxnabSz9XMBGS5sHijmrrUDJ15vUF2aGWlsfPh4hkjclsgXrwir3aqvgtIE2VD5ZeH" https://localhost/courses/4453154610/conversations/33 > ./data/measurements/latency-and-throughput.txt 2>&1
Note: You may want to watch the system resources while the test is running. For example, in macOS, use Activity Monitor.
-
Stop the server and see the measurements at
./data/measurements/
.Note: If you wish to keep these measurements, then rename the folder, because it will be overwritten the next time you run the server in profile mode.