|
| 1 | +# Curl loader |
| 2 | + |
| 3 | +## Configuration |
| 4 | + |
| 5 | +To define load behavior, create a config.json file. |
| 6 | + |
| 7 | +For example: |
| 8 | + |
| 9 | +If you want to test how your API endpoint on the frontend service handles concurrent traffic, you can list it multiple times in the `urls` array and adjust the `sleep` and `wait` values accordingly to simulate the desired load pattern. |
| 10 | + |
| 11 | +```json |
| 12 | +{ |
| 13 | + "sleep": 2, |
| 14 | + "wait": 5, |
| 15 | + "urls": [ |
| 16 | + "http://frontend/upload", |
| 17 | + "http://frontend/upload", |
| 18 | + "http://frontend/upload" |
| 19 | + ] |
| 20 | +} |
| 21 | +``` |
| 22 | + |
| 23 | +Each of the following parameters must be specified to control how the load is executed: |
| 24 | + |
| 25 | +| field | type | description | |
| 26 | +| -------------- | -------------- | ------------------------------------------ | |
| 27 | +| Sleep | number | seconds to sleep between each request loop | |
| 28 | +| Wait | number | initial wait time before the first request | |
| 29 | +| URLs | array | list of service URLs to target | |
| 30 | + |
| 31 | +## Behavior Summary |
| 32 | + |
| 33 | +- **Initial Delay**: Waits for the duration specified in wait (in seconds) before initiating any requests. |
| 34 | +- **Request Execution**: Sends repeated HTTP GET requests to each URL in the list, automatically appending a `?unique_session_id=<uuid>` parameter to ensure each request is distinct. |
| 35 | +- **Loop Interval**: Pauses for the duration specified in sleep (in seconds) between each full cycle of requests to all URLs. |
| 36 | + |
| 37 | +## Dependencies |
| 38 | + |
| 39 | +The script requires the following in its runtime environment: |
| 40 | + |
| 41 | +- [`curl`](https://curl.se/) |
| 42 | +- [`jq`](https://jqlang.org/) |
| 43 | +- `uuidgen` (part of uuid-runtime or util-linux) |
| 44 | + |
| 45 | +## Getting Started with Docker |
| 46 | + |
| 47 | +### Docker |
| 48 | + |
| 49 | +Build the Docker image: |
| 50 | + |
| 51 | +```bash |
| 52 | + docker build -t curl-loader |
| 53 | +``` |
| 54 | + |
| 55 | +Run the container: |
| 56 | + |
| 57 | +```bash |
| 58 | + docker run --rm -v $(pwd)/config.json:/config.json curl-loader |
| 59 | +``` |
| 60 | + |
| 61 | +### 2. Docker Compose Integration |
| 62 | + |
| 63 | +Use this block in your config.yaml: |
| 64 | + |
| 65 | +```yaml |
| 66 | +loaders: |
| 67 | + user-1: |
| 68 | + type: curl |
| 69 | + wait: 0 |
| 70 | + sleep: 2 |
| 71 | + urls: |
| 72 | + - http://frontend/upload |
| 73 | + - http://frontend/upload |
| 74 | + - http://frontend/upload |
| 75 | +``` |
| 76 | +
|
| 77 | +Generate the Docker Compose config: |
| 78 | +
|
| 79 | +```bash |
| 80 | + docker run --rm -v ${PWD}:/mnt \ |
| 81 | + ghcr.io/cisco-open/app-simulator-generators-docker-compose |
| 82 | + --config /mnt/config.yaml \ |
| 83 | + --output /mnt/docker-compose.yaml |
| 84 | +``` |
| 85 | + |
| 86 | +### 3. Example Scenario |
| 87 | + |
| 88 | +Here is an example of `docker-compose.yaml` setup: |
| 89 | + |
| 90 | +```yaml |
| 91 | +services: |
| 92 | + frontend: |
| 93 | + image: ghcr.io/cisco-open/app-simulator-services-java:edge |
| 94 | + ports: |
| 95 | + - "3000:80" |
| 96 | + user-1: |
| 97 | + image: ghcr.io/cisco-open/app-simulator-loaders-curl:edge |
| 98 | +``` |
| 99 | +
|
| 100 | +After running `docker compose up`, the loader will continuously simulate user-traffic to frontend. |
| 101 | + |
| 102 | +## Tracing with Jaeger |
| 103 | + |
| 104 | +Combine this loader with OpenTelemetry instrumentation in your services and Jaeger to visualize traces flowing through your architecture. |
| 105 | +See the [Observability with OpenTelemetry](../../../docs/tutorial/5-observability-with-opentelemetry.md) for details. |
0 commit comments