-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some load testing tools to the sandbox #351
Changes from 2 commits
54136f4
d6d7b37
2c1dbc2
d4ee1f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,20 +4,34 @@ | |
|
||
# Use bullseye as build image instead of Bookworm as ubi9 does not not have GLIBCXX_3.4.30 | ||
# https://access.redhat.com/solutions/6969351 | ||
FROM --platform=${BUILDPLATFORM} rust:1.78.0-bullseye as limitador-build | ||
FROM rust:1.78.0-bullseye as limitador-build | ||
|
||
RUN apt update && apt upgrade -y \ | ||
&& apt install -y protobuf-compiler clang | ||
|
||
WORKDIR /usr/src/limitador | ||
|
||
ARG GITHUB_SHA | ||
ARG CARGO_ARGS | ||
ENV GITHUB_SHA=${GITHUB_SHA:-unknown} | ||
ENV RUSTFLAGS="-C target-feature=-crt-static" | ||
|
||
COPY . . | ||
# We set the env here just to make sure that the build is invalidated if the args change | ||
ENV CARGO_ARGS=${CARGO_ARGS} | ||
|
||
RUN cargo build --release | ||
# The following allows us to cache the Cargo dependency downloads with image layers | ||
COPY Cargo.toml Cargo.lock ./ | ||
COPY limitador/Cargo.toml ./limitador/ | ||
COPY limitador-server/Cargo.toml ./limitador-server/ | ||
COPY limitador-server/sandbox/loadtest/Cargo.toml ./limitador-server/sandbox/loadtest/ | ||
eguzki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
RUN mkdir -p limitador-server/src && echo 'fn main() {}' > limitador-server/src/main.rs | ||
RUN mkdir -p limitador-server/sandbox/loadtest/src && echo 'fn main() {}' > limitador-server/sandbox/loadtest/src/main.rs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this still needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep that's not needed either.. |
||
RUN cargo build --release ${CARGO_ARGS} | ||
|
||
COPY ./limitador ./limitador | ||
COPY ./limitador-server ./limitador-server | ||
|
||
RUN cargo build --release ${CARGO_ARGS} | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Run Stage | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
*.key | ||
*.pem | ||
*.csr | ||
report.html |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,14 +17,40 @@ Check out `make help` for all the targets. | |
|
||
### Deployment options | ||
|
||
| Limitador's configuration | Command | Info | | ||
| ------------- | ----- | ----- | | ||
| In-memory configuration | `make deploy-in-memory` | Counters are held in Limitador (ephemeral) | | ||
| Redis | `make deploy-redis` | Uses Redis to store counters | | ||
| Redis Secured | `make deploy-redis-tls` | Uses Redis with TLS and password protected to store counters | | ||
| Redis Cached | `make deploy-redis-cached` | Uses Redis to store counters, with an in-memory cache | | ||
| Redis Otel Instrumented | `make deploy-redis-otel` | Uses redis to store counters, [instrumented with opentelemetry](redis-otel/README.md) | | ||
| Disk | `make deploy-disk` | Uses disk to store counters | | ||
| Limitador's configuration | Command | Info | | ||
|--------------------------| ----- |----------------------------------------------------------------------------------------------------------------| | ||
| In-memory configuration | `make deploy-in-memory` | Counters are held in Limitador (ephemeral) | | ||
| Redis | `make deploy-redis` | Uses Redis to store counters | | ||
| Redis Secured | `make deploy-redis-tls` | Uses Redis with TLS and password protected to store counters | | ||
| Redis Cached | `make deploy-redis-cached` | Uses Redis to store counters, with an in-memory cache | | ||
| Redis Otel Instrumented | `make deploy-redis-otel` | Uses redis to store counters, [instrumented with opentelemetry](redis-otel/README.md) | | ||
| Disk | `make deploy-disk` | Uses disk to store counters | | ||
| Distributed | `make deploy-distributed` | Counters are held in Limitador (ephemeral) but replicated to other Limitador servers. | | ||
|
||
| Distributed 3 Node | `make deploy-distributed-3-node` | Counters are held in Limitador (ephemeral) but replicated to 3 other Limitador servers. | | ||
|
||
### Running Multi Node Distributed Deployments | ||
|
||
The `make deploy-distributed` target can be connected to other Limitador servers but requires you to set the `PEER_ID` and `PEER_URLS` environment variables when you run the target. | ||
eguzki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
If you have 3 servers you want to replicate between, you would run the following commands: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to have 3 servers, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, you might still want to do this on 3 machines if you are benchmarking. Doing it all on one would not be very representative. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I buy that |
||
|
||
```bash | ||
# on server where: hostname=server1 | ||
PEER_ID=`hostname` PEER_URLS="http://server2:15001 http://server3:15001" make deploy-distributed | ||
``` | ||
|
||
```bash | ||
# on server where: hostname=server2 | ||
PEER_ID=`hostname` PEER_URLS="http://server1:15001 http://server3:15001" make deploy-distributed | ||
``` | ||
|
||
```bash | ||
# on server where: hostname=server3 | ||
PEER_ID=`hostname` PEER_URLS="http://server1:15001 http://server2:15001" make deploy-distributed | ||
``` | ||
|
||
The `PEER_ID` just need to be unique between the servers, and the `PEER_URLS` should be a space-separated list of the other servers' URLs. | ||
|
||
### Limitador's admin HTTP endpoint | ||
|
||
|
@@ -75,6 +101,10 @@ bin/grpcurl -plaintext -d @ 127.0.0.1:18081 envoy.service.ratelimit.v3.RateLimit | |
{ | ||
"key": "req.method", | ||
"value": "POST" | ||
}, | ||
{ | ||
"key": "req.path", | ||
"value": "/" | ||
} | ||
] | ||
} | ||
|
@@ -97,6 +127,10 @@ while :; do bin/grpcurl -plaintext -d @ 127.0.0.1:18081 envoy.service.ratelimit. | |
{ | ||
"key": "req.method", | ||
"value": "POST" | ||
}, | ||
{ | ||
"key": "req.path", | ||
"value": "/" | ||
} | ||
] | ||
} | ||
|
@@ -113,6 +147,24 @@ EOM | |
curl -i -H "Host: example.com" http://127.0.0.1:18000/get | ||
``` | ||
|
||
### Load Testing the GRPC RateLimitService directly | ||
|
||
This load test will use `grpcurl`. You need [Go SDK](https://golang.org/doc/install) installed. | ||
|
||
Run a load test a 5000 requests per second (RPS) for 10 seconds: | ||
|
||
```bash | ||
RPS=5000 make load-test | ||
``` | ||
|
||
### Load Testing via Envoy Proxy | ||
|
||
```bash | ||
cargo run --manifest-path loadtest/Cargo.toml --package loadtest --release -- --report-file=report.htm | ||
``` | ||
|
||
The report will be saved in `report.htm` file. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alexsnaps see above re: how to use |
||
### Limitador Image | ||
|
||
By default, the sandbox will run Limitador's `limitador-testing:latest` image. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
version: '3.8' | ||
services: | ||
envoy: | ||
image: envoyproxy/envoy:v1.20-latest | ||
depends_on: | ||
- upstream | ||
- limitador | ||
command: | ||
- /usr/local/bin/envoy | ||
- --config-path | ||
- /etc/envoy.yaml | ||
- --log-level | ||
- info | ||
- --component-log-level | ||
- http:debug,router:debug | ||
- --service-cluster | ||
- proxy | ||
expose: | ||
- "80" | ||
- "8001" | ||
ports: | ||
- "18000:80" | ||
- "18001:8001" | ||
volumes: | ||
- ./envoy.yaml:/etc/envoy.yaml | ||
envoy2: | ||
image: envoyproxy/envoy:v1.20-latest | ||
depends_on: | ||
- upstream | ||
- limitador | ||
command: | ||
- /usr/local/bin/envoy | ||
- --config-path | ||
- /etc/envoy.yaml | ||
- --log-level | ||
- info | ||
- --component-log-level | ||
- http:debug,router:debug | ||
- --service-cluster | ||
- proxy | ||
expose: | ||
- "80" | ||
- "8001" | ||
ports: | ||
- "18100:80" | ||
- "18101:8001" | ||
volumes: | ||
- ./envoy.yaml:/etc/envoy.yaml | ||
envoy3: | ||
image: envoyproxy/envoy:v1.20-latest | ||
depends_on: | ||
- upstream | ||
- limitador | ||
command: | ||
- /usr/local/bin/envoy | ||
- --config-path | ||
- /etc/envoy.yaml | ||
- --log-level | ||
- info | ||
- --component-log-level | ||
- http:debug,router:debug | ||
- --service-cluster | ||
- proxy | ||
expose: | ||
- "80" | ||
- "8001" | ||
ports: | ||
- "18200:80" | ||
- "18201:8001" | ||
volumes: | ||
- ./envoy.yaml:/etc/envoy.yaml | ||
upstream: | ||
image: kennethreitz/httpbin |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
version: '3.8' | ||
services: | ||
limitador: | ||
image: limitador-testing-all-features | ||
build: | ||
context: ../.. | ||
dockerfile: Dockerfile | ||
args: | ||
- CARGO_ARGS=--all-features | ||
command: | | ||
limitador-server --rls-ip 0.0.0.0 --rls-port 8081 --http-ip 0.0.0.0 --http-port "8080" | ||
-vv --grpc-reflection-service /opt/kuadrant/limits/limits.yaml | ||
distributed limitador 0.0.0.0:5001 http://limitador2:5001 http://limitador3:5001 | ||
expose: | ||
- "8080" | ||
- "8081" | ||
- "5001" | ||
ports: | ||
- "18080:8080" | ||
- "18081:8081" | ||
- "15001:5001" | ||
volumes: | ||
- ./limits.yaml:/opt/kuadrant/limits/limits.yaml | ||
limitador2: | ||
image: limitador-testing-all-features | ||
build: | ||
context: ../.. | ||
dockerfile: Dockerfile | ||
args: | ||
- CARGO_ARGS=--all-features | ||
command: | | ||
limitador-server --rls-ip 0.0.0.0 --rls-port 8081 --http-ip 0.0.0.0 --http-port "8080" | ||
-vv --grpc-reflection-service /opt/kuadrant/limits/limits.yaml | ||
distributed limitador2 0.0.0.0:5001 http://limitador:5001 http://limitador3:5001 | ||
expose: | ||
- "8080" | ||
- "8081" | ||
- "5001" | ||
volumes: | ||
- ./limits.yaml:/opt/kuadrant/limits/limits.yaml | ||
limitador3: | ||
image: limitador-testing-all-features | ||
build: | ||
context: ../.. | ||
dockerfile: Dockerfile | ||
args: | ||
- CARGO_ARGS=--all-features | ||
command: | | ||
limitador-server --rls-ip 0.0.0.0 --rls-port 8081 --http-ip 0.0.0.0 --http-port "8080" | ||
-vv --grpc-reflection-service /opt/kuadrant/limits/limits.yaml | ||
distributed limitador3 0.0.0.0:5001 http://limitador:5001 http://limitador2:5001 | ||
expose: | ||
- "8080" | ||
- "8081" | ||
- "5001" | ||
volumes: | ||
- ./limits.yaml:/opt/kuadrant/limits/limits.yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
version: '3.8' | ||
services: | ||
limitador: | ||
image: limitador-testing-all-features | ||
build: | ||
context: ../.. | ||
dockerfile: Dockerfile | ||
args: | ||
- CARGO_ARGS=--all-features | ||
command: | | ||
limitador-server --rls-ip 0.0.0.0 --rls-port 8081 --http-ip 0.0.0.0 --http-port "8080" | ||
-vv --grpc-reflection-service /opt/kuadrant/limits/limits.yaml | ||
distributed ${PEER_ID:-node1} 0.0.0.0:5001 ${PEER_URLS:-} | ||
expose: | ||
- "8080" | ||
- "8081" | ||
- "5001" | ||
ports: | ||
- "18080:8080" | ||
- "18081:8081" | ||
- "15001:5001" | ||
volumes: | ||
- ./limits.yaml:/opt/kuadrant/limits/limits.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this breaking cross platform builds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would it? This Dockerfile works fine on my arm mac.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.docker.com/reference/dockerfile/#from
When I need to do cross-compile, I need that
rust:1.78.0-bullseye
be native to my current machine platform. Whendocker buildx build --platform=linux/amd64
, without thatFROM --platform=${BUILDPLATFORM}
therust:1.78.0-bullseye
will belinux/amd64
and my current machine platform might be something else (like arm). Which is not correct.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's best if the plain Dockerfile just does a container build that matches the host, and then we have additional Dockerfiles to do the cross compiles like Dockerfile.aarch64.
Your saying your on arm trying to build linux/amd64 with that Dockerfile?? Shouldn't that work if the host is running QEMU?