Glenn Lum Software Engineering

2.5 Continuous Delivery and Deployment (CD)

Continuous Delivery is the practice of keeping your software in a state where it can be deployed to production at any time. Continuous Deployment is the practice of automatically deploying every change that passes CI to production without human intervention. The distinction matters: Continuous Delivery requires a human decision to deploy; Continuous Deployment automates even that decision. Many organizations practice Continuous Delivery (the pipeline goes all the way to a pre-production environment automatically, and production deployment is triggered manually) because some deployment targets require a deliberate human act for regulatory or risk management reasons.

The most important conceptual refinement in this segment is the decoupling of deployment from release. These two acts are often conflated, but separating them is the key to making deployment genuinely low-risk. A deployment is the technical act of placing new code onto infrastructure. A release is the business act of making new functionality visible to users. By deploying code behind a feature flag (a configuration toggle that controls whether the code path is active), you can put new code in production while it is invisible to users. The code runs, you can observe its performance and error rates, you can run it alongside the old code path in a shadow mode, and you can release it to a small percentage of users (say, 1%) before releasing it to everyone. If problems emerge, you toggle the flag off in seconds without any deployment at all. This model changes the risk calculus of deployment fundamentally: you are no longer choosing between “deploy and risk user impact” and “don’t deploy and accumulate risk in a large batch.” You are continuously deploying small, dark changes and releasing them deliberately when you have sufficient confidence.

Deployment strategies describe the mechanics of how a new version of an artifact replaces an old version without causing downtime. In a rolling update, instances are updated one by one (or in small batches): some instances run the old version and some run the new version simultaneously during the rollout. This is simple and resource-efficient but means that for a period, different users may receive responses from different versions, which can cause inconsistency if the API has changed. In a blue/green deployment, you maintain two complete production environments (“blue” running the current version, “green” running the new version). Traffic is shifted from blue to green at the load balancer level, either all at once or gradually. Rollback is instantaneous: you redirect traffic back to blue. The cost is that you need double the infrastructure capacity during deployments. In a canary release, you route a small percentage of production traffic (say, 1% or 5%) to the new version and monitor its behavior. If metrics are healthy, you gradually increase the percentage. If they are not, you route the canary traffic back to the old version. This gives you the highest confidence in real-world performance but requires sophisticated traffic routing and automated metric comparison.

Rollback strategies are a critical operational consideration that is often neglected until an emergency. Rolling back a deployment, reverting to the previous artifact version, is not always possible. If the deployment included a database migration that added a column or changed a constraint, the previous version of the code may not be compatible with the new database schema. This is why the expand and contract pattern for schema changes is an operational discipline, not just a database concern. The pattern works in two phases: in the “expand” phase, you make the schema change backward-compatible (adding a new column without removing the old one), deploy the new code that can work with either schema, and verify stability. In the “contract” phase, you remove the old column once you are confident the new code is stable. This ensures that at every point in time, you can roll back the deployment without leaving the database in an incompatible state.

← Back to Home