Linux – Why are there so many processes running

javalinuxprocessUbuntu

I host several Rails applications on a VPS using Ubuntu 8.04, Nginx, Passenger, Mysql, RVM, so all the usual suspects.

In the last days it was the first time I really had to debug a problem and look at which processes are running. I could fix the problem using passenger-status and passenger-memory-stats, but I am quite confused by the number of processes running and can't quite figure it out.

Take a look at this screenshot for example: http://screencast.com/t/wUMrmy5iQPQi (taken from htop)

It shows lots of Hudson processes (Hudson is the CI server I am running on that machine).

My questions are:

  • Why are there 34 of them?
  • Are they all separate processes?
  • Are there supposed to be 34 of them or are some of them stale, orphaned processes that didn't shutdown properly on a restart and which I should kill?

Best Answer

You are seeing threads. While in htop, press F2 for options then select "Display Options". Check the box for "Hide userland threads" and/or try some of the options in htop like "display threads in a different color"

You may also want to turn on the PPID (parent process id) column. Then you'll be able to tell that all of the threads likely list the same parent process.