1832678 Members
2954 Online
110043 Solutions
New Discussion

ports and processes

 
SOLVED
Go to solution
Anil_5
Advisor

ports and processes

Hi,

Can two webservers(apache) which start up as 2 different processes share a single port for example port 80. If so how can they do it as no 2 process can share a port.
Has someone done this?

Anil
webapp
7 REPLIES 7
A. Clay Stephenson
Acclaimed Contributor

Re: ports and processes

Not on the same port but what you can do is increase the number of MaxSpareServers and MinSpareServers so that the main process can hand off the requests as quickly as possible. You probably need to increase MaxClients as well.

If it ain't broke, I can fix that.
Anil_5
Advisor

Re: ports and processes

Thanks,I am still not clear.
The scene is like this- I have an Apache server under a specified directory starting up on port 80, I have another apache server in a different directory on a different Virtual IP trying to start on port 80.It doesn't startup and I don't think it would as the OS can only allocate one port to one daemon,even if the Virtual IP's are different, am I right? But I would like to be sure.

Anil
webapp
John Dvorchak
Honored Contributor
Solution

Re: ports and processes

You are correct in that you can't start up two instances of Apache, or any other on the same port. I would suggest that you investigate running virtual web servers. Apache is well known for doing just that, and pretty easy to setup. So you would have a LAN id and a virtual LAN id and also virtual web servers each serving the separate LAN id's under one instance of Apache all on port 80 but different IP addresses. I hope that made sense to you. I haven't configured it like that in a couple of years, but I do remember that it was not very complicated to do.
If it has wheels or a skirt, you can't afford it.
Anil_5
Advisor

Re: ports and processes

Thank you, It makes sense to me, yes virtual hosting can be used and is easy to setup.

purpose of this message, was to clarify my doubt at the OS level.
Anil
webapp
rick jones
Honored Contributor

Re: ports and processes

If the two processes, in addition to binding to the common port 80 also bind to unique IP addresses, then it should (iirc) work. Uniqueness of a listen socket is determined by the tuple of IP address and port number.
there is no rest for the wicked yet the virtuous have no pillows
Anil_5
Advisor

Re: ports and processes

Yes, you are right I verified it by binding apache to an IP and port on one webserver, I started the other webserver on a different IP and same port, that process also started up properly.

Thanks
Anil Jacob
webapp
A. Clay Stephenson
Acclaimed Contributor

Re: ports and processes

Since you can use two (or actually more) hostnames for your webserver, you can actually use a clever DNS technique to round-robin the Apache servers and share load between them either on the same box or another box. If you make multiple entries for the same host but specify different ip addresses then the named server will return alternating IP addresses for the same hostname unless the default round-robin behavior has been intentionally overridden.
If it ain't broke, I can fix that.