# Cpu spike on HUP

**URL:** <https://www.ruby-forum.com/t/cpu-spike-on-hup/198276>\
**Category:** NGINX\
**Created:** [October 29, 2010, 1:57am UTC](https://www.ruby-forum.com/t/cpu-spike-on-hup/198276 "2010-10-29T01:57:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [October 29, 2010, 1:57am UTC](https://www.ruby-forum.com/t/cpu-spike-on-hup/198276/1 "2010-10-29T01:57:02Z")

</div>

Whenever nginx is sent a HUP signal, the cpu jumps to 100% then slowly  
drops until all the nginx worker processes that are trying to shutting  
down are done. Those nginx process usually take a while to shutdown  
since we’re serving very large files (200MB-2GB). Any ideas why this is  
happening?

From the strace below it looks like it all in sendfile but I wouldn’t  
think that would so cpu intense.

-gary

/usr/local/nginx/sbin/nginx -V  
nginx version: nginx/0.8.52  
built by gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5)  
TLS SNI support enabled  
configure arguments: --with-http\_ssl\_module --with-http\_flv\_module

This is from about 10 seconds of strace of one of the nginx process  
while shutting down.

sudo strace -cp 7087  
Process 7087 attached - interrupt to quit  
^CProcess 7087 detached  
% time seconds usecs/call calls errors syscall

* * *

99.85 0.071681 139 515 sendfile  
0.15 0.000110 0 252 epoll\_wait

* * *

100.00 0.071791 767 total

---

<div class="post-metadata">

**Author:** ![Gary\_Barrueto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3da27b/32.png) [@Gary\_Barrueto](https://www.ruby-forum.com/u/Gary_Barrueto)\
**Post date:** [October 29, 2010, 10:03am UTC](https://www.ruby-forum.com/t/cpu-spike-on-hup/198276/2 "2010-10-29T10:03:14Z")

</div>

On Thu, Oct 28, 2010 at 04:55:40PM -0700, Gary Barrueto wrote:

> Whenever nginx is sent a HUP signal, the cpu jumps to 100% then slowly  
> drops until all the nginx worker processes that are trying to shutting  
> down are done. Those nginx process usually take a while to shutdown  
> since we’re serving very large files (200MB-2GB). Any ideas why this is  
> happening?
> 
> From the strace below it looks like it all in sendfile but I wouldn’t  
> think that would so cpu intense.

What kind of CPU is used in these moments: system or user according to  
top ?

> sudo strace -cp 7087  
> Process 7087 attached - interrupt to quit  
> ^CProcess 7087 detached  
> % time seconds usecs/call calls errors syscall
> 
> * * *
> 
> 99.85 0.071681 139 515 sendfile  
> 0.15 0.000110 0 252 epoll\_wait
> 
> * * *
> 
> 100.00 0.071791 767 total

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![Gary\_Barrueto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3da27b/32.png) [@Gary\_Barrueto](https://www.ruby-forum.com/u/Gary_Barrueto)\
**Post date:** [October 29, 2010, 11:04pm UTC](https://www.ruby-forum.com/t/cpu-spike-on-hup/198276/3 "2010-10-29T23:04:00Z")

</div>

On 10/29/2010 01:02 AM, Igor S. wrote:

> What kind of CPU is used in these moments: system or user according to top ?

I just sent a HUP signal to nginx and the cpu shot up to 55% user and  
another 10% sys.

-gary

---

<div class="post-metadata">

**Author:** ![Gary\_Barrueto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3da27b/32.png) [@Gary\_Barrueto](https://www.ruby-forum.com/u/Gary_Barrueto)\
**Post date:** [October 30, 2010, 8:08am UTC](https://www.ruby-forum.com/t/cpu-spike-on-hup/198276/4 "2010-10-30T08:08:56Z")

</div>

On Fri, Oct 29, 2010 at 02:02:29PM -0700, Gary Barrueto wrote:

> > > think that would so cpu intense.  
> > > What kind of CPU is used in these moments: system or user according to top ?
> 
> I just sent a HUP signal to nginx and the cpu shot up to 55% user and  
> another 10% sys.

Do you send a HUP signal to master process only or to worker processes  
too ?

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![Gary\_Barrueto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3da27b/32.png) [@Gary\_Barrueto](https://www.ruby-forum.com/u/Gary_Barrueto)\
**Post date:** [November 3, 2010, 7:06pm UTC](https://www.ruby-forum.com/t/cpu-spike-on-hup/198276/5 "2010-11-03T19:06:46Z")

</div>

On 10/30/2010 2:13 AM, Gary Barrueto wrote:

> On 10/29/2010 11:07 PM, Igor S. wrote:
> 
> > > I just sent a HUP signal to nginx and the cpu shot up to 55% user and  
> > > another 10% sys.  
> > > Do you send a HUP signal to master process only or to worker  
> > > processes too ?  
> > > I sent the HUP signal to the master process.  
> > > -gary

Normally, the cpu is at 1% user and system is at 2% when serving  
60-90MB/sec.

-gary

---

<div class="post-metadata">

**Author:** ![Gary\_Barrueto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3da27b/32.png) [@Gary\_Barrueto](https://www.ruby-forum.com/u/Gary_Barrueto)\
**Post date:** [October 30, 2010, 11:14am UTC](https://www.ruby-forum.com/t/cpu-spike-on-hup/198276/6 "2010-10-30T11:14:47Z")

</div>

On 10/29/2010 11:07 PM, Igor S. wrote:

> > I just sent a HUP signal to nginx and the cpu shot up to 55% user and  
> > another 10% sys.  
> > Do you send a HUP signal to master process only or to worker processes too ?

I sent the HUP signal to the master process.

-gary
