Prompt
How do I scale workers separately from my main app?
Latest observation
Oct 24, 2026
OpenAI APIWeb search: off
You generally want to run workers as a separate process/service from your main app, then scale that worker service independently.
Basic idea
- Web app handles requests
- Worker(s) handle background jobs from a queue
- Scale them separately based on different bottlenecks
Common setup
1. Put jobs on a queue
Examples:
- Redis
- RabbitMQ
- SQS
- Sidekiq / BullMQ / Celery / RQ / Resque, etc.
2. Run workers as their own process
Instead of starting workers inside the web server, start them with a separate command, for example:
npm run worker
or
python worker.py
or
bundle exec sidekiq
3. Deploy as separate service/container
Typical options:
- Docker Compose: separate
webandworkerservices - Kubernetes: separate Deployment for web and workers
- Heroku/Render/Fly: separate dyno/service for workers
- VMs: separate systemd services or process managers
4. Scale worker instances independently
Examples:
- 2 web instances, 10 worker instances
- or 5 web instances, 2 worker instances
This lets you increase worker capacity without affecting the app servers.
Example with Docker Compose
services:
web:
build: .
command: npm run start
ports:
- "3000:3000"
worker:
build: .
command: npm run worker
depends_on:
- redis
Then scale workers:
docker compose up --scale worker=5
Example with Kubernetes
Create:
- one Deployment for
web - one Deployment for
worker
Then scale worker deployment:
kubectl scale deployment worker --replicas=10
Best practices
- Keep worker code stateless
- Use retries and dead-letter queues
- Make jobs idempotent
- Monitor queue depth and job latency
- Autoscale workers based on queue length or CPU if possible
If you tell me your stack (Rails, Node, Django, etc.) and where you deploy, I can show the exact setup.