Number of processes and relationship to mod_jk, Apache, tomcat
I am trying to understand the relationship between applications in Tomcat, the number of Tomcat processes, Apache mod_jk and the number of threads. For instance on a system I have the following Apache 1.3.28, Tomcat 4.1.27, Java 1.4.2_02 I use the follow commands to see what is listening to different ports to get an idea of what process or threads are running. Apache: lsof -i tcp:80 | wc -l This gives me 12 processes listening to port 80 (I checked these are related to the number of Apache instances) Tomcat direct port: lsof -i tcp:8080 | wc -l This gives me 50 process that also correspond to the number of tomcat instances running(i.e. the number of java instances I see in ps ) Tomcat mod_jk port: lsof -i tcp:8009 | wc -l gives me 550 I have included my condensed jk.properties and workers.properties files at the end if that may help. Now I now that these numbers will change depending on load but I am trying to understand the relationship. So my questions is how do the numbers relate to each other? How does this effect performance? How could I tune these numbers? Now I have a vague understanding of how these relate but the numbers don't add up for me. I have read the docs and searched for quite a while for a better description. Thanks FILE: jk.properties ### LoadModule jk_module libexec/mod_jk.so JkWorkersFile /usr/local/tomcat/conf/workers.properties JkLogFile /usr/local/tomcat/logs/mod_jk.log JkLogLevel info JkLogStampFormat [%a %b %d %H:%M:%S %Y] JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories JkRequestLogFormat %w %V %U %T %b ## /examples1 Alias /examples1 /usr/local/tomcat/webapps/examples1 Location /examples1/WEB-INF/ AllowOverride None deny from all /Location JkMount /examples1/* worker1 ## /ctrials Alias /ctrials /usr/local/tomcat/webapps/ctrials Location /ctrials/WEB-INF/ AllowOverride None deny from all /Location JkMount /ctrials/* worker1 ## /syndication Alias /syndication /usr/local/tomcat/webapps/syndication Location /syndication/WEB-INF/ AllowOverride None deny from all /Location JkMount /syndication/* worker1 ## /fellowship Alias /fellowship /usr/local/tomcat/webapps/fellowship Location /fellowship/WEB-INF/ AllowOverride None deny from all /Location JkMount /fellowship/* worker1 ## /test Alias /test /usr/local/tomcat/webapps/test Location /test/WEB-INF/ AllowOverride None deny from all /Location JkMount /test/* worker1 # All jsp go to worker1 JkMount /*.jsp worker1 # All servlets goes to worker1 JkMount /*/servlet/ worker1 ## FILE: workers.properties ## # Define some properties workers.apache_log=/usr/local/apache/logs/ workers.tomcat_home=/usr/local/tomcat workers.java_home=/usr/local/java/ ps=/ # Define workers worker.list=worker1 worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009 worker.worker1.lbfactor=1 #worker.worker1.cachesize=10 #worker.worker1.cache_timeout=300 worker.worker1.socket_keepalive=1 worker.worker1.socket_timeout=300 # how many ms to wait for PONG after sending a PING for connection worker.worker1.connect_timeout=2000 # how many ms to wait for PONG after sending a PING before posting data worker.worker1.prepost_timeout=2000 # how long to wait for a reply after sending data before server considers connection dead worker.worker1.reply_timeout=180 ## - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Number of processes and relationship to mod_jk, Apache, tomcat
Andrew, I am trying to understand the relationship between applications in Tomcat, the number of Tomcat processes, Apache mod_jk and the number of threads. Apache: lsof -i tcp:80 | wc -l This gives me 12 processes listening to port 80 (I checked these are related to the number of Apache instances) You should be able to predict this from the httpd.conf file. Do the numbers add up for Apache? Tomcat direct port: lsof -i tcp:8080 | wc -l This gives me 50 process that also correspond to the number of tomcat instances running(i.e. the number of java instances I see in ps ) What UNIX flavor are you running? I know that in old versions of Linux, each pthread was shown as a separate process. Thus, it looked like many processes (really threads) all held the same resource. For example, they all had the same resident memory footprint (because the memory is shared) and they all were bound to the same ports. In the later versions (mine being one of them, I've got kernel 2.4.20), they only show up as one process. Thus, I get this output: [EMAIL PROTECTED] ]# /usr/sbin/lsof -i tcp:8009 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME java9313 tomcat 15u IPv4 69785 TCP *:8009 (LISTEN) [EMAIL PROTECTED] ]# I'm guessing that you're getting multiple lines that all look like this. Is this accurate? Only one process can bind to a port at any given time, so multiple processes (even with separate pids) might appear to be bound to that port. Tomcat mod_jk port: lsof -i tcp:8009 | wc -l gives me 550 Again, see the discussion of the threads/processes above. Also note that you may have many more threads that you thought you would. I recall that each (non-nio) stream in Java requires a separate thread, so System.in, System.out, and System.err already give you three threads. Then, you've got the main thread, plus the thread pool to serve requests from remote clients. That may be large, although having that number higher than your Apache request processor limit is probably a waste. Now I know that these numbers will change depending on load but I am trying to understand the relationship. Well, some numbers should not change. For example, there should be a hard limit on the number of Apache threads/processes running. You can tune that in httpd.conf. For the Java process, it's harder to predict because of the way the VM retires threads and when your server is creating them. Ideally, new threads wouldn't be created at all because there would be a closed thread pool (unless you have a min and max thread pool size and the number of threads depends on load). So my questions is how do the numbers relate to each other? The number of Apache processes is usually completely unrelated to the java process counts (except that there will be more java threads than Apache processes :). How does this effect performance? Most of the processes are very lightweight. Apache is a lean, mean, web-serving machine so don't worry about that. What you should worry about is if your thread count continually goes up and never comes back down. You'd have a nasty resource leak, then. If you avoid creating your own threads in your web application (which you should be avoiding anyway), you're generally okay. -chris - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]