Overview
Want to see Bifrost’s performance in your specific environment? The Bifrost Benchmarking Repository provides everything you need to conduct comprehensive performance tests tailored to your infrastructure and workload requirements. What You Can Test:- Custom Instance Sizes - Test on your preferred AWS/GCP/Azure instances
- Your Workload Patterns - Use your actual request/response sizes
- Different Configurations - Compare various Bifrost settings
- Provider Comparisons - Benchmark against other AI gateways or raw OpenAI
- Load Scenarios - Test burst loads, sustained traffic, and endurance
- mocker — a mock LLM provider server with configurable latency, failures, and rate limits. Point your gateways at it to measure pure gateway overhead with zero API costs.
- hitter — a load generator for stress-testing a single Bifrost deployment with realistic multi-model/streaming traffic.
💡 Open Source: The benchmarking tool is completely open source! Feel free to submit pull requests if you think anything is missing or could be improved.
Prerequisites
Before running benchmarks, ensure you have:- Go 1.24+ installed on your testing machine
- Bifrost instance running and accessible
- Target providers configured in Bifrost (real providers, or the mocker for cost-free runs)
- Network access between benchmark tool and Bifrost
- Sufficient resources on the testing machine to generate load
Quick Start
1. Clone the Repository
2. Build the Benchmark Tool
benchmark executable (or benchmark.exe on Windows).
3. Configure Gateway Ports
Create a.env file in the repo root with the port of each gateway you plan to benchmark — the tool reads ports from here, not from flags:
.env variable.
4. Run Your First Benchmark
Either-rate (fixed RPS) or -users (fixed concurrency) is required:
⚠️ Note: Omitting-providerbenchmarks all providers sequentially — includingopenai, which sends real requests toapi.openai.comusing yourOPENAI_API_KEY.
Configuration Options
Basic Configuration
| Flag | Required | Description | Default |
|---|---|---|---|
-rate <number> | ✅* | Requests per second (mutually exclusive with -users) | None |
-users <number> | ✅* | Concurrent users to maintain (mutually exclusive with -rate) | None |
-provider <name> | ❌ | Gateway to benchmark: bifrost, openai, or another supported gateway (full list in the repo README); empty runs all | None (all) |
-duration <seconds> | ❌ | Test duration in seconds | 10 |
-output <filename> | ❌ | Results output file | results.json |
-big-payload | ❌ | Use a ~10KB request payload instead of the ~200B default | false |
-rate or -users must be provided.
Advanced Configuration
| Flag | Description | Default |
|---|---|---|
-timeout <seconds> | Request timeout — set to duration + expected backend latency | 300 |
-cooldown <seconds> | Cooldown between provider tests | 60 |
-model <name> | Model to put in the request payload | gpt-4o-mini |
-host <address> | Host address of the gateway servers | localhost |
-path <path> | API path to hit (e.g. chat/completions, embeddings) | chat/completions |
-suffix <suffix> | URL route suffix prepended to the path | v1 |
-request-type <type> | chat or embedding — controls payload shape | chat |
-prompt-file <path> | File whose content is used as the prompt (for large-prompt tests) | "" |
-ramp-up | Gradually ramp users up (only with -users) | false |
-ramp-up-duration <seconds> | Seconds to ramp from 1 to -users users | 0 |
-debug | Detailed logging and periodic status updates | false |
Rate vs. Users Mode
-ratesends requests at a constant RPS regardless of response times — best for measuring throughput capacity and latency under a known load.-userskeeps exactly N requests in flight at all times; as one completes, the next is dispatched. Throughput becomes ≈users / avg_latency— best for simulating connection pools and realistic client behavior.
Benchmark Scenarios
1. Basic Performance Test
Test standard performance with typical request sizes:2. High-Load Stress Test
Push your instance to its limits:3. Large Payload Test
Test with bigger request/response sizes:4. Endurance Test
Long-running stability test:5. Concurrent Users with Ramp-Up
Simulate realistic traffic that gradually builds:6. Comparative Benchmarking
Compare Bifrost against other gateways (each gateway’s port comes from.env):
Understanding Results
The benchmark tool writes per-provider metrics to the output file (keyed by provider, latest run per provider):Key Metrics Explained
Critical Performance Indicators
Success Rate:- Target: >99.9% for production readiness
- Excellent: 100% (perfect reliability)
- P50 (Median): Typical user experience
- P99: Worst-case user experience
- Mean: Overall average performance
- Peak / Average: server-side RSS sampled during the run — the tool finds the gateway process by its configured port, so run the benchmark on the same machine as the gateway to capture memory stats
- Categorized failure analysis (timeouts, HTTP errors, connection failures)
Instance Sizing Recommendations
Based on your benchmark results, use these guidelines for production sizing:Resource Planning Matrix
| Target RPS | Memory Usage | Recommended Instance | Notes |
|---|---|---|---|
| < 1,000 | < 1GB | t3.small | Cost-effective for light loads |
| 1,000 - 3,000 | 1-2GB | t3.medium | Balanced performance/cost |
| 3,000 - 5,000 | 2-4GB | t3.large | High-performance production |
| 5,000+ | 3-6GB | t3.xlarge+ | Enterprise/mission-critical |
Configuration Tuning Based on Results
If seeing high latency:- Increase
initial_pool_size - Increase
buffer_size - Consider larger instance
- Decrease
initial_pool_size - Optimize
buffer_size - Monitor for memory leaks
- Reduce request rate
- Increase timeout settings
- Check provider limits
Advanced Testing Scenarios
Burst Load Testing
Simulate traffic spikes:Multi-Instance Testing
Test horizontal scaling — environment variables override.env, so you can target multiple instances in parallel:
Embeddings Benchmarking
Benchmark embeddings endpoints, optionally with very large prompts from a file:10kbprompt.txt and 50kbprompt.txt as ready-made fixtures.
Continuous Benchmarking
Automated Testing Pipeline
Set up regular performance regression testing:Performance Monitoring Integration
Monitor key metrics over time:- Success rate trends
- Latency percentile changes
- Memory usage patterns
- Throughput capacity
Troubleshooting
Common Issues
“Either —rate or —users flag must be provided”:- Exactly one of
-rateor-usersis required; they are mutually exclusive.
- Check the provider’s port (e.g.
BIFROST_PORT) is defined in the.envfile at the repo root.
- The gateway isn’t running, or the
.envport is wrong. The benchmark still runs; only memory stats are skipped.
- Raise
-timeout; it must coverduration + backend latency.
- Check provider API key limits
- Verify Bifrost configuration
- Monitor upstream provider status
- Reduce request rate for baseline test
- Run multiple test iterations
- Account for network variability
- Use longer test durations (60+ seconds)
- Isolate testing environment
- Point the gateway at the repo’s mock provider to eliminate upstream variability
Next Steps
After Running Benchmarks
- Analyze Results: Compare against official benchmarks
- Optimize Configuration: Tune based on your specific results
- Plan Capacity: Size instances based on measured performance
- Set Up Monitoring: Track key metrics in production
Compare Results
- t3.medium Performance - Compare against medium instance results
- t3.xlarge Performance - Compare against high-performance configuration

