Home / Companies / Cloudflare / Blog / Post Details
Content Deep Dive

Graceful upgrades in Go

Blog post from Cloudflare

Post Details
Company
Date Published
Author
Lorenz Bauer
Word Count
1,677
Company Posts That Month
25
Language
English
Hacker News Points
8
Post removed?
No
Summary

Graceful upgrades allow for the seamless replacement of a process's configuration and code without disruption, a necessity in environments lacking load balancing layers, such as Cloudflare. This process involves complex systems programming, with solutions like using the Go library tableflip, which Cloudflare plans to open-source. Graceful upgrades ensure that neither the listening socket is removed nor connections are dropped during code updates. Traditional methods like the Exec() function or using the SO_REUSEPORT flag have limitations, such as the inability to reverse the Exec() call or the risk of orphaned connections with separate sockets. Instead, models like NGINX's, which utilize a process-per-core approach along with a primary process to manage socket sharing during upgrades, offer a robust solution. This method ensures that only one upgrade is active, the new process can safely crash during initialization, and no old code persists post-upgrade. Despite existing libraries like tablecloth, beego/grace, and facebookgo/grace, none fully met Cloudflare's requirements for flexibility beyond HTTP protocols, prompting the creation of their library, tableflip, which facilitates NGINX-style upgrades in Go applications.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.