Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
Handling failures / absences of your backend server nicely

It's good for your website to put a professional smile on it's face, even when it's having problems with its backend!

On high traffic sites (for example - TV show and news sites), backend servers can occasionally get overloaded and you'll want your web site visitor to get a message to that effect, rather than a failure. If the feed is a regular news feed, you might even be able to respond with the latest (cached) news if it's less that a few minutes old, and your user will be none the wiser!

Here's a demonstration of one way to do this - setting up a front end Apache httpd to divert requests it would normally pass on to a proxy to a local PHP script if the proxy is not available. Simply add something like
  ErrorDocument 503 "/proxydown.php"
into the httpd.conf file, a file it includes, or an appropriate .htaccess file.

Then within that PHP script, you can force a 200 (OK) header to be returned:
  header("HTTP/1.1 200 OK");
and the PHP script can work out what's running, and what was asked for:
  $requested = $_SERVER["REQUEST_URI"];
  $gotinstead = $_SERVER["PHP_SELF"];
may give when you print out those variables
  You called for /dryfeet but it is not available
  You got instead /proxydown.php

This example is a demonstration which I've written to show the sort of thing that can be done when perhaps you have httpd fronting a number of Tomcat servers, and you want the httpd to catch and control any times that it fails to contact a Tomcat. The complete demonstration is [here] - that's a basic framework into which you can add logging, caching, emailin the system adminsitrator if the problem persists, and lots of other facilities.
(written 2013-02-08)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
A655 - Web Application Deployment - Using Tomcat and Apache httpd Together
  [3018] Tuning Apache httpd and Tomcat to work well together - (2010-10-27)
  [2482] Load balancing with sticky sessions (httpd / Tomcat) - (2009-10-29)
  [1944] Forwarding session and cookie requests from httpd to Tomcat - (2008-12-14)
  [1940] URL rewriting with front and back servers - (2008-12-14)
  [1938] Predictive Load Balancing - PHP and / or Java - (2008-12-13)
  [1771] More HowTo diagrams - MySQL, Tomcat and Java - (2008-08-24)
  [1552] Extra public classes in deploying Apache httpd and Tomcat - (2008-02-24)
  [1549] http, https and ajp - comparison and choice - (2008-02-22)
  [1383] Monitoring mod_jk and how it is load balancing - (2007-10-07)
  [1376] Choosing between mod_proxy and mod_rewrite - (2007-10-02)
  [631] Apache httpd to Tomcat - jk v proxy - (2006-03-03)
  [576] Why run two different web servers - (2006-01-25)
  [436] Linking Apache httpd to Apache Tomcat - (2005-09-05)

A657 - Web Application Deployment - Using httpd to front Tomcat
  [2483] Clustering on Tomcat - (2009-10-30)
  [1939] mod_proxy_ajp and mod_proxy_balancer examples - (2008-12-13)
  [1566] Strange behaviour of web directory requests without a trailing slash - (2008-03-06)
  [1377] Load Balancing with Apache mod_jk (httpd/Tomcat) - (2007-10-02)

H307 - PHP - Web2 and caching
  [4627] Caching results in an object for efficiency - avoiding re-calculation - (2016-01-20)
  [4136] How do I post automatically from a PHP script to my Twitter account? - (2013-07-10)
  [4106] Web server efficiency - saving repetition through caches - (2013-05-30)
  [4075] Further recent PHP examples - (2013-04-28)
  [4055] Using web services to access you data - JSON and RESTful services - (2013-03-29)
  [3955] Building up from a small PHP setup to an enterprise one - (2012-12-16)
  [3458] On this day ... one PHP script with three uses - (2011-09-26)
  [3186] How to add a customised twitter feed to your site - (2011-02-27)
  [3094] Setting your user_agent in PHP - telling back servers who you are - (2010-12-18)
  [3029] PHP data sources - other web servers, large data flows, and the client (browser) - (2010-11-04)
  [2545] Scraping content for your own page via PHP - (2009-12-21)
  [2321] Uploading and Downloading files - changing names (Perl and PHP) - (2009-08-04)
  [2196] New Example - cacheing results in PHP for faster loading - (2009-05-24)
  [1995] Automated server heartbeat and health check - (2009-01-16)
  [1926] Flash (client) to PHP (server) - example - (2008-12-06)
  [1814] Javascript/HTML example, dynamic server monitor - (2008-09-28)
  [1813] Ajax - going Asyncronous and what it means - (2008-09-28)
  [1812] Starting Ajax - easy example of browser calling up server data - (2008-09-27)
  [1733] memcached - overview, installation, example of use in PHP - (2008-08-02)
  [1647] Exchange Rates - PHP with your prices in your users currency - (2008-05-19)
  [1633] Changing a screen saver from a web page (PHP, Perl, OSX) - (2008-05-06)


Back to
Travelogue - from the Netherlands to London via Hook and Harwich
Previous and next
or
Horse's mouth home
Forward to
9 years, and 4000 articles on
Some other Articles
Web and console - same principle, same code - Ruby example
Images of Melksham you havent seen before
Helping search engines with appropriate 400 error codes
9 years, and 4000 articles on
Handling failures / absences of your backend server nicely
Travelogue - from the Netherlands to London via Hook and Harwich
Servlet v JSP (Java Server Page). What is the difference?
Tips on Tomcat - moving applications around
Onward from Brussels
On board Eurostar - a running commentary
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/3999_Han ... icely.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat