This project sets up ORY Hydra with both MySQL and PostgreSQL databases for performance comparison. Each database is configured with specific tuning parameters and monitored using Prometheus and Grafana.
.
├── postgres/
│ ├── docker-compose.postgres.yml
│ ├── postgresql.conf
│ └── pg_hba.conf
├── mysql/
│ ├── docker-compose.mysql.yml
│ ├── my.cnf
│ ├── .my.cnf
│ └── Dockerfile.exporter
└── shared-monitoring/
├── docker-compose.monitoring.yml
├── prometheus/
│ └── prometheus.yml
└── grafana/
└── provisioning/
├── datasources/
└── dashboards/
All services use a single shared Docker network (hydra_benchmark_network
) to ensure proper communication between:
- Monitoring services (Prometheus, Grafana)
- Database servers (PostgreSQL, MySQL)
- Exporters (postgres_exporter, mysqld_exporter)
- ORY Hydra instances
This unified network approach simplifies service discovery and ensures metrics collection works properly.
- Tuned for OLTP workload
- Optimized buffer and memory settings
- Configured autovacuum for maintenance
- Monitoring via postgres_exporter
- InnoDB optimizations
- Buffer pool and log settings
- Performance schema enabled
- Custom mysqld_exporter configuration:
- Built from prom/mysqld-exporter:v0.15.0
- Configured with root access for complete metrics collection
- Enhanced metrics collection (tables, innodb, global status)
- Proper container naming for Prometheus service discovery
The experiments are designed to be run sequentially to ensure accurate benchmarking:
docker network create hydra_benchmark_network
cd shared-monitoring
docker-compose -f docker-compose.monitoring.yml up -d
cd ../postgres
docker-compose -f docker-compose.postgres.yml up -d
# Run experiments, then when complete:
docker-compose -f docker-compose.postgres.yml down
cd ../mysql
docker-compose -f docker-compose.mysql.yml up -d
# Run experiments, then when complete:
docker-compose -f docker-compose.mysql.yml down
cd ../shared-monitoring
docker-compose -f docker-compose.monitoring.yml down
docker network rm hydra_benchmark_network
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000
- PostgreSQL Metrics: http://localhost:9187/metrics
- MySQL Metrics: http://localhost:9104/metrics
- CPU & RAM Usage
- Buffer/Cache Usage
- Connection Stats
- Database-specific metrics:
- PostgreSQL: Autovacuum activity
- MySQL: InnoDB purge threads and buffer pool
- Single shared network for all services
- Streamlined job configuration with one job per component
- Hydra metrics collected via
/admin/metrics/prometheus
endpoint - Container names used for direct service discovery
- Database: oauth2-oidc
- Port: 5432
- Default Credentials:
- Username: postgres
- Password: secret
- Database: oauth2-oidc
- Port: 3306
- Default Credentials:
- Username: root
- Password: secret
- Public API: http://localhost:4444
- Admin API: http://localhost:4445
- Resource Limits:
- CPU: 1 unit
- Memory: 2GB
The project includes a hydra-tester
tool for simulating OAuth2 flows and benchmarking Hydra's performance:
cd hydra-tester
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Example: 10 clients, 5 threads/client, each thread repeats flow 3 times, 10 refresh cycles/repetition, 60s interval, 15s timeout
./run.py --clients 10 --threads-per-client 5 --flow-repeat-count 3 --refresh-count 10 --refresh-interval 60 --timeout 15 --verbose
See hydra-tester/README.md for detailed configuration options and usage instructions.
- Each database is configured with appropriate resource limits (2 CPU, 4GB RAM)
- Hydra instances are configured with 1 CPU and 2GB RAM
- Monitoring is set up to track key performance metrics
- Both setups use the same database name 'oauth2-oidc'