Mssm
Mssm

Reputation: 787

Deploy multiple instances of spring application

I need to deploy multiple instances of the same spring application.

I'm actually using docker as a container for my instances, and have got 1 container for each instance.

However noticed that one container consume up to 500mb, which is much for me, as i need my VPS to catch up as many instances as possible, and honestly, the containers are used just for the JVM and nothing else, would be a great waste of memory to dedicate a whole virtual environnement for a simple JVM instance and i don't really need that at all.

What i need is more like a tool to help me to administrate the instances (auto start if the processes are killed for some reasons, update easily the instances if a new version of the app has been developped, managing the instances through line commands for debugging or whatever.) just as i can do with Docker but without a whole virtualisation environnement which is too " greedy "

By the way, i've got a VPS from OVH Cloud Services, who doesn't provide any kind of spring like deployment services. I'm working on a traditionnal Ubuntu 18.04.

Thanks in advance

Upvotes: 0

Views: 577

Answers (1)

Diego
Diego

Reputation: 793

You should approach this from the bottom to the top of the stack. I'll try to answer each topic but I'd advise you to divide this into several questions, so people can give more detailed answer to each problem.

I'll give you just an overview so you can have a starting point.

JVM Memory Limit

First, control the memory allocation by setting coherent limits to the JVM. You can do so by setting the Max Heap Size, and the Max Metaspace size (Java 8).

You can set the max heap size by appending the flag -Xmx. -Xmx1G will limit the heap size to 1 Gigabyte.

The metaspace can be set using -MaxMetaspaceSize. The metaspace was introduced in Java 8. If you are using Java 6 or 7, you should take a look at PermGen.

Container Limit

You can also set the max memory of your container using appending the -m flag to the docker run command. You can take a look at docker's doc here: https://docs.docker.com/config/containers/resource_constraints/

Container Management

This deserves its own detailed answer. First of all, Spring Framework it is not related to what you are trying to achieve. It won't solve automatic restarts or anything like that.

What you are looking for is a Container Management Tool. You can take a look at docker swarm, portainer, or kubernetes.

They'll allow you start multiple instances of the same service without changing anything at code level.

For a quick and dirty implementation, you can use docker swarm, which is a no-brainer and integrates seamlessly with docker containers.

Upvotes: 1

Related Questions