Reputation: 1627
We are a logistics startup and we are running 12 Spring Boot microservice projects in 2 AWS EC2 machines. 1 machine has 16GB RAM and other has 8GB RAM. We have the same setup for Prod and QA. For 2 environments, totally 48GB RAM machines are running which costs us very high every month.
On average, each service is consuming 2GB of memory.
We are running QA servers only during the day time to reduce the cost.
Is there any better way to reduce the RAM usage per service to reduce the overall expense?
Upvotes: 0
Views: 673
Reputation: 1627
We limited the amount of memory each Spring services takes when we start the service.
Here is what we used. This will also increase the heap only by 20% when the memory needs to grow and release the memory by 40% when it needs to shrink.
java -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:MaxRAM=400m -jar java-service.jar
Now Ideally, each spring service takes less than 400MB which was 2GB earlier.
Upvotes: 1