A performance benchmark for Rage, testing both standard API requests and Server-Sent Events (SSE) streaming under load.
This project benchmarks Rage's ability to handle:
- API Endpoint (
GET /api) - Fetches a random record from a SQLite database (10,000 records) and returns it as JSON - SSE Endpoint (
GET /sse) - Creates a streaming connection that sends random values every second for 5-10 seconds
Generated with rage new -d sqlite3 with the following customizations:
- YJIT enabled via
config/initializers/yjit.rb - Production logs redirected to
log/production.log(instead ofSTDOUT)
- Ruby (with YJIT support, Ruby 3.2+)
- SQLite3
- k6 for load testing
bundle installbundle exec rage db:create
bundle exec rage db:migrate
bundle exec rage db:seedThis seeds the database with 10,000 World records.
Development:
rage sProduction:
rage s -e production -b 0.0.0.0The benchmark uses k6 and runs two scenarios simultaneously:
- SSE Streams: Maintains a constant number of concurrent SSE connections
- API Requests: Sends requests at a constant arrival rate
| Parameter | Default | Description |
|---|---|---|
TARGET_STREAMS |
5000 | Number of concurrent SSE connections |
TARGET_RPS |
5000 | API requests per second |
| Duration | 5 minutes | Total benchmark duration |
k6 run benchmark/k6.jsk6 run benchmark/k6.js \
-e BASE_URL=http://localhost:3000 \
-e TARGET_STREAMS=1000 \
-e TARGET_RPS=2000The benchmark tracks:
sse_messages_total- Total SSE messages receivedsse_streams_opened- Number of streams openedsse_streams_closed- Number of streams closed successfullysse_stream_duration- Duration of each streamsse_errors- Failed SSE connections
api_req_success- Successful API requestsapi_req_errors- Failed API requestsapi_req_duration- Request latency
- API error rate < 1%
- SSE error rate < 1%
- API p95 latency < 500ms
- At least one SSE message received
.
├── app/
│ ├── controllers/
│ │ └── benchmarks_controller.rb # API and SSE endpoints
│ └── models/
│ └── world.rb # ActiveRecord model
├── benchmark/
│ └── k6.js # k6 load test script
├── config/
│ ├── environments/
│ │ └── production.rb # Production config
│ └── initializers/
│ └── yjit.rb # YJIT enablement
└── db/
├── migrate/
├── schema.rb
└── seeds.rb # Seeds 10,000 World records
MIT