I just started big journey towards SCWCD. Each and every resources coming on my way always says about thread in servlets like: 1)container creates a thread for each request 2)there is only single instance of servlet available and all that. But one big thing hammering my mind is: "what about the process management in container/server?"
Lets say, we are using Tomcat as a server which is running in Linux machine. httpd process get started when we start Tomcat which mean our container is ready to take clients request and able to send it to appropriate servlet. So when so many requests are coming from the clients; container creates that many threads and servlet handles each thread accordingly, that mean only one process (per container/server) should run in machine. Many times I've seen so many server processes running in my linux box (I do not have any particular scenario but out of my 3 boxes I found this in two machines). So what's root cause for this? What forces container to start many processes? Is this something related to many threads?
Below given are my few combination, which may force container to start many processes to handle incoming requests:
1) Only one servlet is available in container but that is in heavy usage; millions of client requests are coming
2) so many servlets are configured in container, each of them are having traffic.
Threads are running under process (one process so many threads), so how container's process manage so many threads? Is there any limitation for these thread numbers? Is it like container gets more requests/threads then defined number and that's why it is creating more process to handle this?
I know this question is out of the track for SCWCD, it doesn't have any connection with exam, but please let me know what do you think on this. I can sense this as a general problem of sites having heavy usage, this may crash Tomcat (Tomcat is not suggested for using as a WebServer).
As with lots of these things, the number of processes, and threads supported is configurable, and each implementation will have it's own foibles over when new processes are created.
There is a subtle distinction between threads from the httpd perspective (i.e. to handle requests for anything including images / static html), and threads allocated to servlets.
If the number of threads a process is alloated becomes too large then processes spend too much time (and memory) handling threads rather than dealing with the task in hand. Whether that is for a httpd process, or a process that the servlet container runs in.
Joined: Oct 07, 2008
hmm...that makes sense. Thanks for the reply and providing proper link.