2

I have to front various application servers (in the beginning this will be JBoss 6, Tomcat 8 standalone and Tomcat 8 embedded into spring boot 1.2 apps) with an Apache 2.4. Because of this I decided to go for mod_proxy (and not jk, ajp or something like this). From what I know I set up Apache and the application servers to reuse / pool connection. But when I count the number of open ports I see several thousands:

$ netstat | grep :80 | wc -l
4630

(I am on Windows, the command above was run in Cygwin, so don't be confused. Apache etc run native, that means without cygwin emulation layer) I would have expected perhaps a thousand ports, but not more.

This is my Apache reverse proxy config:

<VirtualHost *:80>
    ServerAdmin ...
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass / http://localhost:8080/ connectiontimeout=5 timeout=30
    ProxyPassReverse / http://localhost:8080/ 
    ServerName ...
    ErrorLog "logs/foo.log"
    CustomLog "logs/foo-access.log" common
</VirtualHost>

MPM is active and I can use up to 150 incoming connections, at least this is what I judge from looking at server-status ...

...
1 requests currently being processed, 149 idle workers
...

.. and the Apache config:

<IfModule mpm_winnt_module>
    ThreadsPerChild        150
    MaxConnectionsPerChild   0
</IfModule>

This configuration causes the Spring Boot embedded Tomcat to access up to 500 connections:

server.tomcat.access-log-pattern=%h %l %u %t %I "%r" %s %b %D
server.tomcat.access-log-enabled=true
server.tomcat.max-threads=500
server.tomcat.basedir=./tomcat

So why are there so many ports ? I ran a load test with JMeter from another PC and when I calculate manually I would expect these figures: jmeter->Apache: 150 connections on port 80 Apache->Tomcat: 150 connections on port 8080 (can not exceed 500) Tomcat<-Apache: 150 connections on port 8080 (can not exceed 500)

Is there an error in my setup which causes ports not to be re-used ?

1
  • I would think the simplest explanation would be you grep. ":80" will not just match port 80, but any port whose first two digits is '80'. Just run "netstat | grep :80" and have a look at the output to see if other ports are increasing the count.
    – Unbeliever
    Sep 27 '16 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.