Reducing Artemis’ deployment downtime with blue-green deployments
Summary
Artemis, a web reader application, implemented blue-green deployments to significantly reduce downtime during software updates. Previously, restarting the systemd process for updates caused 5-10 seconds of unavailability, displaying a maintenance message. The new approach involves running two Artemis processes: a primary ("blue") and a fallback ("green"). During an update, the new code is deployed, the blue process restarts, and the green process temporarily handles requests. Once the blue process is back online, requests revert to it, and the green process is then updated. This setup uses Nginx to route traffic between `localhost:9000` (blue) and `localhost:9001` (green), with the green fallback designed as read-only to simplify its implementation and testing, disabling account pages and forms.
Key takeaway
For DevOps Engineers managing web applications with systemd, adopting a blue-green deployment strategy can drastically cut user-facing downtime during updates. You should configure your web server, like Nginx, to route traffic between primary and fallback instances, potentially making the fallback read-only to streamline its implementation and reduce testing complexity. This approach improves user experience by avoiding full service interruptions.
Key insights
Blue-green deployment minimizes application downtime by using a fallback instance during updates.
Principles
- Isolate primary and fallback deployments.
- Route traffic dynamically between versions.
Method
Deploy new code, restart primary process while fallback handles requests, revert traffic to primary, then update fallback process. Nginx routes traffic to `localhost:9000` (blue) and `localhost:9001` (green).
In practice
- Use Nginx `upstream` for traffic routing.
- Implement fallback as read-only for simplicity.
- Use environment variables to control deployment mode.
Topics
- Blue-Green Deployment
- Nginx Configuration
- Web Application Deployment
- Downtime Reduction
- Flask Framework
Best for: Software Engineer, DevOps Engineer, MLOps Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by James' Coffee Blog.