Gunther Kochmann

How to Setup a Custom Failover for logged-in Users (via Property Manager)

Blog Post created by Gunther Kochmann Employee on Dec 30, 2015

Imagine this use-case, which I recently came across:

 

  • anonymous users shall receive a cached version served from Akamai Edge servers (if any exists)
  • authenticated users shall be treated as follows:
    1. When backend/origin is responsive (e.g. no HTTP5xx or origin timeout): never serve a cached object, but fetch content by forwarding request to origin servers (cached objects for anonymous users must not be expunged from Akamai caches!)
    2. In case backend/origin is down (in fact the situation is contrary from 1.): serve cached version from Akamai Edge server (which is anonymous/not personalized and meant for all users that are not logged-in)

 

How did we solve this?

 

  • Default rule must have the following:
    1. Origin behavior - 'Cache Key' set to 'Origin Hostname' *)
    2. Caching behavior - 'Serve stale if unable to validate' must be turned on **)

 

origin.JPG

 

  • Introduce a new rule which contains a criteria that matches for logged-in users (e.g. presence of a particular cookie, like 'SESSION' or similar as in this case:
    • Note that Akamai Edge will not be able to validate the SESSION cookie value, this must be done at the origin still, where requests are forwarded to for logged-in users (or those that present such a cookie)


session.JPG


  • Add a child rule to this one, where you trigger/match on the hostname NOT being the (fake) failover hostname failover.mrcustomer.com (which in the end means we are not in failover mode)


not-failover.JPG


  • Below this rule two other child rules will be required:


    • set 'bypass cache'


by-pass.JPG


    • and another one that matches on origin issues (5xx, origin timeout) and then initiates Site Failover to the 'fake' or 'alternate' hostname 'failover.mrcustomer.com'


failover.JPG


In the end this means that requests for the 'fake' failover hostname 'failover.mrcustomer.com' will never trigger failover (which would be useless) or by-pass Akamai caches. On the other hand, we want all that to happen for the real (public-facing) hostname 'www.mrcustomer.com'.


The structure for the failover would look like this:


structure.JPG


For easier testing the following can be built in:


  • a new rule that will break any forward connection and hence simulate an origin issue


simulate.JPG


  • additional cache-key query string behavior in the default rule to make this fully work


cache-key.JPG

 

*) If this were not the case, then objects for the regular hostname www.mrcustomer.com and the failover hostname 'failover.mrcustomer.com' would not share the same object in cache and serving stale for failover.mrcustomer.com would not work.

**) This is important because otherwise Akamai Edge would not be allowed to serve stale content at if origin is not responsive.

Outcomes