This is a example of how we can design an application that is ready to handle unexpected events.
You can easily spin up the whole system by executing:
docker-compose up -d
This will setup our 2 services and will make sure they are talking to each other. If you want to play around with it and simulate failure you can run the failure scenarios.
If you really wanna see the power of a reliable service setup you should install the helm charts that are available.
helm install build/coffee-shop
This will setup:
- HA rabbitMQ cluster
- Postgres database with the migrations already applied
- 2 instances load balanced of the
- 2 instances of the
baristaservice that is listening to rabbitmq messages
Enable an ingress controller
helm install stable/nginx-ingress --name nginx-ingress \ --set controller.stats.enabled=true \ --set controller.metrics.enabled=true
You can access the coffee-shop
reception endpoint at http://coffee-shop.local
Enable prometheus and grafana
helm install -f build/monitoring/grafana-values.yaml --name prometheus --namespace monitoring stable/prometheus-operator
You can access grafana at http://monitoring.local
Think about a coffee-shop. The first thing you normally do when you enter one is to go to the reception
and order a coffee. Reception is the service that is getting new orders and sending to the
barista to be done.
In this service we have:
- RabbitMQ to send messages that are send with protocol buffers
- Tracing and monitoring using open census
- All calls to external dependencies are wrapped around a Circuit Breaker. You can use a Hystrix dashboard to check for the circuits.
- To keep things simple, we mock the
paymentsservice with wiremock in a separate container where we can simulate failure when necessary.
Barista is the service that actually prepares your coffee and make sure you can have the best experience possible.
barista will get an order request from RabbitMQ and start preparing your coffee. Once the coffee is ready
another message is published and whoever want's to interact with that will be able to.
Breaking the message broker
docker-compose stop rabbitmq