Categories: Uncategorized

Show a “We are Busy” page when your server is too busy by using PHP

If you are apache fan. You shold have many virtual host in your apache conf. But after your site getting popular, sometimes your server can not handle all request and your visitor will have to wait in front of the browser.

I could not find a nice solution for that so created one.

First, create a html page that will be shown when your server is busy.





We are busy



Many visitors are accessing my server or I'm encoding some movies on the server.

Wait just a few second and reload.

Save above file as “/phpGlobal/busy.html”. The directory can be anywhere as you like.

Next, create a php that check whether my server is heavy.


Save above as “/phpGlobal/check.php”
This will show “busy.html” when the load avarage exceeds 3.

Next, add this line on apache2.conf or your conf file.

php_value auto_prepend_file /phpGlobal/check.php

NOw when you restarts apache2. “check.php” will run before any php requests.

check.php uses UTF-8 that will disturb with your character code of your environment.
In that case, try to consider adding these lines to check.php.

@ini_set ( 'default_charset' , '');
header ('Content-Type: text/html; charset=UTF-8');

At last, you can see a current load average by using “top” command. At top right corner of the command output.

admin

Recent Posts

Obtain global IP in bash

In current Internet environment, every PC is assigned a private IP. If global IP is…

3 years ago

Create log file in the directory of the script in Python

__file__ is the script file itself. From python3.9 above, it is an absolute path, otherwise…

3 years ago

RichTextBox’s font changes automatically in C#

You need to clear these two flags IMF_DUALFONT and IMF_AUTOFONT to keep font unchanged.

3 years ago

Test post to check image URL

This is an image inserted by wordpress 'Add Media'

3 years ago

msbuild says ‘target does not exist’

I don't know what is going wrong but... How to fix it Open the solution…

3 years ago

Creating a break point that hits on calling win32 api

Create a break point that hits when CreateProcess was called Enter a Function Breakpoint Enter…

4 years ago