This challenge corresponds to the 41st part of the Coding Challenges series by John Crickett https://codingchallenges.fyi/challenges/challenge-load-tester.
The objective of the challenge is to build a HTTP(s) Load Tester that can query a given address and return some important stats such as Total Request Time, Time to First Byte, Time to Last Byte.
You can use the ts-node
tool to run the command line version of the NTP Client as follows:
npx ts-node <path/to/index.ts> -u <url> [-n <number-of-requests>] [-c <concurrency>]
-
-u <url>
: The URL on which load testing needs to be performed. -
-n <number-of-requests>
: The number of requests sent to the server. This are sent in series. Default = 10. -
-c <concurrency>
: The number of concurrent requests to send. Default = 1.
# Load test https://google.com with 10 requests and 10 concurrency
npx ts-node <path-to-index.ts> -u https://google.com -n 10 -c 10
-
customer_request.ts: A helper function which calculates some stats while doing a network GET request. The code is inspired from https://gabrieleromanato.name/nodejs-get-the-time-to-first-byte-ttfb-of-a-website.
-
load_tester.ts: The main load tester implementation.
To run the tests for the Load Tester, go to the root directory of this repository and run the following command:
npm test src/41/