• 7

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

When to show a fail whale?

How or when do I know my Web Application can't handle the traffic/activities and show a "Fail Whale" kind of page?


You could try sys_getloadavg() if you just want to show an error when the server is under high load.

    $load = sys_getloadavg();
    $max_load = 95;

    if($load[0] >= $max_load){
        // Show failwhale
        // Do stuff
  • 8
Reply Report
      • 2
    • This is a pretty good solution. Do some stress testing of the server to find out what kind of load it can handle to give you an idea of what your max is.
    • Yes. This is a good one. Now I'm wondering how to get the idea of the max value?? Anyway Thanks @Joseph W

If your web server is unable to get a valid response from another important server, whether it's a key web service, an authentication server, database server, etc., that seems like a good time for something like a fail whale.

  • 3
Reply Report

This is something I've discussed with colleagues in the past. You can't predict when traffic is going to be too high. Eventually you're server will just fall over. Potentially you could have the server start up with the "fail whale" page and have some kind of switch over to your operating site. Then if your server went down under load it could automatically come back up with the "fail" page.

Your server can't handle traffic anymore when it fails... that's where the difficulty lies in identifying. Matt V's answer would work but you would have to add some kind of heartbeat check and it would still be a manual process to interrupt the "OK" response.

  • 3
Reply Report
      • 2
    • Oops. I was actually going to say I didn't think that Twitter showed a fail whale because of a DOS-type problem (which is, understandably, difficult to respond to), but because Ruby wasn't "robust" enough to handle the load. As I pointed out, if the server can't respond, or is responding but can't get through, that's a difficult problem to address. But, there can be other problems within the server container that may lend them to show a "site error" as some recovery goes on (even having Apache respond if the server is not running correctly). However, I hit add comment by mistake.
    • @Jared Farrish Fair enough :) If it was some problem other than a DoS potentially the server could respond automatically with a default static page. I would be interested to know exactly how to configure that... However for a DoS style failure, attack or otherwise, I don't know that any kind of automatic failsafe could be put in place without the server inevitably restarting.
    • Which is why I focused on the "application" part, and not the "web". Joseph W's answer is the easiest for the 503 error state, but that only covers one of some of the other issues that would need to be handled. RunKeeper.com just had such an issue the other day, for instance; the server kept responding, but every page returned the error. They show a plug/smiley face thingy, if I remember correctly.

Since you would need to look a variety of issues, I would say start at error handling:


Look into your database vendor's connection documentation (such as too many connections); here is MySQL:



Assuming your server can respond to the load (and the user doesn't get a 408 Request timeout), it should be something detectable within your code, not something wrong within the perimeter of the server itself (server out of memory, for instance). You could also have other timeouts occurring, for instance a web service that is slow in responding or whatnot.

Also, if you get it figured out, drop a line to the Facebook team.

  • 1
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions