Self-Hosting
Deploy Flipswitch on your own infrastructure
Self-Hosting
Flipswitch is designed to be self-hosted on your own infrastructure. This guide covers deployment options and configuration.
Requirements
- Java 21+ - For running the backend server
- PostgreSQL 14+ - Primary database
- Redis (optional) - For distributed caching in multi-instance deployments
Quick Start with Docker
The server will be available at http://localhost:8080.
Configuration
Configure Flipswitch using environment variables:
Database
| Variable | Default | Description |
|---|---|---|
DB_URL | jdbc:postgresql://localhost:5432/flipswitch | PostgreSQL JDBC URL |
DB_USERNAME | flipswitch | Database username |
DB_PASSWORD | flipswitch | Database password |
Server
| Variable | Default | Description |
|---|---|---|
BIND_HOST | 0.0.0.0 | Server bind host |
BIND_PORT | 8080 | Server bind port |
CORS_ORIGINS | * | Allowed CORS origins (comma-separated) |
Authentication
Flipswitch supports multiple authentication modes:
Users are stored in the database with bcrypt-hashed passwords.
Redis (Optional)
For multi-instance deployments with distributed caching:
| Variable | Default | Description |
|---|---|---|
REDIS_URL | (disabled) | Redis connection URL |
REDIS_PASSWORD | (none) | Redis password |
Docker Compose
Create a docker-compose.yml for a complete setup:
Kubernetes
Example Kubernetes deployment:
Database Migrations
Flipswitch automatically runs database migrations on startup using Flyway. No manual migration steps are required.
Ensure your database user has CREATE TABLE permissions for the initial setup.
High Availability
For production deployments, consider:
1. Multiple Instances
Run multiple Flipswitch instances behind a load balancer:
- Use Redis for distributed caching
- Ensure sticky sessions are NOT required (stateless design)
- SSE connections are per-instance
2. Database Replication
Set up PostgreSQL with:
- Primary for writes
- Read replicas for flag evaluations
- Connection pooling (PgBouncer)
3. Redis Cluster
For high-traffic deployments:
Monitoring
Prometheus Metrics
Flipswitch exposes Prometheus metrics at /metrics:
Health Checks
| Endpoint | Description |
|---|---|
/health | Basic health check |
/health/ready | Readiness (database connected) |
/health/live | Liveness (server running) |
Security
API Key Management
- Generate separate API keys per environment
- Rotate keys regularly
- Use server keys only on backend services
Network Security
- Use TLS/HTTPS in production
- Restrict database access to Flipswitch servers
- Use private networking for Redis
CORS Configuration
Backup & Recovery
Database Backups
Point-in-Time Recovery
Configure PostgreSQL WAL archiving for point-in-time recovery capabilities.
Troubleshooting
Connection Refused
Check that PostgreSQL is running and accessible:
Migrations Failed
Check the Flyway migration history:
SSE Not Working
Verify that your proxy/load balancer supports long-lived connections and has appropriate timeout settings.