unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* Why so many worker threads?
@ 2013-03-01 11:19 Alexey Chernenkov
  2013-03-01 17:41 ` Eric Wong
  2013-03-01 18:29 ` Alejandro Riera
  0 siblings, 2 replies; 8+ messages in thread
From: Alexey Chernenkov @ 2013-03-01 11:19 UTC (permalink / raw)
  To: mongrel-unicorn

Hello!

Can anyone explain why my Unicorn installation (for RoR site) have so
many worker threads?

  * screenshot: http://i.stack.imgur.com/U9TFR.png
  * unicorn.rb: https://gist.github.com/907th/4995323

Thanks!
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Why so many worker threads?
  2013-03-01 11:19 Why so many worker threads? Alexey Chernenkov
@ 2013-03-01 17:41 ` Eric Wong
       [not found]   ` <CAHF=L-xHOguSLkyytYS6G-b=5nHYid-Mgz1MOqo8=zm0sRk=kQ@mail.gmail.com>
  2013-03-01 19:06   ` Alexey Chernenkov
  2013-03-01 18:29 ` Alejandro Riera
  1 sibling, 2 replies; 8+ messages in thread
From: Eric Wong @ 2013-03-01 17:41 UTC (permalink / raw)
  To: unicorn list; +Cc: Alexey Chernenkov

Alexey Chernenkov <laise@pisem.net> wrote:
> Hello!
> 
> Can anyone explain why my Unicorn installation (for RoR site) have so
> many worker threads?
> 
>   * screenshot: http://i.stack.imgur.com/U9TFR.png
>   * unicorn.rb: https://gist.github.com/907th/4995323

It's probably some gem/library you're using which spawns threads behind
your back.  Ruby 1.9/2.0 only has one extra thread per-process for
accepting signals.
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Why so many worker threads?
  2013-03-01 11:19 Why so many worker threads? Alexey Chernenkov
  2013-03-01 17:41 ` Eric Wong
@ 2013-03-01 18:29 ` Alejandro Riera
  1 sibling, 0 replies; 8+ messages in thread
From: Alejandro Riera @ 2013-03-01 18:29 UTC (permalink / raw)
  To: unicorn list

>   * screenshot: http://i.stack.imgur.com/U9TFR.png

which command did you run to show that list?
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Why so many worker threads?
       [not found]   ` <CAHF=L-xHOguSLkyytYS6G-b=5nHYid-Mgz1MOqo8=zm0sRk=kQ@mail.gmail.com>
@ 2013-03-01 19:05     ` Alexey Chernenkov
  2013-03-01 19:14       ` Alejandro Riera
  0 siblings, 1 reply; 8+ messages in thread
From: Alexey Chernenkov @ 2013-03-01 19:05 UTC (permalink / raw)
  To: Alejandro Riera; +Cc: unicorn list

2013/3/1 Alejandro Riera <ariera@gmail.com>:
> which command do you run to show that list?
>
> On 1 March 2013 18:41, Eric Wong <normalperson@yhbt.net> wrote:
>>
>> Alexey Chernenkov <laise@pisem.net> wrote:
>> > Can anyone explain why my Unicorn installation (for RoR site) have so
>> > many worker threads?
>> >
>> >   * screenshot: http://i.stack.imgur.com/U9TFR.png
>> >   * unicorn.rb: https://gist.github.com/907th/4995323
>>
>> It's probably some gem/library you're using which spawns threads behind
>> your back.  Ruby 1.9/2.0 only has one extra thread per-process for
>> accepting signals.

Screenshot? Its `htop` command with tree (F5) view.
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Why so many worker threads?
  2013-03-01 17:41 ` Eric Wong
       [not found]   ` <CAHF=L-xHOguSLkyytYS6G-b=5nHYid-Mgz1MOqo8=zm0sRk=kQ@mail.gmail.com>
@ 2013-03-01 19:06   ` Alexey Chernenkov
  2013-03-01 23:05     ` Eric Wong
  1 sibling, 1 reply; 8+ messages in thread
From: Alexey Chernenkov @ 2013-03-01 19:06 UTC (permalink / raw)
  To: Eric Wong; +Cc: unicorn list

2013/3/1 Eric Wong <normalperson@yhbt.net>:
> Alexey Chernenkov <laise@pisem.net> wrote:
>>
>> Can anyone explain why my Unicorn installation (for RoR site) have so
>> many worker threads?
>>   * screenshot: http://i.stack.imgur.com/U9TFR.png
>>   * unicorn.rb: https://gist.github.com/907th/4995323
>>
>
> It's probably some gem/library you're using which spawns threads behind
> your back.  Ruby 1.9/2.0 only has one extra thread per-process for
> accepting signals.
>

Could you advise me how I can determine which gem causes the problem?
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Why so many worker threads?
  2013-03-01 19:05     ` Alexey Chernenkov
