In this blog I will explain how you can migrate Java applications from a monolithic application that is deployed directly onto instances with no containerization or orchestration, to a containerized and orchestrated microservices architecture.
Moving an existing Java application to a container deployed using ECS
- Containers allows engineering organizations to create a standard pipeline for the application lifecycle. This typically looks like:
- Developers build and run the container locally.
- Continuous integration server runs the same container and executes integration tests against it to make sure it passes expectations.
- The same container is shipped to a staging environment where its runtime behavior can be checked using load tests or manual QA.
- The same container is finally shipped to production.
Being able to ship the exact the same container through all four stages of the process makes delivering a high quality, reliable application considerably easier.
Why EC2 Container Service?
The EC2 Container Service provides orchestration for your containers. It automates the process of launching containers across your fleet of instances according to rules you specify. It then automates keeping track of where those containers are running, so that you can use a load balancer to get traffic to them. It also has built in features to roll out deploys with zero downtime, gather metrics and logs from your containers, and auto scale the number of containers you are running based on metrics.
The below image, published by Amazon Web Services, provides a concise overview of the setup for Amazon ECS.
From monolithic to microservice
This graphic provides an overview of the container deployment on EC2.
In the case of separate modules, I recommend simply:
- Break the modules into microservices by functionality in each case; such as a mail service or printing service.
- You can use your favourite language technologies to build your microservice. Here I strongly recommend Java or Spring Boot.
Conclusion – moving to microservices has significant benefits
Moving from having monolithic apps to microservices have significant benefits, both for developers and the business. As I mentioned earlier, being able to ship the exact same container every time, means you can much more easily and reliably deliver a high quality application.