In development I have a Java backend API which I'm running with Tomcat. I'm wanting to wrap the backend in a docker container and deploy to an AWS EC2 instance, and be able to scale up/down.
Does every docker container need to have a separate Tomcat server running? I don't know any way around it, but I guess it just seems like a lot of overhead (1GB-2GB memory, 500MB disc space) per container.
3 Answers 3
In the Microservices architecture, usually, you want the flexibility to deploy the services independently and this requirement leads you to have one container per service with all the dependency and environment necessary to run it.
The default Java ecosystem is heavy to create cloud-native applications, but this is changing with projects like Quarkus and GraaVM where you can build cloud-native applications with high performance and low memory consumption.
Consider using embedded Tomcat inside your application instead of deploying your app in a Tomcat instance. I prefer this approach in general but it's definitely much more aligned with micro-service architectures and containers.
You don't need docker in this instance.
Tomcat is already a container running system which can run multiple seperate websites and apis
-
1Can you scale each site in a Tomcat instance independently?Dan Wilson– Dan Wilson2019年11月06日 13:07:24 +00:00Commented Nov 6, 2019 at 13:07
-
1no but you cant do that with docker on a single ec2 eitherEwan– Ewan2019年11月06日 13:31:03 +00:00Commented Nov 6, 2019 at 13:31
-
3Yes, this. Both Tomcat and Docker (intend to) solve the same problem: Provide a consistent environment for an application/service. They just do so at different levels (basically, Tomcat provides the Servlet API, while Docker provides the Linux API).sleske– sleske2019年11月06日 14:06:48 +00:00Commented Nov 6, 2019 at 14:06
-
Of, course you might want to use Docker for the advantages it provides...sleske– sleske2019年11月06日 14:10:52 +00:00Commented Nov 6, 2019 at 14:10
-
1This article: the decline of Java application servers when using docker containers explains the advantages Docker offers over just using an application server (like Tomcat). This may not apply in all situations, but there are things that Docker can do while Tomcat alone cannot.sleske– sleske2019年11月08日 10:57:46 +00:00Commented Nov 8, 2019 at 10:57
Explore related questions
See similar questions with these tags.
Does every docker container need to have a separate Tomcat server running?
yes.it just seems like a lot of overhead (1GB-2GB memory, 500MB disc space) per container
then review how is your docker image built. Or do review why your app needs so many resources. I run similar images with much fewer resources.