The project for showing the zero-downtime approach
This project demonstrates a zero-downtime approach and provides solutions for critical operations that pose challenges.
It contains the migrations that allow smooth changing of the product version without downtime.
The project consists of Django ORM, simple GraphQL API and DB on postgreSQL.
It guarantees no downtime when switching one version at a time. In this example from v0.1 to v0.2, with firstly upgrading to v.0.1.1.
It contains the solution for:
is_published
slug
created
$ python -m venv env_name
$ pip install requirements.txt
$ docker-compose up
$ python manage.py migrate
populate_db
command.--amount
argument to specify number of instances to create:$ python manage.py populate_db --amount=1000
$ python -m celery -A zerodowntime worker -B -l info
$ python manage.py runserver
pgAdmin
, open http://localhost:5051/browser/ and log in (username: [email protected], password: root
).db
service from port 5432
, username
and password
are: demo
.Tags:
0.1.0
- the initial state, this is the starting point0.1.1
- contains changes that ensure the zero-downtime approach when switching to version v0.20.2
- version v0.2 of the system with applied intended model changes0.3
- contains the final stage with all required operationsBranches:
0.1
- corresponds to version v0.10.2
- corresponds to version v0.20.3
- corresponds to version v0.3The best way to check the zero downtime solution is to start from v0.1.0, switching through v0.1.1 to v0.2, and finally to v0.3.0.
Zero downtime ensures the compatibility of DB with the previous version of the system. On each step, the upgraded DB will be compatible with the previous version of the code.
Also on all of these step, I recommended you to check the changes on the product table in the pgAdmin.
You might ask yourself But why all of this effort, what wrong might happen? and the response it you can test it by yourself! Just follow the steps from What are the exact steps zero downtime approach? but with skipping the versions.
For example:
You should get errors when trying to perform API requests.
The easiest way to test the API is by opening the graphql playground. After starting the server go to http://localhost:8000/graphql/ and run some queries or mutations.