This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Tomcat service on different ports Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat service on different ports" Watch "Tomcat service on different ports" New topic

Tomcat service on different ports

Thomas Greene
Ranch Hand

Joined: Aug 09, 2004
Posts: 125
We have Tomcat servers running on 2 different machines. There is a hardware load balancer which decides request should go to which tomcat server. Lets call these tomcat server AppSrv1 and AppSrv2.

At times we need to do some content uploading stuff (using a web app) on one of these production servers (both use the same database). But while we are doing this content uploading stuff the load on these servers increase a lot (since onine users are alos using it) and we start getting OutOfmemory errors.

Tomcat on both these machines is running as a service.

TO solve this problem what we have been suggested now is that in AppSrv2, we should run the same tomcat server on another port (say 8086) as well. Is it possible to run the same tomcat service on 2 ports?
The idea is that when the content team tries to load the content they'll bypass the loadbalancer and directly send a request to port 8086. So the 2 default ports (8080 on both machines will be free to take care of client requests).

What I want to know is that, even when we have tomcat services running on 2 ports (in same machine), since they'll be using the same JVM will the above help. I feel only one heap is created for both the instances of tomcat on AppSrv2 but I told that since it'll be a seperate process two heaps will be created. The content team will use one port which will have one heap, while the online users will use another (8080) port which will use a seperate heap. Please give your comments on the above.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

No, they will not use the same heap.
You will have two, completely different instances of Java running.

There are two port settings that must be changed.
The first is the connector port which defaults to port 8080.
The second is the shutdown port which defaults to 8005.

These can be changed in tomcat/conf/server.xml

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Thomas Greene
Ranch Hand

Joined: Aug 09, 2004
Posts: 125
If I do this, and suppose there is OutOfMemoryException in one app (say the content app) which is running on port 8086, but the one on 8080 is working fine. Now to make the app on 8086 I'll need to restart the tomcat server, will that mean that tomcat on 8080 will also be restarted (since there is only one instance). Is there a way to restart just the instance running on one port?
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Thomas Greene:
(since there is only one instance)

There is not only one instance.
There would be two instances.

As I said earlier, you will have two completely separate Java programs running on your machine. You can stop, start, restart either one without affecting the other.
Don't get me started about those stupid light bulbs.
subject: Tomcat service on different ports
Similar Threads
Query regarding hosts file.
Servers In Netbeans or Eclipse
Query about 'Port' Number??
JDBC Driver not found.
remote debug from myeclipse