Python services in production · senior
Running Django and Celery on Kubernetes, and upgrading Django
A production setup separates web, workers, one beat, a migration job and the data stores, with a connection budget and observability. Support ends for old Django versions, so upgrades are planned work with a business case.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Processes: web pods (Gunicorn or an ASGI server), Celery worker deployments per queue (critical, default, bulk), exactly one beat or CronJobs, a migration Job, and Flower or a metrics exporter. Static files on S3 and a CDN, or WhiteNoise.
- Config from the environment and a secret manager; DEBUG = False, ALLOWED_HOSTS, SECURE_PROXY_SSL_HEADER; manage.py check --deploy in CI.
- Database: a connection budget across web, workers and jobs; PgBouncer once pods autoscale; CONN_MAX_AGE or Django's pool option; statement_timeout; a read replica for reports. Redis: separate instances for cache and broker, with noeviction for the broker.
- Deploys: migrations first as a Job and backward-compatible (expand and contract); rolling updates with readiness probes; a preStop sleep plus Gunicorn graceful timeout; Celery warm shutdown on SIGTERM with terminationGracePeriodSeconds longer than the longest task.
- Observability: JSON logs with request ids; rate, errors and duration per endpoint; queue length and age of the oldest message; task runtimes and failures; pool usage; OpenTelemetry traces from web to Celery; error tracking; alerts on service-level objectives.
- Scaling: HPA on CPU or latency for web, KEDA on queue length for workers, limits from measured memory per worker. At 10 times the load, database connections and slow queries usually break first, then third-party rate limits.
- Django support (facts.md, Nov 2026): 6.1 is current, 5.2 is the LTS supported until April 2028, and 4.2 LTS ended in April 2026. Unsupported Django gets no security fixes, and audits flag it.
- Upgrade plan: go LTS to LTS (4.2 to 5.2 first, then 6.x), fix deprecation warnings on the way (run tests with python -Wd), watch removed settings such as STATICFILES_STORAGE and DEFAULT_FILE_STORAGE (replaced by STORAGES), update third-party apps one at a time, and plan the Python upgrade as well. Use a staging soak, a canary release and no irreversible migrations in the same release. Explain it to the business with a dated risk, a real example and a cost against a planned 3 to 4 week effort.
The red pen
Common traps: mistake → fix
Mistake: One Django deployment with a Celery sidecar is enough
Fix: web, workers, beat and migrations scale and fail separately.
Mistake: Run migrations at pod start
Fix: pods race and a failure crash-loops all of them.
Mistake: No time for the upgrade this quarter, so wait
Fix: unsupported software keeps risk growing; plan it next to feature work.
Mistake: Jump straight to the newest Django
Fix: go LTS to LTS and fix warnings on the way.
Easy to hard
Questions interviewers ask, easy to hard
- Lay out Django, DRF, Celery, PostgreSQL and Redis in production on Kubernetes.
- Where do migrations run and why?
- What do you watch?
- What usually breaks first at 10 times the load?
- The product still runs Django 4.2 after support ended and the manager says there is no time. What do you do?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.