An in-depth introduction to Rolling Deployments

944 views Backend System Design

Rolling Deployment is a deployment strategy that slowly replaces the previous version of the application with the new one by replacing the underlying infrastructure.

Say we have 9 servers and each one is running version 1 of the code. With rolling deployment, we roll out our changes i.e. version 2 of the code to one server at a time eventually covering all 9 servers. This is the core idea of the rolling deployment, however, the implementation could vary a bit.

A key thing to note here is the fact that deployment is incremental in nature which means during the deployment there would be a few servers that are serving the old version of the code and the remaining servers serving the newer version. Hence the changes we push should be both backward and forward compatible.

Implementing Rolling Deployment

Rolling deployments are always gradual and graceful, and we typically happen through the below steps

  1. Pick a server for deployment
  2. Stop the incoming traffic by removing it from the load balancer
  3. Wait for the existing requests to be completed
  4. if we are not replacing the infra, pull the latest code and reload
  5. if we are replacing the infra, delete the server and launch a new one with the new code
  6. attach the server behind the load balancer and start serving the requests

Tuning Rolling Deployment

Concurrent Servers

Instead of deploying to one server at a time, we can deploy changes to n servers concurrently. This would complete the entire deployment quicker.

Choosing the appropriate n is critical as a small value would mean the deployment takes ages to complete and a large one would affect the availability during deployment.

Double-Half Deployment

An interesting way to implement rolling deployment is to double the infrastructure and then delete the older half.

Say, we have 4 servers with version 1 of our code so in order to deploy the changes we add 4 new servers with the new version of the code to the infra taking our total count to 8, and then delete the 4 older servers. This way, what remains are the 4 servers with the newer version of the code.

Pros of Rolling Deployments

  • Cost efficient
  • Rollouts are gradual
  • Rollbacks are simple
  • Deployment incurs zero downtime
  • Much faster than Blue-Green Deployment
  • Any hiccup during deployment affects only a fraction of the users

Cons of Rolling Deployments

  • No environment isolation
  • Naive deployment takes a long time to complete
  • Stateful applications are affected during deployment
  • Changes we rollout should be backward and forward compatible

Arpit Bhayani

Arpit's Newsletter

CS newsletter for the curious engineers

❤️ by 17000+ readers

If you like what you read subscribe you can always subscribe to my newsletter and get the post delivered straight to your inbox. I write essays on various engineering topics and share it through my weekly newsletter.

Other essays that you might like

An in-depth introduction to Rolling Deployments

944 views 46 likes 2022-05-27

One of the simplest deployment strategies that make deployment a breeze is Rolling Deployment. It is the most widely ado...

Implementing Vertical Sharding

1124 views 75 likes 2022-05-25

Sharding is super-important when you want to handle the traffic that cannot be handled through one server. Sharding come...

An in-depth introduction to Blue Green Deployments

1309 views 60 likes 2022-05-18

Deployments are a pain if we are unsure about our release changes. But sometimes even if we know our changes well, somet...

An in-depth introduction to Canary Deployments

1982 views 117 likes 2022-05-16

Deployments are stressful; what if something goes wrong? What if you forgot to handle an edge case that was also missed ...

Be a better engineer

A set of courses designed to make you a better engineer and excel at your career; no-fluff, pure engineering.

System Design Masterclass

A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.

Enrolled by 700+ learners

Details →

Designing Microservices

A free course to help you understand Microservices and their high-level patterns in depth.

Enrolled by 17+ learners

Details →

GitHub Outage Dissections

A free course to help you learn core engineering from outages that happened at GitHub.

Enrolled by 67+ learners

Details →

Hash Table Internals

A free course to help you learn core engineering from outages that happened at GitHub.

Enrolled by 25+ learners

Details →

BitTorrent Internals

A free course to help you understand the algorithms and strategies that power P2P networks and BitTorrent.

Enrolled by 42+ learners

Details →

Topics I talk about

Being a passionate engineer, I love to talk about a wide range of topics, but these are my personal favourites.

Arpit's Newsletter read by 17000+ engineers

🔥 Thrice a week, in your inbox, an essay about system design, distributed systems, microservices, programming languages internals, or a deep dive on some super-clever algorithm, or just a few tips on building highly scalable distributed systems.

  • v12.4.4
  • © Arpit Bhayani, 2022

Powered by this tech stack.