Thursday, February 20, 2014

Akamai & ATG

Now a day most of the ATG site uses the Akamai server, as it is key component in decreasing the page load time and maintain the server load and performances. This blog is about how to integrate ATG site & the Akamai.

What is Akamai, Why to use it, how does it work?
                Akamai is the service provided by the Akamai Company. It has several servers across the globe.   Servers are used to serve the static content of the request from that region.

Akamai serve the request from the server which is in the same region, it will server request faster by save the data transfer time and as it server the stored data, so computing time is removed. The Akamai servers are present across globe, which have data stored in them for the static content like JS, CSS, Image and even dynamic data like JSP request.

                When even a request is made to server it is go to the respect regional Akamai servers. Akamai server check cached response for the request which is made by the user in it stored cache data. Akamai maintains cache of the responses which are sent by the main server (ATG server) in reply of the request. The cache are stored as a value for the key, where key is made up of combination of request URI and selected parameters. The values in cache are refreshed on timely basis, where time is sent to expire by the main server. When a request is made to Akamai server where the request is not found in cache of Akamai server, than it in turn pass the request to main server, where the response is cache at Akamai and also server to user. The picture shows layer diagram of the request and position of the Akamai server.

Request & Response flow using Akamai server

What happens to the secured data which should not be cached?
                Akamai just cache the response of the get request and not for post request, where post request contain the data which is in response to some update data at server side.
Akamai will not even cache the HTTPS request, as it mains some secured data which is between the server and the user. We should make sure that the secured data is transferred with the HTTPS protocol. Or else Akamai we can configure Akamai not to cache a set of URIs.

How can we use Akamai more efficiently where set of block in response changes with every request?
Akamai reads response as combination of the different blocks. We can set cache time different for each block and only data of that block is refreshed and not the whole response. Even we can set not to cache a particular block in html response. So each time a request is made only that block as requested to main server and the response is combined with store data at Akamai and will be server to user.

What are ESI Tags?
ESI Tags are like HTML tags which are sent as part of the response to Akamai request. ESI tags are read and interpreted by the Akamai server and appropriate actions are taken accordingly.  
                Main the ESI tags are used to define the blocks and set the cache time for the block. It also contains the URL which should be is used with just get the data for that block which can be embedded and sent as one response for the user request.

Eg. <esi:include src="/contextroot/jsp/abc.jsp" ttl="256" onerror="continue" maxwait="60" no-store="ture|false"/>

S.No
Attribute

1
Scr
JSP URL to get the block data which can be embedded in stored response.
2
ttl
Cache expire timing.
3
onerror
What to do when the block return error page.
4
Maxwait
Max waiting times for get the block data.
5
no-store
Should store the block or should not.

Note:
  • The response sent to user will not contain any of the ESI Tag, basically the Akamai replace the ESI tag with appropriate block of data.
  • Cache expire time can be set as part on response header as expire time :

How to code better to integrated Akamai efficiently?
  • When we design/code the JSP we should make sure that entire JSP should not be in a single file. Instead we should create different JSP for each block in the page layout and all the JSP are included in one to form the completed page. It will also easies in maintain the JSP code and make it more readable. The block can be reused if the same is to be displayed in other page layouts.

  • JSP Design
  • We should make sure that the including JSP just requires only the parameter to be passed and should not depend on main JSP getting executed every time.
    For example: Internal JSP used Object which gets create parent JSP gets executed.
  • Parent JSP should not pass any object as parameter as in ATG we can pass the object as request parameter.

2 comments:

  1. Very informative for both audience, who knows and who are new to Akamai with ATG.

    ReplyDelete
  2. Informative .. Keep up the good work ...

    ReplyDelete