Deployment strategy patterns are common solutions to a subset of problems which can be solved in the same way.
Deploy strategy patterns use a set of concepts which I will further explain below.
Load Balancer can be a hardware or a virtual hardware that acts like a reverse proxy mainly distributing network/application traffic to more servers.
There are a couple of reasons why to use it:
- increase the capacity of infrastructure to prevent system fail on high load
- all servers will have less load.
Listener/Server is an instance used by load balancer to handle a transaction/request. This figure shows how a load balancer and 3 listeners look like:
The way the load balancer communicates with a listener can be configured, the ssl termination can be on load balancer level or on server level.
Health Check is a concept which defines how a load balancer detects an instance as unavailable.
The LB will check from time to time that a server is alive, using a timeout. If the server is not responding, then it will be marked as unavailable and will not receive any more transactions/traffic to process.
Stickiness it is a concept which means that a server which processed a transaction for a client should process all transactions for that client. In order to achieve this, more strategies can be used. Some of them are:
- client ip (the client ip is used to make session sticky, the same ip will be processed by the same server)
- client ip + protocol (a combination between client ip and protocol will be used to make session sticky so that the same ip with the same protocol will be processed by the same server)
- cookie name + ttl (a cookie name is used to make session sticky, but this time will set also a cookie ttl)
- cookie name (a cookie name is used to make session sticky, it assumes will never expire)
- duration based (the load balancer attaches a cookie to request, with an expiry date to know what server to process the requests. If server is no longer available, another server is used. LB may not check the cookie expired before using it)
- application controlled cookie (the load balancer follows application cookies and will create one current session only if the application will return one. Then will use it to associate a client with a server)
Connection draining means the servers must terminate all incoming transactions before becoming unavailable for load balancer.
An image used enters website and during the request the server is removed by a deployment. To solve this problem, the load balancer must wait for each server to terminate incoming transactions in order to remove them. If those servers are not receiving any more traffic, it means they are ready for deploy.
Load Balancer Availability means the availability of the load balancer to be up without downtime.
A single load balancer means a single point of failure. If load balancer is down, all servers are useless, the user can not use them directly to get a HTTPS response in a load balanced infrastructure.
If we make a second layer of load balancers (top layers) which will balance between the bottom layer of load balancers we just entered in a loop where the single point of failure just more one layer above. Thea to balancer traffic between more load balancer layers can be used to solve high load, redundancy but not single point of failure.
The single point of failure is solved using a dedicated software and a series of inactive load balancers. The software can switch active/inactive mode between load balancers in case any of them has errors or becomes inactive. Of course, if all load balancers have errors there is nothing we can do, but with some redundancy on load balancers level and a dedicated software which knows how to activate/deactivate them, the downtime risk decreases drastically.
Such a solution of load balancer with high availability can by HAProxy.
Common deploy strategy patterns
- “Rolling with additional batches” deployment method
- “Rolling” Deployment method
- “All At Once” Deployment Method
- “Immutable” Deployment strategy
- “Blue / Green” Deployment strategy