In recent years, microservices have been sought after for their flexibility and scalability, and many companies have started to adopt microservices architectures or transform existing monolithic systems into microservices. IBM also recently open source for lightweight Java microservices Application Server open Liberty. But is it really the best choice to use Java to develop microservices? Elliot Forbes, a senior engineer from JPMorgan, based on his own experience, analyzed from a cost perspective and contrasted with the microservices in other languages and answered the question nicely.
The team where Elliot originally developed a single system using Java. Their production environment has a total of 12 servers, with 20 to 30 instances deployed on each server, and 8G of memory per instance. In this way, a total of 1.5T to 2.5T of memory is consumed. Later, they split the monomer into 5 microservices and used the container to deploy the micro-service. Each container runs a microservices because it is based on the JVM, so it requires at least 1G of memory. The original single instance uses 8G of memory, and after splitting into a micro-service, it only needs 5G to 6G of memory, saving at least 2G of memory.
But it's not going to be that simple. One of them is responsible for providing rest APIs externally and is the most critical part of the entire system. To increase availability, they deployed 4 instances in Europe, North America, and Asia respectively. In this way, the microservices used a total of 12G of memory, so the overall memory usage has increased a lot. Java Communication Group 669823128
What happens if you use the Go language instead of Java development microservices? The memory of each micro-service can be reduced from 1G to 64M, so the total number of microservices that were deployed with 12 instances would require only 768M of memory, which is less than the memory used by a single Java MicroServices instance.
Assuming that microservices are deployed on the Google Cloud platform, the 1G memory is charged at 1 cents to 2 cents per hour, at GCP's charge, and about $87 to $175 a year, then 12G of memory costs at least $1000 a year. 5 micro-Services add up to a minimum of $5000 a year. If you use the Go language, this number is about $500, which can be said to be reduced by an order of magnitude.
But Elliot also explains that cost is only one of many factors that need to be considered when using microservices. In addition to the cost, you also need to consider the development of language applicability and other aspects of the problem. But for large companies, they have a lot of microservices, and the cost is still an important consideration, after all, it could save them $ millions of a year.
Java Communication Group 669823128
View Java microservices from a cost perspective