Embedded vs Stand alone Tomcat ( HTTP ) server

15.7k views Asked by At

I am working on a new project which would be a web application with a front end UI and a back end web service. I started looking into what servers to use like Tomcat / Jetty and so .. I also noticed that there is an embedded version of these HTTP servers. I don't understand when to use an embedded version against a standalone version. I tried googling but could not find a convincing answer, So would appreciate if some one to explain me the use-case for an embedded server. Thanks in advance.

2

There are 2 answers

2
Rizstien On

I have used embedded-jetty for a web app. The reason I used is was that I didn't want to set up a separate web server for just one App,. So I made a simple java program with embedding jetty in it and configure all server properties through java code. Now I can run this program on any machine without web server installed and it will act as a web app running in a server. I can associate any port and program many-to-many context/servlet mapping in it.

1
kdabir On

Embedded servers are useful when you treat your application as an OS process and it will be started with something like java -jar youapp.jar. In this scenario, setting up the box upfront with a given app server, say, Tomcat, is not necessary. Such applications can be run by the end user without needing extra installation and configuration of an app server.

Applications like Jenkins for example hugely benefit from such packaging. Another scenario is when deploying on cloud services like Heroku. You wrapping the app server within your jar eliminates the need to get the server installed on such cloud boxes.

Here essentially a single web app runs on a given embedded server. However if you wish to install two web apps on lets say two contexts ${root}/app1 ${root}/app2 then embedded app server is not a good option for you.