No announcement yet.

Too much traffic! NginX

  • Filter
  • Time
  • Show
Clear All
new posts

  • Too much traffic! NginX

    WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 398 total children
    WARNING: [pool www] server reached pm.max_children setting (400), consider raising it
    How do I keep my website from getting a 502 error because of too many concurrent connections? 1,000 Unique hits in 30 seconds brought us down, then after fine tuning php-fpm, 60 hits in 30 seconds brought us down, but those only represent successful downloads, etc. What is bringing us down is concurrent connections.

    Any advice?

  • #2
    Without a URL to look at or good description of what the site is doing server side a definative answer is a bit tricky. How the database itself is arranged can also cause problems. Newbies often shove everything into a single massive table and this means that time may be being wasted moving irrelevent data around.

    Caching (storing) commonly requested content instead of rebuilding it each time from the database for every visitor is one method. Works well for most sites doing product listings or mostly static content served up from a database.

    The other would be a queuing system where the error generated by having insufficient connections available locks the visitor into a waiting loop until one becomes available. Eg: forums or a chatroom Rather than having the more usual 'connect or die' statement used in many tutorials.

    Not tried the code, but it looks about right
    PHP Code:
    if (
    mysql_errno() == 1203) {
    // 1203 == ER_TOO_MANY_USER_CONNECTIONS (mysqld_error.h)
    Last edited by cybrax; 02-22-2012, 08:37 PM.


    • #3
      There is a lot of good info in the post above me. I really like that caching was mentioned. I would like to post something I read earlier today that seems relevant. It is basically some advice on optimizing your queries to MySQL. This is from the page "Writing a Plugin : WordPress Codex".

      Database reading is cheap, but writing is expensive. Databases are exceptionally good at fetching data and giving it to you, and these operations are (usually) lightning quick. Making changes to the database, though, is a more complex process, and computationally more expensive. As a result, try to minimize the amount of writing you do to the database. Get everything prepared in your code first, so that you can make only those write operations that you need.

      SELECT only what you need. Even though databases fetch data blindingly fast, you should still try to reduce the load on the database by only selecting that data which you need to use. If you need to count the number of rows in a table don't SELECT * FROM, because all the data in all the rows will be pulled, wasting memory. Likewise, if you only need the post_id and the post_author, then just SELECT those specific fields, to minimize database load. Remember: hundreds of other processes may be hitting the database at the same time. The database and server each have only so many resources to spread around amongst all those processes.
      EDIT: I tried reading a bit more on the subject today and could not figure out a solution. If you manage to resolve your issue I would be very interested to know how you did.
      Last edited by Assembly Code; 03-13-2012, 07:51 AM.