@ 2013-03-01 19:14       ` Alejandro Riera
  2013-03-01 20:54         ` Tatsuya Ono
  0 siblings, 1 reply; 8+ messages in thread
From: Alejandro Riera @ 2013-03-01 19:14 UTC (permalink / raw)
  To: Alexey Chernenkov; +Cc: unicorn list

>>> >   * screenshot: http://i.stack.imgur.com/U9TFR.png
>>> >   * unicorn.rb: https://gist.github.com/907th/4995323
>> which command do you run to show that list?
>
> Screenshot? Its `htop` command with tree (F5) view.


I have just one worker. If I run top I just see one master and one
worker. But with htop there are 3 masters and 3 workers, each of them
with a different pid. This is a surprise to me too. I'm runnnig ruby
1.9.2.
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Why so many worker threads?
  2013-03-01 19:14       ` Alejandro Riera
@ 2013-03-01 20:54         ` Tatsuya Ono
  0 siblings, 0 replies; 8+ messages in thread
From: Tatsuya Ono @ 2013-03-01 20:54 UTC (permalink / raw)
  To: unicorn list

NewRelic and Airbrake are popular gems which spawns threads.

Unfortunately I don't think there is a silver bullet to detect which
gems are doing that. You have to investigate it step by step. For
example, you can create a new Rails app with the Gemfile(assuming you
use bundler), config and initializers. If you succeeded to reproduce
the problem with the small app, the rest of research would not be
difficult. You remove a gem one by one and restart app and you may
want to make some requests, then check the number of threads. If the
number of threads is reduced, that's would be it.

Or maybe you can grep your gem library directory with some keywords
like "Thread" or "Proc"? If you install gem library to specific path
(--path option on Bundler) for the application, you can avoid look at
other gems installed by other ruby application.
http://gembundler.com/v1.2/bundle_install.html


I don't think that the problem is related to Unicorn though.

Good luck :-)

On 1 March 2013 19:14, Alejandro Riera <ariera@gmail.com> wrote:
>
> >>> >   * screenshot: http://i.stack.imgur.com/U9TFR.png
> >>> >   * unicorn.rb: https://gist.github.com/907th/4995323
> >> which command do you run to show that list?
> >
> > Screenshot? Its `htop` command with tree (F5) view.
>
>
> I have just one worker. If I run top I just see one master and one
> worker. But with htop there are 3 masters and 3 workers, each of them
> with a different pid. This is a surprise to me too. I'm runnnig ruby
> 1.9.2.
> _______________________________________________
> Unicorn mailing list - mongrel-unicorn@rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-unicorn
> Do not quote signatures (like this one) or top post when replying
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Why so many worker threads?
  2013-03-01 19:06   ` Alexey Chernenkov
@ 2013-03-01 23:05     ` Eric Wong
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Wong @ 2013-03-01 23:05 UTC (permalink / raw)
  To: unicorn list; +Cc: Alexey Chernenkov

Alexey Chernenkov <laise@pisem.net> wrote:
> 2013/3/1 Eric Wong <normalperson@yhbt.net>:
> > Alexey Chernenkov <laise@pisem.net> wrote:
> >>
> >> Can anyone explain why my Unicorn installation (for RoR site) have so
> >> many worker threads?
> >>   * screenshot: http://i.stack.imgur.com/U9TFR.png
> >>   * unicorn.rb: https://gist.github.com/907th/4995323
> >>
> >
> > It's probably some gem/library you're using which spawns threads behind
> > your back.  Ruby 1.9/2.0 only has one extra thread per-process for
> > accepting signals.
> >
> Could you advise me how I can determine which gem causes the problem?

What Tatsuya said.

Really, you should never hesitate to grep/scan/read the source of
_everything_ you're running.

For C extensions, check for the pthread_create() function, too.  Also,
any existing libraries your C/FFI extensions might link to...

If you're on Linux, you can probably track it down a little faster via
"strace -f -e clone"  (clone() is the underlying syscall used for both
fork() and pthread_create()).
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-03-01 23:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-01 11:19 Why so many worker threads? Alexey Chernenkov
2013-03-01 17:41 ` Eric Wong
     [not found]   ` <CAHF=L-xHOguSLkyytYS6G-b=5nHYid-Mgz1MOqo8=zm0sRk=kQ@mail.gmail.com>
2013-03-01 19:05     ` Alexey Chernenkov
2013-03-01 19:14       ` Alejandro Riera
2013-03-01 20:54         ` Tatsuya Ono
2013-03-01 19:06   ` Alexey Chernenkov
2013-03-01 23:05     ` Eric Wong
2013-03-01 18:29 ` Alejandro Riera

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).