Multiple master processes

Eric Wong normalperson at yhbt.net
Mon Jan 31 13:08:15 EST 2011


Tilmann Singer <tils at tils.net> wrote:
> Hi,
> 
> I'm seeing the following output of ps after starting unicorn, which as
> I understand it means that there are multiple master processes
> running, each with its own pid. Is that normal behaviour or is there
> something wrong with my setup?

It's normal behavior for Linux 2.4.x + Ruby 1.9, don't worry about it.

> $ ps xf|grep 4002
>  8022 ?        S      0:00 unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
>  8024 ?        S      0:00  \_ unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
> 26743 ?        S      0:00  |   \_ unicorn master -c config/unicorn.rb -E production -p 4002 -D                                         
> 26734 ?        S      0:22  \_ unicorn worker[0] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26736 ?        S      0:00  |   \_ unicorn worker[0] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26739 ?        S      0:00  |       \_ unicorn worker[0] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26737 ?        S      0:22  \_ unicorn worker[2] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26740 ?        S      0:00  |   \_ unicorn worker[2] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26741 ?        S      0:00  |       \_ unicorn worker[2] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26742 ?        S      0:21  \_ unicorn worker[1] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26744 ?        S      0:00      \_ unicorn worker[1] -c config/unicorn.rb -E production -p 4002 -D                                      
> 26745 ?        S      0:00          \_ unicorn worker[1] -c config/unicorn.rb -E production -p 4002 -D                                      
> $ cat tmp/pids/unicorn.pid
> 8022
> 
> This is on Linux 2.4.27, ruby 1.9.2

With LinuxThreads in 2.4, the native threads used by Ruby 1.9 each had a
unique PID and /proc entry whereas with NPTL in 2.6 hides the top-level
entries of tasks that weren't processes (still visible in
/proc/$pid/task/*)

"tasks" are just the in-kernel representation of either processes and
native threads in all Linux versions.  They're created via the same
system call, clone(2), so pthread_create() and fork() are just wrappers
around clone() with different arguments.  It's just 2.4 had fewer
options for clone() that made it weirder and less POSIX-conformant.

The pthreads(7) manpage has more details on the differences between NPTL
and LinuxThreads.

Wow, I didn't realize people ran the latest Rubies on 2.4.x!

-- 
Eric Wong


More information about the mongrel-unicorn mailing list