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

https://github.com/diegopacheco/java-pocs/tree/master/pocs/spring-restart-app

Cheers,

Diego Pacheco

Popular posts from this blog

Podman in Linux

Java Agents

Manage Work not People