This project shows a web application built using a microservices architecture.
There are two python microservices (rest-count and rest-ip).
Using consul-template you can generate a dynamic Nginx configuration so that you can deploy new microservices version with no downtime.
You can find additional information on my Slideshare presentation "Always be shipping"
Docker 1.8.3
docker-compose 1.4.2
Run the following commands in terminal (the first time you have to wait for a few minutes to download the Docker base images):
docker build -t rest-count rest-count/
docker build -t rest-ip rest-ip/
docker-compose -f application/docker-compose.yml up -d
open your browser to http://localhost:8080/
you can check the Consul state on http://localhost:8500/ui/
now edit rest-count/main.py (for example, you can increase the version to 1.1)
docker build -t rest-count rest-count/
docker-compose -f application/docker-compose.yml up -d restcountprimary
sleep 15
docker-compose -f application/docker-compose.yml up -d restcountbackup
this section will explain how to can scale up and down docker-compose services.
open your browser to http://localhost:8500/ui/
. There you will find a rest-count service, running on two nodes (one primary and one backup). Note that each node is a Docker container. Execute
docker-compose -f application/docker-compose.yml scale restcountprimary=3
check again http://localhost:8500/ui
to ensure that there are now four rest-count instance (three primary and one backup).
Make a few requests to http://localhost:8080/api/v1/count
and then run docker-compose -f application/docker-compose.yml logs
to see how requests are processed by different rest-count instances.
You can now scale down the rest-count service without having any down time, e.g.:
docker-compose -f application/docker-compose.yml scale restcountprimary=2
Again, you can check http://localhost:8500/ui
to see that there are now only two primary instances.