I have two applications, can I run them on one port 8080? I am currently running them on different ports.
This would be the equivalent of putting a proxy in-front of 2 apps anyway. You could deploy 2 different apps on a Servlet Container like Tomcat, but arguably you could consider Tomcat an app, but it's just perspective. The only reason you would want to do that is to share resources to minimize application runtime footprints, which nobody cares about anymore anyway.
If you use Tomcat then the answer is yes. When deploy, just choose the same Tomcat instance for both apps and voila. However it is advised to use multiple Tomcat instances and separate ports for different applications.
Related
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?
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.
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.
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!
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
In the past when a new webapp or set of services was to be deployed, it was common practice to be given a new vm with tomcat installed on to deploy to. With my current position the client is only giving me one linux instance to deploy several webapps to. (Small internal usage, 0 scaling. Deploying to a single AWS EC2 linux machine)
The applications are required to be given unique domains. ie app1 and app2 could be mapped to smallapp1.com:8080/app1/login and smallerapp2.com:8080/app2/login (ports are for example only and not a requirement)
I currently have two installations of tomcat8 running on the instance and each application is deployed to a unique tomcat install and running on different ports. (one is 8080 and the other 8081).
If I were to want to deploy a handful of other small applications would I be better off using individual tomcat installations or should I be using Virtual Hosting?
I am new to deployment. In the past I was handed a deployment destination and procedure. In the new position I was simply given credentials to a single instance. I am not sure what is better practice or in which situation which is better than another. If it matters, each application is only ever going to be used by a maximum of 20 users at the same time.
TL;DR Using multiple installations of tomcat on the same instance or using the same tomcat installation to host multiple applications.
Virtualhosts is a better option because you are not bloating the server with several installations that could conflict with each other, and you are to take 1 port for each instance of tomcat.
Keep in mind that tomcat is a better solution for Java web applications, if you are not running servlets or JSPs you are better off using Apache Http server.
We have two different Java web apps named foo.war and bar.war and we want to deploy these on Jetty server
Jetty is running on 8080 port on the machine
Is it possible simultaneously run two apps on same port ? If no what are the alternatives to run multiple web apps on same jetty server
Thanks
You can run as many web applications as you want in a servlet container. They just need different context roots.
Let's say you have abc.war and def.war. If you deploy both, by default you can access them through http://localhost:8080/abc and http://localhost:8080/def.
Since this usually looks ugly, it's a good idea to put a reverse proxy in front of your Servlet container. This will allow you to have for example 2 different domains foobar.com and xipbaz.com that will then be routed to different applications, even if they're all on the same server.
I do understand that using the same tomcat instance for a number of web applications has some risks (e.g. if one web application crashes tomcat it will terminate the other web applications as well.). The benefit is of course cost effectiveness since one server is enough and having all the web applications in one place makes it very easy to administrate.
Are there any industry guidelines on how a good setup with multiple web applications on tomcat should look like?
Pros
One JVM to monitor
Common libraries can be shared (sometimes risky)
Cons
Common HTTP thread pool all applications are using (you can, however, configure several connectors with different thread pools)
One malfunctioning application can take down the whole server
Restarting one application requires restarting all of them (if not using hot-deployment)
You are right that hosting of multiple we applications on one application server / web container (either Tomcat or other) has benefits.
You mentioned the robustness issue when one application may cause failure of another. But let's simplify this: even if you have only one application you still want 24*7 availability. To achieve this goal people typically run more than one instance of application server with identical application on each one and load balancer in the enterence to the site. The same is relevant for several web applications. Just run N (2 as minimum) application servers with identical set of web applications deployed and load balancer. You will probably need a kind of watchdog that restarts server if it failed or if it stopped responding etc.
In some cases kind of clustering is required. But it is other story.
I am working at a startup, we are just about to roll out our first beta. Knowing that we will be having a good number of users, we want to have seamlessly deployment when we are adding new features.
I have worked with windows azure before, and I know they support seamless deployment, so I did some googling and cloudbees was the first result.
So the question is, with what we have now (geronimo server, rackspace hosting), is it possible to seamlessly redeploy a java web application? If so, how?
Are there other alternative solution, such as using another hosting provider or use a different web server? (Because it is a startup, it would be beneficial if the answer keeps scalability in mind)
If with a seamless redeploy, you mean an upgrade of your application without any downtime or restarting of your server, LiveRebel might be something to look at.
See http://zeroturnaround.com/liverebel
There are a lot of methods for doing this in the java world. If you don't use sessions (or use shared sessions between app servers) you can do a rolling stop/deploy/start of your appservers, taking 1 offline at a time and using a load balancer to ensure that traffic goes to the other servers.
I have heard Glassfish has such feature, the reference probably ment this (Glassfish 3.x redeploy command) : http://docs.oracle.com/cd/E19798-01/821-1758/6nmnj7q1h/index.html