Deploying a Bencher App
Bencher is a powerful, open-source continuous benchmarking platform designed to help development teams track and optimize application performance over time. Built for modern software development workflows, Bencher integrates seamlessly with your CI/CD pipelines to automatically run benchmarks, detect performance regressions, and maintain performance standards throughout your codebase. Whether you’re optimizing critical algorithms, monitoring web service latency, or tracking memory usage, Bencher provides the insights and tools to keep your application performant.
Why Bencher?
Bencher stands out in the performance monitoring landscape with its comprehensive features and developer-friendly approach:
- Continuous Benchmarking: Automatically run and track benchmarks across every commit or pull request
- Regression Detection: Intelligent detection of performance regressions with statistical analysis
- Multi-Language Support: Works with Rust, Python, JavaScript, Java, C++, Go, and more
- CI/CD Integration: Seamless integration with GitHub Actions, GitLab CI, and other CI platforms
- Performance Tracking: Historical performance data and visualizations for trend analysis
- Threshold Management: Set and enforce performance thresholds for critical metrics
- Project Collaboration: Team-based access control and collaborative performance monitoring
- Customizable Metrics: Track any benchmark metric that matters to your application
- API-First Design: RESTful API for programmatic access and custom integrations
- Web Dashboard: Beautiful, intuitive interface for exploring performance data
- Open Source: Apache 2.0 licensed with active community support
- Self-Hosted: Complete control over your performance data and infrastructure
Bencher is ideal for performance-conscious development teams, open-source projects, and organizations that need granular control over their benchmarking infrastructure. With persistent storage on Klutch.sh, your performance data is always safe, searchable, and accessible.
Prerequisites
Before deploying Bencher, ensure you have:
- A Klutch.sh account
- A GitHub repository with your Bencher deployment configuration
- Basic familiarity with Docker and Git
- (Optional) PostgreSQL database for production deployments
Deploying Bencher
Create a New Project
Log in to your Klutch.sh dashboard and create a new project for your Bencher deployment.
Prepare Your Repository
Create a GitHub repository with the following structure for your Bencher deployment:
bencher-deploy/├─ Dockerfile├─ .env.example├─ .gitignore└─ README.mdHere’s a production-ready Dockerfile for Bencher:
FROM rust:1.75-slim as builderWORKDIR /app# Install dependenciesRUN apt-get update && apt-get install -y \git \curl \build-essential \&& rm -rf /var/lib/apt/lists/*# Clone Bencher repositoryRUN git clone https://github.com/bencherdev/bencher.git .# Build BencherRUN cargo build --release# Runtime stageFROM debian:bookworm-slimWORKDIR /app# Install runtime dependenciesRUN apt-get update && apt-get install -y \ca-certificates \libssl3 \&& rm -rf /var/lib/apt/lists/*# Copy binary from builderCOPY --from=builder /app/target/release/bencher-cli /usr/local/bin/bencherCOPY --from=builder /app/target/release/bencher-server /usr/local/bin/bencher-server# Create app directoriesRUN mkdir -p /app/data /app/logs# Expose port 61500 (default Bencher server port)EXPOSE 61500# Health checkHEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \CMD curl -f http://localhost:61500/health || exit 1# Start Bencher serverCMD ["bencher-server", "--listen", "0.0.0.0:61500"]Create a
.env.examplefile for environment configuration:Terminal window # Bencher ConfigurationBENCHER_HOST=0.0.0.0BENCHER_PORT=61500BENCHER_LOG_LEVEL=info# Database ConfigurationDATABASE_URL=postgresql://bencher:bencher_password@localhost:5432/bencherDATABASE_MAX_CONNECTIONS=10# SecurityBENCHER_API_TOKEN_EXPIRATION=86400BENCHER_JWT_SECRET=your-secure-jwt-secret# Optional: GitHub IntegrationGITHUB_CLIENT_ID=your-github-client-idGITHUB_CLIENT_SECRET=your-github-client-secretCommit and push to your GitHub repository:
Terminal window git initgit add .git commit -m "Initial Bencher deployment"git remote add origin https://github.com/yourusername/bencher-deploy.gitgit push -u origin mainCreate a New App
In the Klutch.sh dashboard:
- Click “Create New App”
- Select your GitHub repository containing the Dockerfile
- Choose the branch (typically
mainormaster) - Klutch.sh will automatically detect the Dockerfile in the root directory
Configure Environment Variables
Set up these environment variables in your Klutch.sh dashboard:
Variable Description Example BENCHER_HOSTServer host binding 0.0.0.0BENCHER_PORTServer port 61500BENCHER_LOG_LEVELLogging level (debug, info, warn, error) infoDATABASE_URLPostgreSQL connection string (required for production) postgresql://user:pass@host:5432/bencherDATABASE_MAX_CONNECTIONSDatabase connection pool size 10BENCHER_JWT_SECRETSecret key for JWT tokens (generate a secure random string) your-secure-jwt-secretBENCHER_API_TOKEN_EXPIRATIONAPI token expiration time in seconds 86400Configure Persistent Storage
Bencher requires persistent storage for benchmark data and databases. Add persistent volumes:
Mount Path Description Recommended Size /app/dataBenchmark data and artifacts 50GB /app/logsApplication logs 10GB In the Klutch.sh dashboard:
- Navigate to your app settings
- Go to the “Volumes” section
- Click “Add Volume” for each mount path
- Set mount paths and sizes as specified above
Set Network Configuration
Configure your app’s network settings:
- Select traffic type: HTTP
- Internal port: 61500 (the Bencher server port)
- Klutch.sh will automatically handle HTTPS termination
Deploy Your App
- Review all settings
- Click “Deploy”
- Klutch.sh will build the Docker image and start your Bencher instance
- Wait for the deployment to complete (typically 5-10 minutes for the initial build)
Initial Setup and Configuration
After deployment completes, access your Bencher instance:
Accessing the Bencher Dashboard
Navigate to your app’s URL: https://example-app.klutch.sh
You’ll see the Bencher dashboard where you can manage projects, view benchmarks, and configure integrations.
Creating Your First Project
- Log in to your Bencher instance
- Click “Create Project” or “New Project”
- Enter a project name (e.g., “My Application”)
- Add an optional description
- Configure project settings:
- Public or private visibility
- Repository URL (optional)
- Performance thresholds
- Save the project
Setting Up Benchmark Tracking
After creating a project:
-
Generate API Token
- Go to project settings
- Generate an API token for CI/CD integration
- Save this token securely
-
Configure Thresholds
- Set performance thresholds for critical metrics
- Define alert conditions and notification preferences
- Configure regression detection sensitivity
-
Add Team Members
- Invite team members to your project
- Set appropriate permission levels
Environment Variable Examples
Basic Bencher Configuration
BENCHER_HOST=0.0.0.0BENCHER_PORT=61500BENCHER_LOG_LEVEL=infoBENCHER_JWT_SECRET=your-secure-random-string-hereBENCHER_API_TOKEN_EXPIRATION=86400PostgreSQL Configuration (Production)
For production deployments with PostgreSQL:
BENCHER_HOST=0.0.0.0BENCHER_PORT=61500BENCHER_LOG_LEVEL=infoDATABASE_URL=postgresql://bencher:secure_password@postgres-host:5432/bencherDATABASE_MAX_CONNECTIONS=20DATABASE_POOL_TIMEOUT=10BENCHER_JWT_SECRET=your-secure-jwt-secretAdvanced Configuration
For fine-tuned control:
BENCHER_CORS_ALLOWED_ORIGINS=https://example.comBENCHER_RATE_LIMIT_REQUESTS=1000BENCHER_RATE_LIMIT_WINDOW=3600BENCHER_BACKUP_ENABLED=trueBENCHER_BACKUP_INTERVAL=86400Sample Code and Getting Started
Running Benchmarks with Bencher CLI
# List available projectsbencher project list
# Create a new benchmark resultbencher run --project my-app --branch main \ --testbed localhost \ --adapter rust_criterion \ -- cargo bench
# Compare benchmark resultsbencher run --project my-app --branch feature-x \ --testbed localhost \ --adapter rust_criterion \ --threshold-check percentage:25% \ -- cargo benchUsing the Bencher API
# Create a new project via APIcurl -X POST https://example-app.klutch.sh/api/v0/projects \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "My Application", "description": "Performance tracking for my app", "visibility": "private" }'
# Get project detailscurl https://example-app.klutch.sh/api/v0/projects/my-app \ -H "Authorization: Bearer YOUR_API_TOKEN"
# Retrieve benchmark resultscurl https://example-app.klutch.sh/api/v0/projects/my-app/results \ -H "Authorization: Bearer YOUR_API_TOKEN"
# Create a benchmark reportcurl -X POST https://example-app.klutch.sh/api/v0/projects/my-app/reports \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "branch": "main", "testbed": "production", "start_time": "2025-01-01T00:00:00Z", "end_time": "2025-01-31T23:59:59Z" }'GitHub Actions Integration
Example workflow file for continuous benchmarking:
name: Bencher Benchmarks
on: [push, pull_request]
jobs: benchmark: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3
- name: Install Rust uses: actions-rs/toolchain@v1 with: toolchain: stable
- name: Run Benchmarks run: | cargo bench --no-fail-fast
- name: Upload to Bencher env: BENCHER_PROJECT: my-app BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }} BENCHER_ADAPTER: rust_criterion BENCHER_HOST: https://example-app.klutch.sh run: | curl -X POST $BENCHER_HOST/api/v0/projects/$BENCHER_PROJECT/results \ -H "Authorization: Bearer $BENCHER_API_TOKEN" \ -H "Content-Type: application/json" \ -d @benchmark-results.jsonPython Benchmark Example
import requestsimport jsonfrom datetime import datetime
# ConfigurationBENCHER_HOST = "https://example-app.klutch.sh"PROJECT_ID = "my-app"API_TOKEN = "your-api-token"
# Sample benchmark resultsresults = { "project": PROJECT_ID, "branch": "main", "testbed": "local", "adapter": "python_pytest", "results": [ { "name": "test_algorithm_speed", "value": 42.5, "unit": "milliseconds" }, { "name": "test_memory_usage", "value": 256.0, "unit": "megabytes" } ], "timestamp": datetime.utcnow().isoformat() + "Z"}
# Upload resultsheaders = { "Authorization": f"Bearer {API_TOKEN}", "Content-Type": "application/json"}
response = requests.post( f"{BENCHER_HOST}/api/v0/projects/{PROJECT_ID}/results", headers=headers, json=results)
if response.status_code == 201: print("Benchmark results uploaded successfully")else: print(f"Error uploading results: {response.status_code}") print(response.text)Docker Compose for Local Development
For local testing before deploying to Klutch.sh:
version: '3.8'
services: bencher: build: . ports: - "61500:61500" environment: - BENCHER_HOST=0.0.0.0 - BENCHER_PORT=61500 - BENCHER_LOG_LEVEL=debug - DATABASE_URL=postgresql://bencher:bencher_password@postgres:5432/bencher - BENCHER_JWT_SECRET=dev-secret-key depends_on: postgres: condition: service_healthy volumes: - ./data:/app/data - ./logs:/app/logs restart: unless-stopped
postgres: image: postgres:15-alpine environment: - POSTGRES_DB=bencher - POSTGRES_USER=bencher - POSTGRES_PASSWORD=bencher_password volumes: - postgres_data:/var/lib/postgresql/data ports: - "5432:5432" healthcheck: test: ["CMD", "pg_isready", "-U", "bencher"] interval: 10s timeout: 5s retries: 5 restart: unless-stopped
volumes: postgres_data:Save as docker-compose.yml and run:
docker-compose up -dAccess Bencher at http://localhost:61500
Database Setup and Migration
Using PostgreSQL for Production
For production deployments with PostgreSQL:
- Deploy a PostgreSQL instance on Klutch.sh or use an external database
- Note the connection details (host, port, username, password, database name)
- Set the
DATABASE_URLenvironment variable in Bencher - Restart the application for changes to take effect
Database Initialization
On first deployment, Bencher automatically initializes the database schema:
# Manual database initialization (if needed)bencher-server --database-url postgresql://user:pass@host:5432/bencher initBacking Up Benchmark Data
# Backup PostgreSQL databasepg_dump -h postgres-host -U bencher -d bencher > bencher-backup.sql
# Restore from backuppsql -h postgres-host -U bencher -d bencher < bencher-backup.sqlPerformance Tracking and Visualization
Creating Performance Reports
- Navigate to your project dashboard
- Click “Reports” or “Performance Reports”
- Select date range and metrics
- Configure visualization preferences:
- Chart type (line, bar, scatter)
- Aggregation method (average, median, P95, P99)
- Comparison options
- Generate and export reports
Setting Up Alerts
Configure alerts for performance degradation:
- Go to project settings
- Set threshold values for each metric
- Configure notification channels:
- Email notifications
- Slack integration
- Webhook endpoints
- Test alert triggers
Analyzing Trends
# Get performance trend data for a metriccurl "https://example-app.klutch.sh/api/v0/projects/my-app/metrics/latency/trend" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -G \ --data-urlencode "start_date=2025-01-01" \ --data-urlencode "end_date=2025-01-31"Scaling and Performance
Vertical Scaling
For large benchmark workloads:
- Navigate to your app settings in Klutch.sh
- Increase instance resources:
- Minimum 2 CPU cores for production
- Minimum 4GB RAM
- Increase persistent volume sizes as needed
Database Optimization
For high-volume benchmark data:
DATABASE_MAX_CONNECTIONS=50DATABASE_POOL_TIMEOUT=30DATABASE_CONNECTION_IDLE_TIMEOUT=300DATABASE_STATEMENT_CACHE_SIZE=128Caching Configuration
Enable caching for frequently accessed data:
BENCHER_CACHE_ENABLED=trueBENCHER_CACHE_TTL=3600BENCHER_CACHE_MAX_SIZE=1000Custom Domain Configuration
To use your own domain with Bencher:
- Navigate to your app’s “Domains” section in Klutch.sh
- Click “Add Custom Domain”
- Enter your domain (e.g.,
benchmarks.yourdomain.com) - Configure your DNS provider with a CNAME record:
benchmarks.yourdomain.com → example-app.klutch.sh
- Klutch.sh automatically provisions SSL certificates
Security Best Practices
Authentication and Access Control
- Use strong, unique
BENCHER_JWT_SECRETfor token generation - Regularly rotate API tokens
- Implement role-based access control for team members
- Enable two-factor authentication if available
- Keep API tokens secure and never commit them to repositories
Network Security
- Always use HTTPS (Klutch.sh provides this automatically)
- Restrict database access to only your Bencher instance
- Use strong database passwords for PostgreSQL
- Monitor access logs for suspicious activity
- Implement rate limiting to prevent abuse
Data Privacy
- Your benchmark data stays on your server
- No external API calls for data storage or analytics
- Full control over data retention and deletion policies
- Regular backups ensure data resilience
- Encrypt sensitive data at rest and in transit
Troubleshooting
Common Issues and Solutions
Issue: Bencher server fails to start
Check the deployment logs in Klutch.sh dashboard. Common causes:
- Missing or invalid
BENCHER_JWT_SECRETenvironment variable - Database connection issues
- Port 61500 already in use
- Insufficient memory allocated
Issue: Benchmark results not uploading
Verify:
- API token is valid and not expired
- Project ID is correct
- Benchmark data format is valid
- Network connectivity to Bencher server
Issue: Database connection errors
Solutions:
- Verify
DATABASE_URLis correct and complete - Check that PostgreSQL instance is running and accessible
- Ensure database credentials are accurate
- Verify firewall rules allow connection to database
Issue: Slow benchmark result retrieval
Causes and solutions:
- Increase instance resources (CPU, RAM)
- Optimize database queries and indexes
- Reduce historical data retention period
- Enable caching for frequently accessed data
Issue: High memory usage
Solutions:
- Increase instance RAM allocation
- Reduce benchmark data retention period
- Optimize PostgreSQL configuration
- Monitor and limit concurrent API requests
Upgrading Bencher
To update Bencher to a newer version:
- Update your Dockerfile to use the latest Bencher commit:
RUN git clone https://github.com/bencherdev/bencher.git . && git pull origin main
- Commit and push to GitHub
- Klutch.sh will automatically rebuild with the latest version
- Test the updated version in a staging environment first
Advanced Configuration
GitHub OAuth Integration
GITHUB_OAUTH_ENABLED=trueGITHUB_CLIENT_ID=your-github-client-idGITHUB_CLIENT_SECRET=your-github-client-secretGITHUB_OAUTH_REDIRECT_URI=https://example-app.klutch.sh/auth/github/callbackWebhook Integrations
Configure webhooks for custom integrations:
BENCHER_WEBHOOK_ENABLED=trueBENCHER_WEBHOOK_URL=https://your-service.com/webhookBENCHER_WEBHOOK_EVENTS=benchmark_complete,threshold_exceededCustom Metric Units
Define custom units for benchmark metrics:
BENCHER_CUSTOM_UNITS=requests_per_second,memory_percent,cache_hit_ratioAdditional Resources
- Bencher Official Website - Documentation and guides
- Bencher GitHub Repository - Source code and issue tracking
- Bencher Documentation - Complete reference
- Bencher API Documentation - API reference
- Klutch.sh Getting Started Guide
- Klutch.sh Volumes Documentation
- Klutch.sh Custom Domains Guide
- PostgreSQL Documentation - Database reference
Conclusion
Deploying Bencher on Klutch.sh provides you with a comprehensive, self-hosted continuous benchmarking platform that helps your team maintain and improve application performance. With persistent storage for benchmark data, intelligent regression detection, and beautiful performance visualizations, Bencher enables data-driven performance optimization. Klutch.sh’s managed infrastructure ensures your benchmarking system is always available, secure, and scalable.
Start monitoring your application’s performance today by deploying Bencher on Klutch.sh and gain the insights needed to optimize your codebase for peak performance.