Overview
Deploying Viaduct to production requires careful consideration of performance, monitoring, error handling, and scalability. This guide covers best practices and production-specific concerns.Performance Optimization
Connection Pooling
Configure connection pooling for all data sources to avoid connection overhead:Query Complexity Limits
Protect your API from expensive queries:Caching Strategies
Implement caching at multiple levels: 1. DataLoader for batch loading:HTTP Server Tuning
Configure your HTTP server for production load: Jetty:Monitoring and Observability
Metrics Collection
Integrate with Micrometer for comprehensive metrics:- Query execution time (percentiles: p50, p95, p99)
- Error rate by query type
- Resolver execution time
- Data source connection pool utilization
- Query complexity distribution
- Cache hit/miss ratio
- Concurrent request count
- JVM memory and GC metrics
Error Reporting
Implement comprehensive error reporting:Logging
Configure structured logging:ERROR: Unhandled exceptions, system failuresWARN: GraphQL validation errors, deprecated field usageINFO: Query execution metrics, authentication eventsDEBUG: Detailed query execution, resolver invocations (avoid in production)
Distributed Tracing
Implement distributed tracing for microservices:Error Handling
Custom Error Responses
Provide user-friendly error messages while logging details:Graceful Degradation
Handle partial failures gracefully:Security
Authentication
Implement authentication at the HTTP layer:Authorization
Implement field-level authorization in resolvers:Rate Limiting
Protect against abuse:Input Validation
Validate all inputs:Scaling
Horizontal Scaling
Viaduct instances are stateless and can be scaled horizontally:Load Balancing
Configure load balancing:Auto-scaling
Configure horizontal pod autoscaling:Health Checks
Implement comprehensive health checks:Deployment Strategies
Blue-Green Deployment
- Deploy new version to green environment
- Run smoke tests against green
- Switch load balancer to green
- Keep blue environment as rollback option
- Shut down blue after stability confirmed
Canary Deployment
- Deploy new version to small subset of instances (5-10%)
- Monitor error rates and performance
- Gradually increase traffic to new version
- Roll back if issues detected
- Complete rollout if metrics are healthy
Rolling Update
Configuration Management
Use environment variables for configuration:Checklist
Before going to production:- Connection pooling configured for all data sources
- Query complexity and depth limits set
- Caching implemented (DataLoader, response, field-level)
- Metrics collection integrated (Micrometer/Prometheus)
- Error reporting configured (Sentry, CloudWatch, etc.)
- Structured logging implemented
- Distributed tracing set up (if microservices)
- Authentication implemented
- Authorization implemented at field level
- Rate limiting configured
- Input validation on all mutations
- Health check endpoint implemented
- Load testing completed
- Auto-scaling configured
- Deployment strategy chosen and tested
- Monitoring dashboards created
- Alerts configured for key metrics
- Runbooks written for common issues
- Disaster recovery plan documented
- Security audit completed
- Performance baseline established
Next Steps
Embedding Viaduct
Review the embedding guide
Development Server
Learn about local development
Monitoring
Deep dive into monitoring and observability
Security
Learn more about security best practices