A high-performance benchmarking suite using C++ and WRK for comprehensive performance analysis of web frameworks across Node.js and Bun runtimes.
This benchmark suite is implemented in C++ for maximum performance and accuracy, using the industry-standard WRK load testing tool to evaluate Express, Fastify, and Hono frameworks across both Node.js and Bun runtime environments.
- Language: C++17 with modern standards
- Load Testing: WRK (HTTP benchmarking tool)
- Build System: Make with cross-platform support
- Frameworks: Express, Fastify, Hono
- Runtimes: Node.js, Bun
- Output: JSON and CSV formats
Results are automatically updated monthly via GitHub Actions
| Rank | Framework & Runtime | Requests/sec | Avg Latency | P90 Latency | P99 Latency | Throughput |
|---|---|---|---|---|---|---|
| 1 | TBD | TBD | TBD | TBD | TBD | TBD |
| 2 | TBD | TBD | TBD | TBD | TBD | TBD |
| 3 | TBD | TBD | TBD | TBD | TBD | TBD |
Run make run to generate latest results
macOS (via Homebrew):
# Install dependencies
brew install curl wrk pkg-config
# Verify installation
wrk --version
g++ --versionUbuntu/Debian:
# Install dependencies
sudo apt-get update
sudo apt-get install -y build-essential libcurl4-openssl-dev pkg-config
# Install WRK
git clone https://github.com/wg/wrk.git /tmp/wrk
cd /tmp/wrk && make && sudo cp wrk /usr/local/bin/
rm -rf /tmp/wrk
# Verify installation
wrk --version
g++ --version# Clone repository
git clone <repository-url>
cd framework-benchmark
# Install framework dependencies
npm install
bun install
# Check dependencies
make check-deps
# Build C++ benchmark
make
# Run benchmark suite
make run# Core targets
make # Build the benchmark (default)
make run # Build and run benchmark
make clean # Clean build artifacts
make clean-all # Clean all generated files
# Build variants
make debug # Build with debug symbols
make release # Build optimized release version
# Dependency management
make install-deps # Install system dependencies (macOS)
make install-deps-ubuntu # Install system dependencies (Ubuntu)
make check-deps # Verify all dependencies
# Development
make test-compile # Test compilation without running
make help # Show all available targets# Build commands
npm run build # Standard build
npm run build:debug # Debug build
npm run build:release # Optimized build
# Run commands
npm run benchmark # Run benchmark suite
npm run benchmark:wrk # Alias for benchmark
# Utility commands
npm run deps:install # Install system dependencies
npm run deps:check # Check dependencies
npm run test:compile # Test compilation
npm run clean # Clean all artifactsThe benchmark is configured in benchmark_wrk.cpp:
const BENCHMARK_CONFIG = {
connections: 100, // Concurrent connections
threads: 12, // Worker threads
duration: "30s", // Test duration per run
timeout: "10s", // Request timeout
runs: 3, // Number of runs per framework
warmupTime: 3000, // Server warmup time (ms)
cooldownTime: 2000, // Cooldown between tests (ms)
latencyStats: true // Enable detailed latency percentiles
};| Framework | Port | Runtime Support | Response Type |
|---|---|---|---|
| Express | 3000 | Node.js, Bun | JSON |
| Fastify | 3001 | Node.js, Bun | JSON |
| Hono | 3002 | Node.js, Bun | JSON |
- Requests per Second (RPS): Primary performance indicator
- Latency Statistics: Average, P50, P75, P90, P99 percentiles
- Throughput: Data transfer rate (MB/s)
- Total Requests: Aggregate request count across all runs
- Error Rate: HTTP errors and connection failures
- Timeout Count: Request timeouts
- Socket Errors: Connection-level failures
- Standard Deviation: Statistical variance across runs
{
"timestamp": "2024-01-01T00:00:00.000Z",
"benchmarkTool": "wrk",
"environment": {
"nodeVersion": "v20.0.0",
"bunVersion": "1.0.0",
"wrkVersion": "4.2.0",
"platform": "darwin",
"cpus": 8
},
"results": [
{
"environment": "Express on Node.js",
"runtime": "node",
"framework": "express",
"requestsPerSecond": 12000.50,
"avgLatency": 8.33,
"p90Latency": 15.20,
"p99Latency": 25.10,
"throughput": 2048000,
"errors": 0
}
]
}Spreadsheet-compatible format for analysis and visualization.
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.json({ message: 'Hello from Express!', timestamp: Date.now() });
});
app.listen(3000, () => console.log('Express server running on port 3000'));const fastify = require('fastify')({ logger: false });
fastify.get('/', async (request, reply) => {
return { message: 'Hello from Fastify!', timestamp: Date.now() };
});
fastify.listen({ port: 3001, host: '0.0.0.0' });import { Hono } from 'hono';
import { serve } from '@hono/node-server';
const app = new Hono();
app.get('/', (c) => {
return c.json({ message: 'Hello from Hono!', timestamp: Date.now() });
});
serve({ fetch: app.fetch, port: 3002 });Monthly Benchmarks (.github/workflows/monthly-benchmark.yml)
- Runs automatically on the 1st of each month
- Tests across multiple Node.js versions
- Updates repository with latest results
- Generates performance trend data
PR Benchmarks (.github/workflows/pr-benchmark.yml)
- Validates performance impact of changes
- Runs optimized tests for faster CI execution
- Comments results directly on pull requests
- Compares against baseline performance
Setup Validation (.github/workflows/test-setup.yml)
- Tests compilation across Ubuntu and macOS
- Validates all framework servers
- Ensures WRK integration works correctly
- Runs performance smoke tests
# Trigger monthly benchmark manually
gh workflow run monthly-benchmark.yml
# Trigger PR benchmark for specific PR
gh workflow run pr-benchmark.yml -f pr_number=123- Create server file:
newframework_server.js - Add to configuration in
benchmark_wrk.cpp:
setups.push_back({
"NewFramework on Node.js",
3003,
"node",
"newframework",
"newframework_server.js"
});- Update port allocation and documentation
Edit the configuration struct in benchmark_wrk.cpp:
const BENCHMARK_CONFIG = {
connections: 200, // Increase load
duration: "60s", // Longer tests
runs: 5, // More runs for accuracy
// ... other parameters
};# Custom compiler flags
make CXXFLAGS="-O3 -march=native"
# Debug build with specific flags
make debug CXXFLAGS="-g -fsanitize=address"
# Cross-compilation
make CXX=clang++Requests per Second (RPS)
- Primary metric for throughput comparison
- Higher values indicate better performance
- Consider alongside latency metrics
Latency Percentiles
- P50 (median): Typical user experience
- P90: Experience of slower 10% of requests
- P99: Worst-case scenarios (important for SLA)
Throughput vs. Latency Trade-offs
- High RPS with low latency = optimal
- High RPS with high latency = potential overload
- Consider both metrics for complete picture
- Multiple runs provide statistical confidence
- Standard deviation indicates result consistency
- Large deviations may indicate system variance
Compilation Errors
# Check dependencies
make check-deps
# Verify compiler version
g++ --version # Requires GCC 7+ or Clang 5+
# Clean and rebuild
make clean && makeWRK Installation Issues
# macOS
brew install wrk
# Ubuntu - manual build
git clone https://github.com/wg/wrk.git
cd wrk && make && sudo cp wrk /usr/local/bin/Server Startup Failures
# Test individual servers
node express_server.js &
curl http://localhost:3000
# Check port availability
lsof -i :3000Permission Issues
# Linux - ensure user can bind to ports
# Run with sudo if needed, or use ports > 1024Low Performance Results
- Check system load during benchmarking
- Ensure no other services using test ports
- Verify adequate system resources (CPU, memory)
- Consider reducing concurrent connections for smaller systems
Inconsistent Results
- Multiple runs help identify variance
- Check for background processes affecting performance
- Ensure stable network conditions
- Consider longer warmup times
- Fork the repository
- Create feature branch:
git checkout -b feature/improvement - Test changes:
make clean && make && make run - Update documentation if needed
- Submit pull request with performance validation
- Follow C++17 standards
- Use meaningful variable names
- Include error handling
- Document complex algorithms
- Maintain cross-platform compatibility
[Specify your license here]
- Repository: [GitHub Repository URL]
- Issues: [Issues URL]
- Discussions: [Discussions URL]
- Latest Results: [Results URL]
Built with β‘ by the performance engineering team
Last updated: [Auto-generated timestamp]