Celery is the most widely used task queue in the Python world, especially with Django and Flask. It moves slow work (emails, reports, image processing, API calls, imports) out of web requests and into background workers. Running Celery well on a VPS is mostly about choosing sensible settings, because the defaults favour throughput over safety in a few important places.
How Celery Fits Together
web app ─▶ broker (Redis or RabbitMQ) ─▶ workers ─▶ result backend (optional)
▲
celery beat (one instance) schedules periodic tasks
For general patterns of background processing, see our background workers guide.
Choosing a Broker
| Broker | Strengths | Watch out for |
|---|---|---|
| Redis | Simple, fast, often already in your stack | Visibility timeout behaviour for long tasks; configure persistence and memory policy |
| RabbitMQ | Mature acknowledgements, routing and durability features | Another service to operate; see our RabbitMQ guide |
With Redis, tasks that are not acknowledged within the visibility timeout can be redelivered to another worker. Set the timeout longer than your longest task, especially when using late acknowledgement and ETA or countdown tasks. Configure Redis so it never evicts broker keys (see our Redis guide).
Concurrency Pools
- prefork (default): multiple processes; best for CPU-bound tasks; set concurrency near the vCore count.
- threads, gevent or eventlet: many concurrent I/O-bound tasks (API calls, sending messages) in fewer processes.
- Run separate worker groups for CPU and I/O tasks, each with a suitable pool.
Separate Queues
Route tasks to queues by type and priority, such as default, emails, reports and heavy, and start workers that consume specific queues. A big report job then never delays password reset emails. Keep the number of queues small and meaningful.
Acknowledgement, Prefetch and Idempotency
By default, Celery acknowledges a task when a worker receives it, so a crash mid-task loses it. For important tasks, enable acks_late so the task is acknowledged after completion, accepting that it may run twice after a crash. That makes idempotency essential: design tasks so a second run does no harm (check whether the email was already sent, use unique constraints, record processed IDs). Lower the prefetch multiplier (for example to 1) for long tasks, so one worker does not reserve many tasks while others sit idle.
Retries and Time Limits
- Use automatic retries for transient errors, with exponential backoff and a maximum number of attempts.
- Do not retry permanent errors such as invalid input.
- Set a soft time limit (raises an exception the task can handle) and a hard time limit (kills the process) for every task type.
- Record failures with enough context to debug, and alert on growing failure rates.
Memory Management
Long-running worker processes can grow in memory due to leaks in libraries or large data. Set worker_max_tasks_per_child or worker_max_memory_per_child so processes are replaced periodically. Pass IDs rather than large objects as task arguments, and load data inside the task.
Periodic Tasks with Celery Beat
Celery beat sends periodic tasks according to a schedule. Run exactly one beat instance, or tasks will be scheduled twice. With Django, the database-backed scheduler lets you manage schedules in the admin. Make periodic tasks idempotent too, because a restart near a scheduled time can cause duplicates or skips.
Results
Many tasks do not need stored results. Disable result storage by default and enable it only where callers need the outcome, with expiry times, so the result backend does not grow forever.
Running Workers
Run each worker group as a systemd service (or a container) with automatic restart, environment variables from a protected file, and logs to the journal or a log collector. On deploy, restart workers gracefully so they finish current tasks: Celery's warm shutdown waits for running tasks. Make sure task code changes stay compatible with tasks already in the queue. See our Django deployment guide for the web side.
Monitoring
Flower provides a web dashboard of workers, tasks and queues; keep it behind authentication and a private network. Export metrics for queue length, task rates, durations and failures to your monitoring system, and alert when queues keep growing or workers disappear (see our monitoring guide).
Sizing
| Workload | Suggested plan |
|---|---|
| Emails, notifications, API calls | 2 vCores / 8 GB with thread or gevent pools |
| Reports, exports, image processing | 4 vCores / 16 GB with prefork |
| Heavy data or ML preprocessing | 8 vCores / 32 GB, or dedicated worker servers |
Workers can live on the web server for small apps; move them to their own VPS when they compete with web traffic for CPU.
Example: An E-Commerce Django App
A Django store uses Redis as broker on a 4 vCore / 16 GB VPS. One worker group with a thread pool handles emails and webhooks; another prefork group with four processes generates invoices and exports. Important tasks use late acknowledgement and idempotency keys, each child process is recycled after 500 tasks, a single beat service runs nightly reports, and Flower is reachable only over VPN.
Common Mistakes
- Running two beat schedulers.
- Default early acknowledgement for critical tasks.
- Redis visibility timeout shorter than the longest task.
- No time limits, so hung tasks block workers forever.
- Storing every result without expiry.
In Short
Pick Redis or RabbitMQ, separate queues, match pools and concurrency to the work, use late acknowledgement with idempotent tasks, set time limits, recycle processes, run one beat, and monitor.
ServoMix Plans for This Workload
Celery workers scale with your tasks: I/O-heavy tasks fit 2 vCores / 8 GB with high concurrency; CPU-heavy tasks need about one process per vCore, so 4–8 vCores for serious processing.
AMD EPYC 7C13 VPS
Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| SMX vPro XS (AMD EPYC) | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹420/mo | Websites, small APIs, bots, staging and VPN servers | Order |
| SMX vPro S (AMD EPYC) | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹560/mo | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| SMX vPro M (AMD EPYC) | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹840/mo | Production databases, high-traffic sites, multi-container apps | Order |
| SMX vPro L (AMD EPYC) | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹1,120/mo | Large production workloads, SaaS platforms, analytics, in-memory caches | Order |
Intel Xeon Platinum 8269CY VPS
KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| SMX vCore XS (Intel Xeon) | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹270/mo | Business websites, small apps, scheduled jobs and bots | Order |
| SMX vCore S (Intel Xeon) | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,169/month | Business software, mid-size databases, several sites on one server | Check stock |
| SMX vCore M (Intel Xeon) | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,249/month | ERP/CRM stacks, heavier databases, multiple production apps | Check stock |
| SMX vCore L (Intel Xeon) | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,248/month | High-memory workloads and consolidated production servers | Check stock |
Prices are monthly in INR as listed on the ServoMix store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.
Frequently Asked Questions
Should Celery use Redis or RabbitMQ?
How many Celery workers should I run?
What does acks_late do?
Why do my Celery tasks run twice?
How do I run periodic tasks?
How do I stop memory growth in workers?
Should every task store its result?
How do I monitor Celery?
How do I deploy new code safely?
Which plan suits Celery workers?
Related Guides
Frequently Asked Questions
Should Celery use Redis or RabbitMQ?
Redis is simple and common; RabbitMQ offers stronger delivery features. Both work well when configured correctly.
How many Celery workers should I run?
For CPU-bound tasks, about one process per vCore; for I/O-bound tasks, a thread or gevent pool with higher concurrency.
What does acks_late do?
It acknowledges tasks after completion instead of on receipt, so tasks survive worker crashes but may run twice.
Why do my Celery tasks run twice?
Late acknowledgement after crashes, Redis visibility timeouts shorter than the task, or duplicate beat schedulers.
How do I run periodic tasks?
With exactly one Celery beat instance, optionally using a database-backed scheduler.
How do I stop memory growth in workers?
Recycle processes with worker_max_tasks_per_child or worker_max_memory_per_child.
Should every task store its result?
No. Disable results by default and enable them with expiry only where needed.
How do I monitor Celery?
Flower for a dashboard, plus metrics for queue length, durations and failures with alerts.
How do I deploy new code safely?
Restart workers gracefully so running tasks finish, and keep task signatures compatible with queued tasks.
Which plan suits Celery workers?
2 vCores / 8 GB for I/O tasks; 4 to 8 vCores for CPU-heavy processing.
Your feedback helps us continuously improve ServoMix guides.
Know someone who may find this guide useful?
