Restarting Spring Boot Applications

Spring Boot is the standard framework for developing java services nowadays. It’s more than normal to have multiple deploys into productions during the day if you are not trapped by a release calendar or release train which should be a temporary thing and end up being a permanent thing. Ideally, you will have 3 at least 3 instances of your service, one for each availability zone in AWS. In order to introduce changes, DevOps often apply a pattern called Rolled Updates where often you patch one service and restart the application and then you do that one server at a time. In order to do that you server should be able to handle a clean shutdown and manage restarts smoothly which requires some config or code in your service side and also some consideration in sense of release resources, deny connections and prepare the land for a proper restart to happen. You might be in the middle of an important transaction so maybe you want to finish that first. For services is common to use the Saga Pattern for transactional coordination between services instead of distributed transactions(2PC). So the Saga Service coordination(IF you doing orchestration instead of choreographic one) you might really want to wait and maybe Denny new requests so they can be failed over to the different server. So today I made a simple POC and Video which I want to share explaining how we can accommodate this code and create a reboot endpoint in Spring Boot. Let’s get started.

The Video

The Code

Cheers,

Diego Pacheco

Originally published at http://diego-pacheco.blogspot.com on April 29, 2021.

Brazilian, Software Architect, SWE(Java, Scala, Rust, Go) SOA & DevOps expert, Author. Working with EKS/K8S. diegopacheco.github.io (Opinions on my own)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store