1

I have three web server using nginx as frontend and php-cgi as backend.
We use DNS round robin to distribute load. In this server we have several PHP applications, each application is stored in its own folder.

We have a large amount of potential users (employee headcount about 20000).

Each application is being maintained by different team and consequently may be using different PHP frameworks. When one of the application has a badly written page, php-cgi instances could became stuck. When enough person accessed the 'bad' page, the entire three servers could became stuck.

Is there a mechanism to determine which PHP application has bad page problem ?
If I could determine which php page is being run by a php-cgi process, I could determine which app the page belongs to, and I could deactivate the problematic app instead of watching the entire system going down.

The problem is I haven't find out how to monitor which page is being run (and still stuck). If there is only one app and I could change it, I would insert log statements upon the start and end of the front controller. Having more than 6 apps make this method not practical anymore.

0

2 Answers 2

1

If each application is using different virtual host name,
just make sure one log file per virtual host

Also, you can make use on the URL path

SetEnvIf Request_URI /SOME_PATH_1 apps_1
SetEnvIf Request_URI /SOME_PATH_2 apps_2

CustomLog logs/apps_1.log env=apps_1
CustomLog logs/apps_2.log env=apps_2

There must be some global environment variables that uniquely identified each application. .

Also, you can consider to set the lower script timeout.
Append the processing time for each apache request into log file could be helpful too.

1
  • Unfortunately I used nginx, not apache. Thanks for the idea, I'll try to find out how to do this in nginx. Sep 9, 2011 at 7:28
0

Here's something that might work. At the top of every PHP file on all the sites, include a line of code that writes "SITE1_ERROR" to a one-line-long text file that all three site scan point to on the server.

At the bottom of each PHP file, make a line of code that writes to the same text file and overwrites "SITE1_ERROR" with "SITE1_WORKING."

Then, since the PHP page is processed top to bottom, if the page is never finished processing (due to an error) at least the text file will be updated to show which site has an error. If there is no problem at all, the text file should always read "SITEX_WORKING" where X is the unique identifier # of the site.

There probably is a better way than this, but why not give it a show? Worst case you're writing to a text file twice for each successful PHP page call. And if simultaneous read/writes to the one-line text file is an issue or too hardware taxing/time wasting, perhaps a MySQL table record update or something would be more efficient, as long as all three sites can share the same DB table.

1
  • I have about 16460 php files - So after more thorough examination some of the apps are not 'small'. And I think this solution is just not feasible for servers having multi apps & a lot PHP files. Sep 14, 2011 at 9:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .