This project demonstrates how to use celery
and redis
for asynchronous task processing. The tasks
themselves (encrypting and decrypting some strings with simple base64) are pretty trivial, that do not
warrant a process fork or such heavy lifting. The focus is on learning one-thing-at-a-time, and not
get bogged down by some complicated processing pipeline, instead understanding the behaviour of a
future/promise for asynchronous processing.
The code is pretty messy and intended to be minimal, as opposed to production ready. Use at your own risk.
It is recommended to run the server inside a docker container to facilitate the dependency set-up. Make sure you have recent versions of docker daemon and CLI installed. The current repository was tested on Docker version 20.10.14 running on a 64 bit AMD architecture.
Clone the repository and run the following commands at the project root directory.
$ docker compose up --detach
This will fire up the redis and the webapp as two separate containers in daemonic mode.
Try to use kube-kompose to directly convert the docker compose file into kubernetes manifests.
Failing that, try the following architecture.
- For workers, create replicated Deployments without any Service
- For the redis, create a single pod Deployment with a ClusterIP service
- For ASGI, create (optionally replicated) Deployment with a default load balanced service.
The ClusterIP Service will be visible internally, and can be accessed by the Service name acting as hostname. The ASGI will have a public IP address.