0

I would like any hints or ideas as to what might be causing the following situation.

The website is on a Debian server with nginx 1.6.2, php5 through fpm.

A GET request to a page is supposed to generate a ZIP archive of considerable size from a few requested files that are on the server. It's a resource demanding operation, taking about 30 seconds (let's say) and consuming ~500+MiB of memory.

Now if during that operation the client attempts to open another page, the PHP's session handling will impose a delay for that page to open until the first GET request is finished. All this is within my understanding up until now.

However: if the client (insistently) refreshes the browser several times (5-8) the server will not respond at all to ANY user, not just the insistent one. This bugs me because the nginx configuration is set to 2 worker_processes, each with 1024 worker_connections, which should give me at least about 1000 connections before the server goes bunkers.

Top command reveals little CPU load.

Enlighten, please.

Slavic
  • 111
  • 4

3 Answers3

1

Looks like PHP is running out of children. In your case - try edit:

/etc/php5/fpm/pool.d/www.conf

Look for pm.max_children = 5 and change it to a higher value (10 or more)

You could also check for php_admin_value[memory_limit] = 32M (max allow memoryconsumption allow for each child)

Remove the comment and change the value to something that suites you setup.

Orphans
  • 1,404
  • 17
  • 26
0

<Stuck record>

You need to be scientific and methodical in your approach to this. In particular Scientific Method is your friend.

  • Install monitoring
  • Gather data
  • Analyse data
  • Make changes based on analysis
  • Monitor changes
  • Document

Rinse and repeat as necessary

</Stuck record>

user9517
  • 114,104
  • 20
  • 206
  • 289
-1

My best guess is the CPU is exhausted. Have you used "top" to work it out?

Nginx lets you impose rate limits with the rate limit module. There's a tutorial on how to do this here, but it's more at the resource level than the IP level, I think. This block should limit requests and connections, which would be more appropriate for you - code from this site.

http {
  ...
  limit_conn_zone $binary_remote_addr zone=alpha:8m;
  limit_req_zone  $binary_remote_addr zone=delta:8m rate=30r/s;
  ...

  server {
    ...
    limit_conn alpha 5;
    limit_req  zone=delta burst=80 nodelay;
    ...
  }
}
Tim
  • 30,383
  • 6
  • 47
  • 77
  • I forgot to add that CPU stands quietly under 40%. Also from my experience it's never the CPU - something else gives up first. I'll add the top output to my question. – Slavic Dec 22 '16 at 11:17