unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* Does unicorn waits after_work to consider a worker ready?
@ 2014-04-30 13:54 Bráulio Bhavamitra
  2014-05-01  1:33 ` Eric Wong
  0 siblings, 1 reply; 8+ messages in thread
From: Bráulio Bhavamitra @ 2014-04-30 13:54 UTC (permalink / raw)
  To: Unicorn

Hello all,

I had to use `sleep` (see https://gist.github.com/brauliobo/11298486)
to make rolling restart on my unicorn configuration.

But I'm worried if unicorn consider the worker ready for request even
before after_fork finishes. Could you say if that is true?

regards,
bráulio

-- 
"Lute pela sua ideologia. Seja um com sua ideologia. Viva pela sua
ideologia. Morra por sua ideologia" P.R. Sarkar

EITA - Educação, Informação e Tecnologias para Autogestão
http://cirandas.net/brauliobo
http://eita.org.br

"Paramapurusha é meu pai e Parama Prakriti é minha mãe. O universo é
meu lar e todos nós somos cidadãos deste cosmo. Este universo é a
imaginação da Mente Macrocósmica, e todas as entidades estão sendo
criadas, preservadas e destruídas nas fases de extroversão e
introversão do fluxo imaginativo cósmico. No âmbito pessoal, quando
uma pessoa imagina algo em sua mente, naquele momento, essa pessoa é a
única proprietária daquilo que ela imagina, e ninguém mais. Quando um
ser humano criado mentalmente caminha por um milharal também
imaginado, a pessoa imaginada não é a propriedade desse milharal, pois
ele pertence ao indivíduo que o está imaginando. Este universo foi
criado na imaginação de Brahma, a Entidade Suprema, por isso a
propriedade deste universo é de Brahma, e não dos microcosmos que
também foram criados pela imaginação de Brahma. Nenhuma propriedade
deste mundo, mutável ou imutável, pertence a um indivíduo em
particular; tudo é o patrimônio comum de todos."
Restante do texto em
http://cirandas.net/brauliobo/blog/a-problematica-de-hoje-em-dia
__
http://bogomips.org/unicorn-public/ - unicorn-public@bogomips.org
please quote as little as necessary when replying

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

* Re: Does unicorn waits after_work to consider a worker ready?
  2014-04-30 13:54 Does unicorn waits after_work to consider a worker ready? Bráulio Bhavamitra
@ 2014-05-01  1:33 ` Eric Wong
  2014-05-01 15:23   ` Bráulio Bhavamitra
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Wong @ 2014-05-01  1:33 UTC (permalink / raw)
  To: Bráulio Bhavamitra; +Cc: mongrel-unicorn, unicorn-public

Bráulio Bhavamitra <braulio@eita.org.br> wrote:
> Hello all,
> 
> I had to use `sleep` (see https://gist.github.com/brauliobo/11298486)
> to make rolling restart on my unicorn configuration.

Btw, rack 1.6 (when released) should have a native warmup method thanks
to Aman.  It's currently in rack.git.

> But I'm worried if unicorn consider the worker ready for request even
> before after_fork finishes. Could you say if that is true?

You do not need to sleep before warmup.

The master never pushes requests to a worker.  The key to unicorn is the
workers pull requests directly from the kernel queue.  The master is
never involved with distributing requests to the worker.


On a side note, your config is depressingly long and complex :<
Try to make your apps run well without needing unicorn-worker-killer,
at least...

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

* Re: Does unicorn waits after_work to consider a worker ready?
  2014-05-01  1:33 ` Eric Wong
@ 2014-05-01 15:23   ` Bráulio Bhavamitra
  2014-05-01 18:18     ` Eric Wong
  0 siblings, 1 reply; 8+ messages in thread
From: Bráulio Bhavamitra @ 2014-05-01 15:23 UTC (permalink / raw)
  To: Eric Wong; +Cc: Unicorn, unicorn-public

Hello Eric,

On Wed, Apr 30, 2014 at 10:33 PM, Eric Wong <normalperson@yhbt.net> wrote:
> Bráulio Bhavamitra <braulio@eita.org.br> wrote:
>> Hello all,
>>
>> I had to use `sleep` (see https://gist.github.com/brauliobo/11298486)
>> to make rolling restart on my unicorn configuration.
>
> Btw, rack 1.6 (when released) should have a native warmup method thanks
> to Aman.  It's currently in rack.git.
Nice!
>
>> But I'm worried if unicorn consider the worker ready for request even
>> before after_fork finishes. Could you say if that is true?
>
> You do not need to sleep before warmup.
Warm up requests are expensive. This sleep based on worker.nr makes
warm up happen on worker by worker, not all at once.

>
> The master never pushes requests to a worker.  The key to unicorn is the
> workers pull requests directly from the kernel queue.  The master is
> never involved with distributing requests to the worker.
Nice! So the kernel "sees" that worker is sleeping and should not pass
a request to it, I guess.
>
>
> On a side note, your config is depressingly long and complex :<
> Try to make your apps run well without needing unicorn-worker-killer,
> at least...
That's the ruby fate... Apps inevitably grow memory over time.

regards,
bráulio


-- 
"Lute pela sua ideologia. Seja um com sua ideologia. Viva pela sua
ideologia. Morra por sua ideologia" P.R. Sarkar

EITA - Educação, Informação e Tecnologias para Autogestão
http://cirandas.net/brauliobo
http://eita.org.br

"Paramapurusha é meu pai e Parama Prakriti é minha mãe. O universo é
meu lar e todos nós somos cidadãos deste cosmo. Este universo é a
imaginação da Mente Macrocósmica, e todas as entidades estão sendo
criadas, preservadas e destruídas nas fases de extroversão e
introversão do fluxo imaginativo cósmico. No âmbito pessoal, quando
uma pessoa imagina algo em sua mente, naquele momento, essa pessoa é a
única proprietária daquilo que ela imagina, e ninguém mais. Quando um
ser humano criado mentalmente caminha por um milharal também
imaginado, a pessoa imaginada não é a propriedade desse milharal, pois
ele pertence ao indivíduo que o está imaginando. Este universo foi
criado na imaginação de Brahma, a Entidade Suprema, por isso a
propriedade deste universo é de Brahma, e não dos microcosmos que
também foram criados pela imaginação de Brahma. Nenhuma propriedade
deste mundo, mutável ou imutável, pertence a um indivíduo em
particular; tudo é o patrimônio comum de todos."
Restante do texto em
http://cirandas.net/brauliobo/blog/a-problematica-de-hoje-em-dia

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

* Re: Does unicorn waits after_work to consider a worker ready?
  2014-05-01 15:23   ` Bráulio Bhavamitra
@ 2014-05-01 18:18     ` Eric Wong
  2014-05-01 19:00       ` Bráulio Bhavamitra
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Wong @ 2014-05-01 18:18 UTC (permalink / raw)
  To: Bráulio Bhavamitra; +Cc: Unicorn, unicorn-public

Bráulio Bhavamitra <braulio@eita.org.br> wrote:
> On Wed, Apr 30, 2014 at 10:33 PM, Eric Wong <normalperson@yhbt.net> wrote:
> > You do not need to sleep before warmup.
> Warm up requests are expensive. This sleep based on worker.nr makes
> warm up happen on worker by worker, not all at once.

The worker might just be processing the expensive request in a
user-visible state, correct?

Modern Linux (and I expect most OSes people use nowadays) are great at
dividing CPU-intensive work fairly.  Of course, if there's disk
intensive load, that's a different case.

> > The master never pushes requests to a worker.  The key to unicorn is the
> > workers pull requests directly from the kernel queue.  The master is
> > never involved with distributing requests to the worker.
> Nice! So the kernel "sees" that worker is sleeping and should not pass
> a request to it, I guess.

Almost, but the kernel socket queueing doesn't really see.  It's more
like the kernel just puts food on the table continuously without caring
if workers are eating.  Sometimes the table overflows and food gets
thrown in the trash when the workers are all sleeping or full.

> > On a side note, your config is depressingly long and complex :<
> > Try to make your apps run well without needing unicorn-worker-killer,
> > at least...
> That's the ruby fate... Apps inevitably grow memory over time.

Only if you let bugs stay around.

If you find bugs in Ruby or the libs you use, please report and help get
them fixed.  Ruby 2.1 had some corner cases, true, but we need to help
fight against bloated apps.

...and bloated email signatures :P

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

* Re: Does unicorn waits after_work to consider a worker ready?
  2014-05-01 18:18     ` Eric Wong
@ 2014-05-01 19:00       ` Bráulio Bhavamitra
  2014-05-02 23:43         ` Eric Wong
  0 siblings, 1 reply; 8+ messages in thread
From: Bráulio Bhavamitra @ 2014-05-01 19:00 UTC (permalink / raw)
  To: Eric Wong; +Cc: Unicorn, unicorn-public

On Thu, May 1, 2014 at 3:18 PM, Eric Wong <normalperson@yhbt.net> wrote:
> Bráulio Bhavamitra <braulio@eita.org.br> wrote:
>> On Wed, Apr 30, 2014 at 10:33 PM, Eric Wong <normalperson@yhbt.net> wrote:
>> > You do not need to sleep before warmup.
>> Warm up requests are expensive. This sleep based on worker.nr makes
>> warm up happen on worker by worker, not all at once.
>
> The worker might just be processing the expensive request in a
> user-visible state, correct?
>
> Modern Linux (and I expect most OSes people use nowadays) are great at
> dividing CPU-intensive work fairly.  Of course, if there's disk
> intensive load, that's a different case.
Yeah, I see that frequently on top.

But if all workers are warming up at once, say 10 workers, then the
old workers will slow down to serve requests, as CPU will be heavily used
by the warming up workers. That's is the main reason to slow down warm up.

>
>> > The master never pushes requests to a worker.  The key to unicorn is the
>> > workers pull requests directly from the kernel queue.  The master is
>> > never involved with distributing requests to the worker.
>> Nice! So the kernel "sees" that worker is sleeping and should not pass
>> a request to it, I guess.
>
> Almost, but the kernel socket queueing doesn't really see.  It's more
> like the kernel just puts food on the table continuously without caring
> if workers are eating.  Sometimes the table overflows and food gets
> thrown in the trash when the workers are all sleeping or full.
Interesting... So the queue know about sleeping workers, but we have
to prevent that all workers are sleeping at the same time.

>
>> > On a side note, your config is depressingly long and complex :<
>> > Try to make your apps run well without needing unicorn-worker-killer,
>> > at least...
>> That's the ruby fate... Apps inevitably grow memory over time.
>
> Only if you let bugs stay around.
>
> If you find bugs in Ruby or the libs you use, please report and help get
> them fixed.  Ruby 2.1 had some corner cases, true, but we need to help
> fight against bloated apps.
That's the ruby design, as the heap only grows, so with a request that
loads a lot of data the heap will grow big and never shrink.
http://izumi.plan99.net/blog/index.php/2007/10/12/how-the-ruby-heap-is-implemented/

Ruby 2.1 changes that? We will soon migrate to ruby 2.1, but we are
not ready for it yet.

>
> ...and bloated email signatures :P
:P


-- 
"Lute pela sua ideologia. Seja um com sua ideologia. Viva pela sua
ideologia. Morra por sua ideologia" P.R. Sarkar

EITA - Educação, Informação e Tecnologias para Autogestão
http://cirandas.net/brauliobo
http://eita.org.br

"Paramapurusha é meu pai e Parama Prakriti é minha mãe. O universo é
meu lar e todos nós somos cidadãos deste cosmo. Este universo é a
imaginação da Mente Macrocósmica, e todas as entidades estão sendo
criadas, preservadas e destruídas nas fases de extroversão e
introversão do fluxo imaginativo cósmico. No âmbito pessoal, quando
uma pessoa imagina algo em sua mente, naquele momento, essa pessoa é a
única proprietária daquilo que ela imagina, e ninguém mais. Quando um
ser humano criado mentalmente caminha por um milharal também
imaginado, a pessoa imaginada não é a propriedade desse milharal, pois
ele pertence ao indivíduo que o está imaginando. Este universo foi
criado na imaginação de Brahma, a Entidade Suprema, por isso a
propriedade deste universo é de Brahma, e não dos microcosmos que
também foram criados pela imaginação de Brahma. Nenhuma propriedade
deste mundo, mutável ou imutável, pertence a um indivíduo em
particular; tudo é o patrimônio comum de todos."
Restante do texto em
http://cirandas.net/brauliobo/blog/a-problematica-de-hoje-em-dia

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

* Re: Does unicorn waits after_work to consider a worker ready?
  2014-05-01 19:00       ` Bráulio Bhavamitra
@ 2014-05-02 23:43         ` Eric Wong
  2014-05-04 12:57           ` Bráulio Bhavamitra
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Wong @ 2014-05-02 23:43 UTC (permalink / raw)
  To: Bráulio Bhavamitra; +Cc: Unicorn, unicorn-public

Bráulio Bhavamitra <braulio@eita.org.br> wrote:
> That's the ruby design, as the heap only grows, so with a request that
> loads a lot of data the heap will grow big and never shrink.
> http://izumi.plan99.net/blog/index.php/2007/10/12/how-the-ruby-heap-is-implemented/

That's ancient, I was waiting for Hongli to reply...

> Ruby 2.1 changes that? We will soon migrate to ruby 2.1, but we are
> not ready for it yet.

Yes, Ruby freed object slots since the 1.9 days, I think.

Anyways, I've maintained a bunch of Ruby apps and I've gotten _all_ of
them have stable memory usage.  Often I needed to fix bugs in Ruby
itself or other gems/libraries to get there, though!

One basic rule (which I learned as a Perl hacker): do not slurp.  Limit
the size of data you work with and break things into smaller chunks if
necessary (e.g. data from client uploads or database/API responses).
Things like running a "SELECT" without "LIMIT" in SQL should raise red
flags immediately.

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

* Re: Does unicorn waits after_work to consider a worker ready?
  2014-05-02 23:43         ` Eric Wong
@ 2014-05-04 12:57           ` Bráulio Bhavamitra
  2014-05-04 21:24             ` Bráulio Bhavamitra
  0 siblings, 1 reply; 8+ messages in thread
From: Bráulio Bhavamitra @ 2014-05-04 12:57 UTC (permalink / raw)
  To: Eric Wong; +Cc: Unicorn, unicorn-public

Thanks very much Eric.

Just looked at the Unicorn's source code and the answer to the
subject's question is yes.

Also, I have made the configuration a little shorter, and made worker
killer optional: https://gist.github.com/brauliobo/11298486

regards,
bráulio

On Fri, May 2, 2014 at 8:43 PM, Eric Wong <normalperson@yhbt.net> wrote:
> Bráulio Bhavamitra <braulio@eita.org.br> wrote:
>> That's the ruby design, as the heap only grows, so with a request that
>> loads a lot of data the heap will grow big and never shrink.
>> http://izumi.plan99.net/blog/index.php/2007/10/12/how-the-ruby-heap-is-implemented/
>
> That's ancient, I was waiting for Hongli to reply...
>
>> Ruby 2.1 changes that? We will soon migrate to ruby 2.1, but we are
>> not ready for it yet.
>
> Yes, Ruby freed object slots since the 1.9 days, I think.
>
> Anyways, I've maintained a bunch of Ruby apps and I've gotten _all_ of
> them have stable memory usage.  Often I needed to fix bugs in Ruby
> itself or other gems/libraries to get there, though!
>
> One basic rule (which I learned as a Perl hacker): do not slurp.  Limit
> the size of data you work with and break things into smaller chunks if
> necessary (e.g. data from client uploads or database/API responses).
> Things like running a "SELECT" without "LIMIT" in SQL should raise red
> flags immediately.



-- 
"Lute pela sua ideologia. Seja um com sua ideologia. Viva pela sua
ideologia. Morra por sua ideologia" P.R. Sarkar

EITA - Educação, Informação e Tecnologias para Autogestão
http://cirandas.net/brauliobo
http://eita.org.br

"Paramapurusha é meu pai e Parama Prakriti é minha mãe. O universo é
meu lar e todos nós somos cidadãos deste cosmo. Este universo é a
imaginação da Mente Macrocósmica, e todas as entidades estão sendo
criadas, preservadas e destruídas nas fases de extroversão e
introversão do fluxo imaginativo cósmico. No âmbito pessoal, quando
uma pessoa imagina algo em sua mente, naquele momento, essa pessoa é a
única proprietária daquilo que ela imagina, e ninguém mais. Quando um
ser humano criado mentalmente caminha por um milharal também
imaginado, a pessoa imaginada não é a propriedade desse milharal, pois
ele pertence ao indivíduo que o está imaginando. Este universo foi
criado na imaginação de Brahma, a Entidade Suprema, por isso a
propriedade deste universo é de Brahma, e não dos microcosmos que
também foram criados pela imaginação de Brahma. Nenhuma propriedade
deste mundo, mutável ou imutável, pertence a um indivíduo em
particular; tudo é o patrimônio comum de todos."
Restante do texto em
http://cirandas.net/brauliobo/blog/a-problematica-de-hoje-em-dia

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

* Re: Does unicorn waits after_work to consider a worker ready?
  2014-05-04 12:57           ` Bráulio Bhavamitra
@ 2014-05-04 21:24             ` Bráulio Bhavamitra
  0 siblings, 0 replies; 8+ messages in thread
From: Bráulio Bhavamitra @ 2014-05-04 21:24 UTC (permalink / raw)
  To: Eric Wong; +Cc: Unicorn, unicorn-public

Reached the state I wanted: decreased worker number using TTOU upon
each warm up time, something like a "phased restart".

Updated http://gist.github.com/brauliobo/11298486

2014-05-04 9:57 GMT-03:00 Bráulio Bhavamitra <braulio@eita.org.br>:
> Thanks very much Eric.
>
> Just looked at the Unicorn's source code and the answer to the
> subject's question is yes.
>
> Also, I have made the configuration a little shorter, and made worker
> killer optional: https://gist.github.com/brauliobo/11298486
>
> regards,
> bráulio
>
> On Fri, May 2, 2014 at 8:43 PM, Eric Wong <normalperson@yhbt.net> wrote:
>> Bráulio Bhavamitra <braulio@eita.org.br> wrote:
>>> That's the ruby design, as the heap only grows, so with a request that
>>> loads a lot of data the heap will grow big and never shrink.
>>> http://izumi.plan99.net/blog/index.php/2007/10/12/how-the-ruby-heap-is-implemented/
>>
>> That's ancient, I was waiting for Hongli to reply...
>>
>>> Ruby 2.1 changes that? We will soon migrate to ruby 2.1, but we are
>>> not ready for it yet.
>>
>> Yes, Ruby freed object slots since the 1.9 days, I think.
>>
>> Anyways, I've maintained a bunch of Ruby apps and I've gotten _all_ of
>> them have stable memory usage.  Often I needed to fix bugs in Ruby
>> itself or other gems/libraries to get there, though!
>>
>> One basic rule (which I learned as a Perl hacker): do not slurp.  Limit
>> the size of data you work with and break things into smaller chunks if
>> necessary (e.g. data from client uploads or database/API responses).
>> Things like running a "SELECT" without "LIMIT" in SQL should raise red
>> flags immediately.
>
>
>
> --
> "Lute pela sua ideologia. Seja um com sua ideologia. Viva pela sua
> ideologia. Morra por sua ideologia" P.R. Sarkar
>
> EITA - Educação, Informação e Tecnologias para Autogestão
> http://cirandas.net/brauliobo
> http://eita.org.br
>
> "Paramapurusha é meu pai e Parama Prakriti é minha mãe. O universo é
> meu lar e todos nós somos cidadãos deste cosmo. Este universo é a
> imaginação da Mente Macrocósmica, e todas as entidades estão sendo
> criadas, preservadas e destruídas nas fases de extroversão e
> introversão do fluxo imaginativo cósmico. No âmbito pessoal, quando
> uma pessoa imagina algo em sua mente, naquele momento, essa pessoa é a
> única proprietária daquilo que ela imagina, e ninguém mais. Quando um
> ser humano criado mentalmente caminha por um milharal também
> imaginado, a pessoa imaginada não é a propriedade desse milharal, pois
> ele pertence ao indivíduo que o está imaginando. Este universo foi
> criado na imaginação de Brahma, a Entidade Suprema, por isso a
> propriedade deste universo é de Brahma, e não dos microcosmos que
> também foram criados pela imaginação de Brahma. Nenhuma propriedade
> deste mundo, mutável ou imutável, pertence a um indivíduo em
> particular; tudo é o patrimônio comum de todos."
> Restante do texto em
> http://cirandas.net/brauliobo/blog/a-problematica-de-hoje-em-dia



-- 
"Lute pela sua ideologia. Seja um com sua ideologia. Viva pela sua
ideologia. Morra por sua ideologia" P.R. Sarkar

EITA - Educação, Informação e Tecnologias para Autogestão
http://cirandas.net/brauliobo
http://eita.org.br

"Paramapurusha é meu pai e Parama Prakriti é minha mãe. O universo é
meu lar e todos nós somos cidadãos deste cosmo. Este universo é a
imaginação da Mente Macrocósmica, e todas as entidades estão sendo
criadas, preservadas e destruídas nas fases de extroversão e
introversão do fluxo imaginativo cósmico. No âmbito pessoal, quando
uma pessoa imagina algo em sua mente, naquele momento, essa pessoa é a
única proprietária daquilo que ela imagina, e ninguém mais. Quando um
ser humano criado mentalmente caminha por um milharal também
imaginado, a pessoa imaginada não é a propriedade desse milharal, pois
ele pertence ao indivíduo que o está imaginando. Este universo foi
criado na imaginação de Brahma, a Entidade Suprema, por isso a
propriedade deste universo é de Brahma, e não dos microcosmos que
também foram criados pela imaginação de Brahma. Nenhuma propriedade
deste mundo, mutável ou imutável, pertence a um indivíduo em
particular; tudo é o patrimônio comum de todos."
Restante do texto em
http://cirandas.net/brauliobo/blog/a-problematica-de-hoje-em-dia

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

end of thread, other threads:[~2014-05-04 21:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-30 13:54 Does unicorn waits after_work to consider a worker ready? Bráulio Bhavamitra
2014-05-01  1:33 ` Eric Wong
2014-05-01 15:23   ` Bráulio Bhavamitra
2014-05-01 18:18     ` Eric Wong
2014-05-01 19:00       ` Bráulio Bhavamitra
2014-05-02 23:43         ` Eric Wong
2014-05-04 12:57           ` Bráulio Bhavamitra
2014-05-04 21:24             ` Bráulio Bhavamitra

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).