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

Graceful startup and shutdown for Phoenix applications

Blog post from Felt

Post Details
Company
Date Published
Author
Jason Axelson, Engineer
Word Count
925
Language
English
Hacker News Points
-
Summary

Graceful Shutdown is a crucial process in managing Phoenix applications, particularly for ensuring a seamless transition when old servers are replaced with new ones. This practice involves stopping new work acceptance, completing in-progress tasks, and safely bringing the application down without causing disruptions to users, essential for companies like Felt that deploy new code multiple times a day. Phoenix handles most shutdown processes through its default configuration, notably using Plug.Cowboy.Drainer to manage HTTP connections and automatic client reconnections to new servers. Effective system design for Graceful Shutdown includes structuring your application to avoid cyclic dependencies and ensuring readiness checks via endpoints. Properly handling shutdowns can prevent errors and maintain accurate presence information, especially in clustered environments, by using techniques like calling Phoenix.Tracker.graceful_permdown. Testing and implementing these strategies ensure that users experience minimal disruption during deployments, maintaining application reliability and performance.