Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oleiade/lhotse
Tiny HTTP server with controllable performance.
https://github.com/oleiade/lhotse
go golang http http-server k6 load-testing performance
Last synced: about 8 hours ago
JSON representation
Tiny HTTP server with controllable performance.
- Host: GitHub
- URL: https://github.com/oleiade/lhotse
- Owner: oleiade
- License: mit
- Created: 2022-11-01T18:21:41.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-14T21:31:49.000Z (10 months ago)
- Last Synced: 2024-06-21T17:56:18.283Z (5 months ago)
- Topics: go, golang, http, http-server, k6, load-testing, performance
- Language: Go
- Homepage:
- Size: 154 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Lightweight HTTP server with controllable performance
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](https://github.com/grafana/k6), Lhotse is an excellent tool for measuring [k6](https://github.com/grafana/k6)'s accuracy and assisting in its improvement and debugging.## Installation
Install Lhotse using Go:
```bash
go install github.com/oleiade/lhotse@latest
```## Usage & Examples
Lhotse provides functionalities such as latency simulation, data response control, and custom response generation.
Here are some examples:
### Latency Control
#### Fixed Duration
Command:
```bash
time curl -X GET -i http://localhost:3434/latency/500ms
```Output:
```bash
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-8waited 500ms
```#### Latency Range
Command:
```bash
curl -X GET -i http://localhost:3434/latency/500ms-1s
```Output:
```bash
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-8waited 610.839158ms
```### Data Response Control
#### Fixed Size
Command:
```bash
curl -X GET -i http://localhost:3434/data/8b
```Output:
```bash
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-8TMtTCoaN
```#### Size Range
Command:
```bash
curl -X GET -i http://localhost:3434/data/64b-128b
```Output:
```bash
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-8whTHctcuAxhxKQFDaFpLSjFbcXoEFfRsWxPLDnJObCsNVlgTeMaPEZQleQYhYzRyJjPjzpfRFEgmotaFetHsbZRjxAwnwekrBEmfdzdcEkXBAkjQZLCt
```### Custom Response Control
#### Custom Status Code
Command:
```bash
curl -X GET -i http://localhost:3434/response?status=204
```Output:
```bash
HTTP/1.1 204 No Content
Content-Type: text/plain
Date: Sun, 14 Jan 2024 10:17:35 GMT
```#### Custom content-type
Command:
```bash
curl -i -X GET --header 'Content-Type: application/json' http://localhost:3434/response
```Output:
```bash
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}
```## API Reference
#### Latency Control
Endpoint `/latency/{duration}` simulates a response delay.
```http
GET /latency/${duration}
```| Parameter | Type | Description |
|:-----------|:---------|:----------------------------------------------------------------------------------------------|
| `duration` | `string` | Specifies the delay before responding. Use {value}{unit} or {lowerBound}-{upperBound} format. |#### Data Volume Control
Endpoint `/data/{size}` controls the response size.
```http
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. |#### Custom Response Control
Endpoint `/response` allows customization of the response.
```http
GET /response?status=${status}
```##### Query Parameters
| Parameter | Type | Description |
|:----------|:---------|:-------------------------------------------------|
| `status` | `string` | Specifies the HTTP status code for the response. |##### Headers
| Header | Type | Description |
|:---------------|:---------|:------------------------------------------------------------------------------------------------------------|
| `Content-Type` | `string` | Determines the `Content-Type` of the response. Currently `text/plain` and `application/json` are supported. |## Contributing
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.## License
Lhotse is open-sourced under the MIT License.