Orchestrating startup and shutdown in Scala
May 10, 2020 | Technical Blog
A set of abstractions to manage the lifecycle of any Scala process, from small console apps to large-scale distributed Akka cluster applications
Starting and stopping an application properly is an often underlooked challenge. Tackling domain complexity is the obvious priority, and we often postpone such mundane concerns for later. Yet, in today’s highly available distributed systems, robust and failsafe application initialization and termination are essential to maintain service quality and data integrity during updates.
Here are some aspects to getting a service off and on the ground:
– initialize and terminate internal components in a specific order
– flush buffers to persistent storage to avoid loss of data
– close database connections and more generally release resources to avoid timeouts and starvation
– stop acceptation of new requests while finalizing in-flight responses
– coordinate cluster membership and node hand-off
This article describes a set of simple abstractions that we use to start and shut down our services. This accelerates our development, ensures reliable continuous delivery operations, and makes our codebase more uniform.