Introducing Blue-Green Deployment to Reduce Deployment Time
Key point
To solve the instability and long deployment time of rolling updates, the team switched to blue-green deployment.
Details
The existing deployment used a HAProxy-based rolling update approach. In the process of removing half of the servers from the load balancer and reconnecting them, intermittent errors occurred, and there was also a risk that the entire set of servers could go down if the deployment failed. As the number of servers increased, the time taken to remove and reconnect them also grew longer, reducing deployment efficiency.
To solve this problem, the team introduced blue-green deployment. The environment currently in operation is divided into Blue, and the environment where the new version is deployed is Green; the new version is deployed first to whichever of the two fixed ports is not in use, and once verification is complete, only the traffic is switched over. The switch was implemented by changing the Nginx proxy port.
The implementation proceeded in the following flow.
- Check the running port to distinguish between the currently used port and the unused port
- Deploy and start the Spring Boot JAR on the unused port
- Perform a health check for up to 60 seconds using
/actuator/health - Change the proxy port in the Nginx configuration to the new port using
sed - Validate the syntax with
nginx -t, then runnginx -s reload - Stop the service on the existing port
The deployment script built the JAR with ./gradlew --build-cache :api:bootJar, then used scp and systemctl restart to start the new port before performing the switch. If a failure occurs, the stopped existing port can be restarted and the Nginx port reverted for an immediate rollback.
The results were clear. Deployment time was reduced from about 13 minutes 30 seconds before the change to 1 minute 54 seconds after the change, a reduction to roughly one-fifth of the original time. Additionally, when running a Jmeter test with 60 threads, period 1, and loop count 20, for a total of 1,200 calls, the error rate was confirmed to be 0%, and uninterrupted calls were maintained even in a single-server environment.
The key point is that stability and speed were improved simultaneously using only the existing Nginx configuration, without introducing complex new tools. Going forward, the plan is to gradually apply the blue-green strategy not only to new services but also to existing services.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.