4

Twitter sometimes shows an message: Twitter is over capacity

This is to prevent too much pressure on the servers. Which avoids that the servers go down.

How do I implement this in my application?

Edit: I am NOT looking for a PHP specific solution.

Wouter Dorgelo
  • 11,770
  • 11
  • 62
  • 80
  • The best way is to use a non-blocking server (AKA: not Apache) so you won't really be put in this situation with sane levels of traffic... Then this becomes a non-problem (again, for sane levels of traffic). If it does start becoming a problem, you can simply implement a 500 error handler to show the pretty page... – ircmaxell Nov 16 '10 at 15:30
  • read the following http://php.net/manual/en/function.memory-get-usage.php – Oliver M Grech Nov 16 '10 at 15:31
  • 3
    @Oliver: That returns the memory usage of the current process or thread (worker model and operating system dependent), and really has no bearing (as far as I can tell anyway) on the overall system load. You'd need to use something like [`sys_getloadavg`](http://us.php.net/manual/en/function.sys-getloadavg.php) for that... – ircmaxell Nov 16 '10 at 15:33
  • Isn't that PHP specific? – Wouter Dorgelo Nov 16 '10 at 15:48
  • 1
    If you are not looking for a PHP specific solution, use a load balancer and determine when to give the use your failanimal of choice – Gordon Nov 16 '10 at 15:53
  • @Enrico: That comment was made when the question was still tagged with `php`, so it was relevant at the time... – ircmaxell Nov 16 '10 at 15:57
  • @ircmaxell, yea, sorry about that.. I retagged it. – Wouter Dorgelo Nov 16 '10 at 15:58

1 Answers1

1

I thing this can be easily achieved by using a separate software to watch the server status, and on to much pressure, show the specified message. This is very important in a cloud architecture, so you can easily launch new instances. I think Amazon uses CloudWatch for this. Also, you could use apache mod_status to watch the server, also using a separate software.

Hope this helps, Gabriel

Gabriel Croitoru
  • 133
  • 2
  • 10