Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Zero Downtime Deployment

DZone 's Guide to

Zero Downtime Deployment

Make sure that your users aren't left hanging every time you need to upgrade by equipping your infrastructure for a Zero Downtime Deployment.

· DevOps Zone ·
Free Resource

Software availability is one of the important criteria considered for the success of any software. It is important to make sure your business is not impacted due to software deployment activity. Achieving the highest software availability is possible in many ways.

A new release of software should not bring down the system. To achieve a zero downtime deployment, the software should be built considering the factors that do not demand any downtime.

There are many factors that will impact software downtime. Here, I am going to discuss a few solutions to minimize the impact on software availability from software deployments.

Deployment Architecture

Deployment architecture plays a vital role to ensure there is no downtime for software deployments. During deployment, the software should be available to the user. To achieve this, the application deployment should have these components.

1. More Than One Application Server 

To make software available all the time, it is important to have more than one application server. This will allow us to bring down one node at a time, upgrade, and bring it up to serve the users. Each node can be brought down when a newly upgraded node is up and running.

2. Load Balancer

The load balancer is required to distribute the traffic equally among all the nodes. It is a minimum requirement for a deployment architecture with more than one application server node.

Stateless

All HTTP requests must be stateless to achieve a zero downtime deployment. There should not be a one-to-one relationship between a request and an application server. For example, consider that a user request is attached to a node and we need to bring down the server to upgrade. In such a case, the user's request would be impacted as it is tightly coupled with that application server.

The architecture should be constructed in such a way that the HTTP request should be able to be served from a different application server. Therefore, it is highly recommended to make sure your architecture is not stateful and does not have a sticky session.

In these cases, the session state is mandatorily a requirement. We should make sure the state is not stored in the application server; rather, it should be stored in a centralized server. There are many ways to store a session state in centralize servers like state server, REDIS, and SQL Server.

Backward Compatibility

In an environment with more than one application server nodes, a rolling deployment is the most common practice. That means, while upgrading servers, a few sets of nodes will be upgraded at once. After the upgrade, bring up the new upgraded ones and bring down the non-upgraded nodes.

If you have a database upgrade, then it is important to upgrade the database first before upgrading application server nodes. All these steps are incremental steps to achieve a zero downtime deployment instead of bringing all of them down together.

When first upgrading the database server, we need to make sure the newly upgraded database has the old stored procedure code. It will ensure that the old version of application nodes can work with the newly upgraded database.

It is important to roll out the guidelines for all SQL developers that the old stored procedures should exist in the DB for the backward compatibility. We follow the process to make sure to version the stored procedure for the new changes. It will ensure there is backward compatibility during the software upgrade.

Incremental Deployment

We should always explore ways that will bring down the total deployment time to designate a few steps as pre-deployment steps. If a new version needs a data upgrade or fix and it is not dependent on the new code, then it can be part of the pre-deployment steps. The pre-deployment steps will be executed incrementally before the actual deployment. If the data upgrade process takes a lot of time, then it is not advisable to do it on the same day of deployment.

A/B Deployments

In software equipped with multiple hardware infrastructures, a few sets of nodes will be serving end users and they are called active nodes. There will be a few more nodes not used by the users and they are called inactive nodes. During the upgrade process, the inactive nodes will be upgraded with the new version and tested thoroughly. Once they passed testing, through routing these new nodes will be made active and older version nodes will be brought down. The A/B deployment, or Blue/Green Deployment, is also used for critical uptime software requirements.

Some critical cases may demand downtime. However, in most cases, these steps will ensure downtime is kept to a minimum for software deployment.


Topics:
software deployment ,software architecture ,session ,stateless session ,blue green deployment ,devops ,zero downtime deployments

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}