Deploying Multiple Spring Boot Web Applications in Single Server

血红的双手。 提交于 2021-02-08 09:42:15

问题


I have 5 Spring Boot web applications but have only one Server (low-end).

What is the best way to deploy all 5 in one Server? Having only one web container (Tomcat) and deploy all of them as separate war files on the same Tomcat or run all 5 on different Tomcat containers (Spring Boot default behavior)?

What is your recommendation by considering performance and maintenanability?


回答1:


IMHO, if you're running a resource-constrained server, your best bet is to deploy all of your applications as war files under a single tomcat instance. Running multiple servers would just add un-needed overhead.




回答2:


If you have little resources on your server, you don't have much choice. Each Java virtual machine has a significant overhead, so running separate containers will make you reach the limits of your low-end server earlier.

You will have to deploy your wars in the same tomcat server, with different servlet contexts.

However, if you have sufficient RAM, the cleanest way in my opinion is creating docker images and running the standalone spring-boot jars in each container.




回答3:


My recommendations are:

  • If these WARs are independent of each other, deploy them in a different Web server, not only Tomcat or whatever container you're using, but also in either different virtual server, dedicated server or Cloud instances.
  • Deploying in different "virtual server" you can scale horizontally, so this is good for future workloads.
  • Deploy a load balancer from your hosting provider, or you can use Nginx for doing that.

Hope this helps!




回答4:


From my experience, using container such as docker is the easiest way to maintenance multiple spring-boot applications. When you have a new server, it can be migrated easily, and the application can be updated without interrupting other applications. But you may need to spend extra time to learn how to use the container.

If using Tomcat, it is recommended to separate the tomcat instances. One tomcat for each WAR file. Putting multiple WAR files in one tomcat can make the maintenance difficult. Tomcat hot deployment / auto deploy tends to have some errors which require you to restart the whole tomcat



来源:https://stackoverflow.com/questions/47625558/deploying-multiple-spring-boot-web-applications-in-single-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!