How Twitter Deploys Its High‑Traffic widgets.js with Zero‑Downtime Rollbacks
Twitter’s widgets.js, serving 300,000 requests per second, uses a carefully engineered deployment pipeline that emphasizes instant rollbacks, progressive rollouts, and real‑time visibility through DNS routing, CDN distribution, and origin management to minimize risk and ensure reliability.
Deployment Process Requirements
1. Rollback Capability
Twitter follows the principle “rollback first, fix second,” requiring fast and simple rollbacks.
2. Progressive Release
All code may contain bugs, so releases are staged to detect issues early and enable quick rollback.
3. Visibility
Real‑time monitoring of deployment status is needed, showing browser type, region, and the current proportion of old versus new versions.
Deployment Process
The deployment uses DNS to control which version a request receives based on configured rules.
There are three components:
1. DNS Management Service
When a request reaches platform.twitter.com, DNS resolves it to an IP based on the requester’s geographic region (IP1 for the old version, IP2 for the new version).
For a pilot region A, the rollout proceeds in stages:
Stage 1: 5% of traffic from region A resolves to IP2; the rest to IP1.
Stage 2: All traffic from region A resolves to IP2; other regions continue to IP1.
Stage 3: All traffic resolves to IP2.
2. CDN
Requests to IP1 fetch widgets.js from Origin 1, while requests to IP2 fetch it from Origin 2.
3. Origin
The Origin stores the actual widgets.js files. The CDN pulls the latest file from the Origin.
Origin 1 holds the old version, Origin 2 holds the new version. Traffic is gradually shifted to Origin 2; after a successful rollout, the new file is copied back to Origin 1 and all traffic is switched to Origin 1.
If a problem is detected, traffic can be instantly redirected back to Origin 1 for a rapid rollback.
widgets.js logs execution details on the client side, allowing the server to build real‑time dashboards.
The white line shows the increasing proportion of the new version, while the gray line shows the decreasing old version, illustrating a smooth, controlled rollout.
This deployment workflow has been running for a year, proving highly efficient; any bugs in the new version can be confined to a minimal audience, and the impact range is clearly visible.
Conclusion
The approach is worth studying; an efficient and reliable deployment process directly accelerates product development, builds confidence in upgrades, and encourages innovative experimentation.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
