Problem
This may happen everyday for transactional infrastructure:
To solve the issue mentioned above, here are some basic concepts I want to introduce.
Immutable
Immutable means the server is built as an image, and when it has issues or needs to upgrade to a new version, instead of fixing or updating it, we build a new server from scratch and fade out the old one.
Docker
Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.
Docker image packs any dependencies and source codes for any development programming language, and run it as container in any kind of host.
Docker host has CPU and memory resources to run docker containers, a group of docker hosts forms a resources pool (CPU and memory) to run containers. By pulling the docker image from docker registry to a new docker host, you don't need to install and compile lots of dependencies.
Rolling Deployment
When programmers commit the source code to git repository, a new immutable docker image with version tag will be built automatically and deployed to the docker cluster. Risk and downtime are reduced by running a copy of new version and remove the old ones from load balancer during deployment.
Cloud
When we want to build a server in the old days, we need to figure out a list for CPU, memory, hard disk size, etc. Beside the performance expectation for the server we also need to cater the compatibilities about those components for further upgrade. In cloud era, docker host is EC2 on AWS (Amazon Web Services, the most powerful cloud platform), and it can be launched via web console or command line very easily for any specified size of instance, which can still also be scaled horizontally or vertically.
Auto Scale Cluster
The number of EC2 in an auto scale cluster can be auto adjusted by overall CPU loading, CPU reservation percentage, and memory reservation percentage. You don't need to prepay numbers of EC2 for it, just pay what you have used.
Application Load Balancer
Route traffic directly to a service (groups of containers)
Auto Scale Service
A group of docker containers which the number of containers can be auto adjusted by service CPU loading and memory utilisation.
Immutable Cloud
Combining all of the concepts mentioned above, it's immutable docker auto scale cluster.
Docker Auto Scale Cluster
You have a unlimited resources pool to run any kind of docker services with auto scale in both service level and cluster level.
This cluster can be server side to server any kind of backend programming for any kind of unexpected dynamic traffic, and it can also be client side for doing stress test or calculation tasks too.
It's the real power of the cloud!
Special Use Case Using Spot Instance
Spot EC2 instance is temporary instance in AWS cloud with much lower hourly price (most likely 80% off to the on demand EC2). Since it may be terminated anytime, it's highly recommended that all EC2 inside cluster should be identical (stateless). This money saving design is actually suitable for most of simple web servers.
Problem Solved
With immutable cloud, it's just another happy day for programmers: