Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dockerized java microservices efficiently

While a java application server will extend a unique JVM to run several (micro)services, a dockerized java microservices architecture will run a JVM for each dockerized microservice. Considering 20+ java microservices and a limited number of host it seems that the amount of resources consumed by the JVMs on each host is huge.

Is there an efficient way to manage this problem ? Is it possible to tune each JVM to limit resources consumption ? The aim is to limit the overhead of using docker in a java microservices architecture.

like image 683
DouglasAdams Avatar asked Apr 09 '26 21:04

DouglasAdams


1 Answers

Each Docker and JVM copy running uses memory. Normally having multiple JVMs on a single node would use shared memory, but this isn't an option with docker.

What you can do is reduce the maximum heap size of each JVM. However, I would allow at least 1 GB per docker image as overhead plus your heap size for each JVM. While that sounds like a lot of memory it doesn't cost so much these days.

Say you give each JVM a 2 GB heap and add 1 GB for docker+JVM, you are looking needing a 64 GB server to run 20 JVMs/dockers.

like image 92
Peter Lawrey Avatar answered Apr 12 '26 09:04

Peter Lawrey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!