Guide
Initialize swarm
title: Scaling
Scale GoFlow to handle millions of requests.
Architecture for Scale
Docker Swarm Deployment
Queue Sharding
Distribute load across multiple queue instances:
Sharding strategies:
HashShard- Consistent hashing on job IDRoundRobinShard- Even distributionLeastLoadedShard- Route to least busy shard
Partitioned Workers
Workers claim specific partitions:
Distributed Locking
Prevent duplicate processing:
Semaphores for Rate Limiting
Control concurrency:
Metrics & Monitoring
Key metrics:
goflow_jobs_completed_totalgoflow_jobs_failed_totalgoflow_queue_depthgoflow_job_duration_secondsgoflow_workers_active
Event Sourcing
Track all events for debugging:
Alerting
Get notified on failures:
Performance Tips
- Use sharding - Single Redis is the bottleneck
- Batch operations - Process jobs in batches when possible
- Tune concurrency - Match worker count to workload
- Monitor queue depth - Alert if it grows too fast
- Use DLQ - Don't retry forever, move to DLQ
- Event sourcing - Debug without guessing
