Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6076625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:37:45+00:00 2026-05-23T10:37:45+00:00

We have a php based web application and are expecting a big spike in

  • 0

We have a php based web application and are expecting a big spike in traffic in 2 days.

We are set up on a standard Rackspace LAMP stack and will throw as many servers at it as we can but the application is quite memory and db intensive so there will be some ceiling of max concurrent users that we will not be able to exceed given the small amount of time we have.

We have been working to implement memcached but due to the nature of the application it is proving difficult to do effectively.

The traffic is only expected to last for a couple of hours and our main concern is that the site doesn’t crash which would bring sales to a halt.

Whats the easiest way to display an error message that says “Sorry we are experiencing heavy traffic, please try again soon.” When the servers are experiencing too heavy load?

In this way we could serve our proper web application and then when the request queue starts to fill up then we can just serve the simple static friendly html traffic message.

I know that with a naive approach it will mean that some people who are just about to buy something will get the error message and then might have to go back to the beginning of the process, which isn’t ideal, but given the short time-frame we just need the site not to crash and stop sales. How do we do this?

Any help would be hugely appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:37:45+00:00Added an answer on May 23, 2026 at 10:37 am

    If by “heavy load” you mean CPU load this would be quite easy with sys_getloadavg(), an example:

    $load = sys_getloadavg();
    $cores = intval(trim(shell_exec('grep physical /proc/cpuinfo | sort -u | wc -l')));
    
    if ($load[0] > $cores)
    {
        // machine was under heavy load in the last minute
    }
    
    else if ($load[1] > $cores)
    {
        // machine was under heavy load in the last 5 minutes
    }
    
    else if ($load[2] > $cores)
    {
        // machine was under heavy load in the last 15 minutes
    }
    

    Depending on your available memory and the number of allowed PHP processes you might wanna just delay the response for a couple of milliseconds using usleep() instead of showing a “under heavy load” message. Be aware that while sleeping, the process is still eating your memory and web server threads so you need to be careful with this – you can delay the response depending on the load, i.e.:

    if (($load[1] / $cores) >= 1)
    {
       $delay = ($load[1] / $cores) / 10;
    
       if ($delay >= 0.5) // never delay for more than 0.5 seconds
       {
           exit('heavy load sorry');
       }
    
       usleep($delay * 1000000);
    }
    

    The higher the load, the higher the delay, this would give time for the CPU to catch up with all the work.

    If you’re running a distributed load balancer you might wanna keep these values in memcached, also storing the $cores variable in APC or similar will probably give you a performance boost.

    If you meant other kind of load (like users or memory) the logic is similar, all you need to worry about is to get the relevant metric and store it, either on APC or memcached if you need distributed logic.

    PS: ServerFault might be a better place to ask this kind of questions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a complex input form within a PHP based web application. To structure
I have a PHP based web application which is currently only using one webserver
I have developed a PHP-MySQL web application, which is a school-based project. My client
I have a PHP-based web application that monitors the status of a process and
at work we have a web-based PHP-application which acts as the single UI that
I'm developing a PHP-based web-application in which you have a form with textarea inputs
I have a C# application that communicates with a PHP-based SOAP web service for
I need to have my PHP application (its a stand alone, not web-based) connect
I'm working on a class-based php web app. I have some places where objects
I am creating a PHP based web application which requires simple authentication to use.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.