www.webdeveloper.com
Results 1 to 7 of 7

Thread: Need to prepare for user overload!!!!

Hybrid View

  1. #1
    Join Date
    Mar 2008
    Location
    Leeds
    Posts
    26

    Need to prepare for user overload!!!!

    Howdy, I have a question regards my website. Next week 30 000 users are going to hit my website at once and it will timeout. I want to put a message asking users to come back later and explain the problem (too many users at once). My site is a PHP/mySQL site on Linuz/Apache. I have a .htaccess file that usually deals with errors and I wass wondering if adding to this would cover me for 5++ errors (like 503, 509).

    For example:

    ErrorDocument 400 https://www.mysite.co.uk/page-not-found.php
    ErrorDocument 403 https://www.mysite.co.uk/page-not-found.php
    ErrorDocument 404 https://www.mysite.co.uk/page-not-found.php
    ErrorDocument 500 https://www.mysite.co.uk/server_down.html
    ErrorDocument 501 https://www.mysite.co.uk/server_down.html
    ErrorDocument 503 https://www.mysite.co.uk/server_down.html
    ErrorDocument 509 https://www.mysite.co.uk/server_down.html

    I'm confused that if mysite is downdue to demand can I redirect the user to a page that (although light in size) is actually on that domain (i.e. www.mysite.co.uk)

    Is this the right thing to do or do I need a subdomain?

    Thanks

  2. #2
    Join Date
    Nov 2008
    Posts
    2,477
    If your site receives too much traffic chances are apache is going to start trying to spawn new child processes on disk (as opposed to in memory) and that will likely be the cause of any slow down - either that or if it is configured to only spawn a maximum number of processes then requests will be queued (I think the default is 150). In these cases then Apache is going to be just as slow serving up your error pages as anything else.

    What sort of time frame are you expecting these 30000 users to access your site over? Minutes? Hours? Days? A site I manage routinely handles a few hundred requests every second without Apache breaking a sweat, 30000 users is not necessarily an issue unless they all come at once (like in the same few minutes) - unless you are on a restrictive shared host of course, but then I wouldn't recommend hosting a site with that sort of volume of traffic on a shared box!
    The first rule of Tautology Club is the first rule of Tautology Club.

  3. #3
    Join Date
    Mar 2008
    Location
    Leeds
    Posts
    26
    Hi there, thanks for that. I'll be getting the hits over a series of minutes as the site will be selling tickets for a very popular event. Last year the site did go down and I know that in the server control panel (I'm on a share at the moment) there is a Maximum simultaneous processes setting. I know I'll have to move to a dedicated server as soon as but it's too late for this year. What should I do and how can I put the holding/splash screen up once I've hit this maximum?

  4. #4
    Join Date
    Mar 2008
    Location
    Leeds
    Posts
    26
    Just one thing I am on a share but it's an expensive share! Business Managed Server I from 1and1

  5. #5
    Join Date
    Mar 2008
    Location
    Leeds
    Posts
    26
    Actually - I have a server, not a share.

  6. #6
    Join Date
    Mar 2010
    Posts
    672
    If you're going to be receiving that much traffic over that short of a period i'd recommend having your hosting setup a load balancer between your current server another dedicated server. You can then load balance using the least connections method. This will also offer you failover if one of the servers die during this period.
    You'll have to check with your host to see what the price is and judge it it will be cost effective.

  7. #7
    Join Date
    Nov 2008
    Posts
    2,477
    If you are indeed on a dedicated box with reasonable hardware then I would imagine that 30k users over some minutes is perfectly ok with a properly configured server - obviously this is a very general statement, a lot depends on the specifics of you site obviously, and your users will, I'm sure, notice some slow down but I wouldn't have thought the server will give up the ghost all together. They key is in configuring it properly. Here is a snippet from my server's httpd.conf:

    Code:
    StartServers 32
    MinSpareServers 10
    MaxSpareServers 30
    ServerLimit 1024
    MaxClients 1024
    Now, this is a very powerful machine, but it will easily handle hundreds of requests per second. The key is the MaxClients (and ServerLimit since MaxClients cannot be > ServerLimit), however you can't just go raising this arbitrarily since if you use up all of the server's RAM Apache will start using the hard disk as mentioned above and that == sloooooow. You need to figure out how much RAM an apache process is using and make sure you have enough RAM to cover the MaxClients setting. You can do this via a shell with the following command (obviously change the httpd in the first grep if your server process is named differently):

    Code:
    ps -ef |  grep httpd | grep -v ^root | awk '{ print $2 '} | xargs pmap -d | grep ^mapped: | awk '{ print $4 }' | cut  -dK -f1 | awk '{ SUM += $1} END { print SUM/NR"KB" }'
    You can then divide your available RAM by this figure for a rough guide. Bear in mind though this is *available* RAM, ie after accounting for the other running processes, notably MySQL which is the biggest RAM hog on my server (so it may be worth making sure all your tables are nicely indexed too to save on resources consumed there).

    If you Google for "apache performance tuning" and similar I'm sure you will find lots of other resources too.

    IMO it will be far preferable if you can keep your server up. If it is overloaded, people are not going to get anything except error messages from their browser.

    BTW in case you are not aware of it, ApacheBench is a very useful tool for testing your configuration. You might also want to whip up a PHP script to hammer your server with HTTP requests and see how it copes with the load (just discard the response data).

    If tuning doesnt look like it will get you what you need, then I'd agree with the above and look into load balancing, but that is not without its own issues. Generally though you can get a lot from the LAMP stack by configuring it properly and not sticking with the default settings.
    Last edited by Mindzai; 03-26-2010 at 12:21 PM.
    The first rule of Tautology Club is the first rule of Tautology Club.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles