Created
May 14, 2024 16:51
-
-
Save leafac/113e7060d077fa0d820a59fd344a8a2b to your computer and use it in GitHub Desktop.
Revisions
-
leafac created this gist
May 14, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ We use two tools to measure the performance of slow pages: 1. [0x](https://www.npmjs.com/package//0x): Profile the application and generate [flame graphs](https://www.brendangregg.com/flamegraphs.html). 2. [autocannon](https://www.npmjs.com/package//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: 1. Run the application normally. > **Note:** Don’t use a custom `HOSTNAME`, because autocannon may not recognize the self-signed certificate generated by Caddy. 2. Setup what you need, for example, create demonstration data. 3. Take note of the information necessary to reproduce the request of interest, including cookies, URL, and so forth, for example: ```console $ npx autocannon --duration 5 --headers "Cookie: __Host-Session=Vsd6eB9gtfjCuK2TTxiUINfn8PoPMYLMWASxnabSz9XMBGS5sHijmrrUDJ15vUF2aGWlsfPh4hkjclsgXrwir3aqvgtIE2VD5ZeH" https://localhost/courses/4453154610/conversations/33 ``` 4. Stop the server and restart it in profile mode: ```console $ npm run start:profile ``` 5. Create load on the server, for example: ```console $ 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. 6. 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.