Lhotse is a lightweight HTTP server designed for controlled performance testing. It facilitates dictating the server's behavior, such as introducing specific latencies or generating responses of varying sizes. Developed to complement k6, Lhotse is an excellent tool for measuring k6's accuracy and assisting in its improvement and debugging.
Install Lhotse using Go:
go install github.com/oleiade/lhotse@latest
Lhotse provides functionalities such as latency simulation, data response control, and custom response generation.
Here are some examples:
Command:
time curl -X GET -i http://localhost:3434/latency/500ms
Output:
HTTP/1.1 200 OK
Allow: GET, OPTIONS
Date: Tue, 01 Nov 2022 18:15:37 GMT
Content-Length: 12
Content-Type: text/plain; charset=utf-8
waited 500ms
Command:
curl -X GET -i http://localhost:3434/latency/500ms-1s
Output:
HTTP/1.1 200 OK
Allow: GET, OPTIONS
Date: Tue, 01 Nov 2022 18:16:43 GMT
Content-Length: 19
Content-Type: text/plain; charset=utf-8
waited 610.839158ms
Command:
curl -X GET -i http://localhost:3434/data/8b
Output:
HTTP/1.1 200 OK
Allow: GET, OPTIONS
Date: Tue, 01 Nov 2022 18:14:12 GMT
Content-Length: 8
Content-Type: text/plain; charset=utf-8
TMtTCoaN
Command:
curl -X GET -i http://localhost:3434/data/64b-128b
Output:
HTTP/1.1 200 OK
Allow: GET, OPTIONS
Date: Tue, 01 Nov 2022 18:13:02 GMT
Content-Length: 116
Content-Type: text/plain; charset=utf-8
whTHctcuAxhxKQFDaFpLSjFbcXoEFfRsWxPLDnJObCsNVlgTeMaPEZQleQYhYzRyJjPjzpfRFEgmotaFetHsbZRjxAwnwekrBEmfdzdcEkXBAkjQZLCt
Command:
curl -X GET -i http://localhost:3434/response?status=204
Output:
HTTP/1.1 204 No Content
Content-Type: text/plain
Date: Sun, 14 Jan 2024 10:17:35 GMT
Command:
curl -i -X GET --header 'Content-Type: application/json' http://localhost:3434/response
Output:
HTTP/1.1 200 OK
Content-Type: application/json
Date: Sun, 14 Jan 2024 10:18:36 GMT
Content-Length: 49
{"content_type":"application/json","status":200}
Endpoint /latency/{duration}
simulates a response delay.
GET /latency/${duration}
Parameter | Type | Description |
---|---|---|
duration |
string |
Specifies the delay before responding. Use {value}{unit} or {lowerBound}-{upperBound} format. |
Endpoint /data/{size}
controls the response size.
GET /data/${size}
Parameter | Type | Description |
---|---|---|
size |
string |
Size of the payload produced by Lhotse. It can either be specified as a single size of the form {value}{unit}, or as a range {lowerBound}-{upperBound}. The value should always be an unsigned integer value. Valid units are b , kb , mb , and gb . When specifying a range, lowerBound needs to be less than upperBound , and as a result, the produced payload will be of a random size somewhere between those bounds. |
Endpoint /response
allows customization of the response.
GET /response?status=${status}
Parameter | Type | Description |
---|---|---|
status |
string |
Specifies the HTTP status code for the response. |
Header | Type | Description |
---|---|---|
Content-Type |
string |
Determines the Content-Type of the response. Currently text/plain and application/json are supported. |
Contributions to Lhotse are welcome! Whether it's bug reports, feature requests, or code contributions, please feel free to contribute. For more details, see CONTRIBUTING.md.
Lhotse is open-sourced under the MIT License.