简体   繁体   中英

Akamai and Jmeter cache manager

I have been running on Jmeter from past few weeks. There is no end-to-end use case in my Jmeter tests (eg login >> go to profile page >> logout). I am simply hitting few important pages of my application directly. eg Registration page, Home Page, About Us etc.

How these pages are served:

Scenario 1: User >> Akamai >> Server >> Akamai >> User

Scenario 2: User >> Akamai >> User (ie after all pages cached in Akamai)

There are 99% chances that when I run Jmeter tests, they are getting served from Akamai ie Scenario 2.

Questions:

  1. Do I need HTTP Cache manager for Scenario 2? I mean Why do I need pages cached twice once at Akamai and same time on my machine's RAM?
  2. Only if answer to #1 is Yes: Is this mandatory/optimum to use cache manager with cookie manager?
  3. Only if answer to #1 is Yes: My scripts are written as: Test Plan >> Thread group >> Throughput Controller >> 80+ HTTP Request Sampler (actually pages) . So do I need HTTP cache manager at throughput controller level or at inside each HTTP Request Sampler? 在此处输入图片说明

When you are doing Load Testing you must represent the real users as close as it is possible, otherwise your load testing does not make sense. So with regards to your questions:

  1. Yes, you need to add HTTP Cache Manager to your Test Plan. Moreover, you need to "tell" all HTTP Request samplers to

    • "Retrieve All Embedded Resources"
    • and use "Parallel Downloads" for this

    The best way of applying this configuration to all the HTTP Request samplers is using HTTP Request Defaults

  2. HTTP Cache Manager and HTTP Cookie Manager are different beasts, but given you are building a web test plan, you need to add a cookie support .

  3. You need to have HTTP Cache Manager/Cookie Manager per each Thread Group . See Scoping Rules user manual chapter for details.

Also don't forget to use HTTP Header Managers to represent browser headers.

From your question, I understand that Akamai is a CDN where static pages are served.

Keeping this in mind, my answer is as follows:

  1. Do I need HTTP Cache manager for Scenario 2? I mean Why do I need pages cached twice once at Akamai and same time on my machine's RAM?

Yes Or No. Depends on the configuration you want to achieve. You must understand the difference b/w pages served by Akamai (CDN cache) is different from the pages stored locally on the user's machine.

Local cache - fastest way of retrieving the page. (achived by Cach-Control: max-age directive). If specified, there is NO need to even hit the Akamai server. Browser fetches the page from local cache itself. If max-age is expired, then browser sends a revalidate request to check whether it has the latest copy. CDN/Server validates it and if the copy is latest, then sends 304 (not modfied). otherwise, the latest copy of the page served with new max-age (max-age is send only if implemented).

So, the point is how the server is configured to deal with Cache. If local cache is implemented using Expires/Cache-Control, then you must add HTTP Cache Manager to the Test Plan.

2. Only if answer to #1 is Yes: Is this mandatory/optimum to use cache manager with cookie manager? Normally, Cache is independent of the user. Cookie manager is to make the user genuine by sending Cookies. Cache Manager to reduce the network latency (round trips) while loading the page. If cache mechanism implementation varies for logged in Vs anonymous users, then you must consider both the cases. Otherwise, Cookie manager is not required.

3. Only if answer to #1 is Yes: My scripts are written as: Test Plan >> Thread group >> Throughput Controller >> 80+ HTTP Request Sampler (actually pages). So do I need HTTP cache manager at throughput controller level or at inside each HTTP Request Sampler?

Generally, you add the HTTP Cache Manager at the top of the hierarchy (under Test Plan or Thread Group), so it will be applicable to all the Samplers (children).

Note: I strongly suggest to understand the application behaviour at HTTP level (in which JMeter works) using Browser -> F12 -> Network tab . This gives each and every HTTP request sent to load the browser, and resposne is retrieved from local cache or CDN or the server etc.

Please go through the following headers to completely understand the behaviour:

  1. Cache-Control header (max-age directive)
  2. ETag header
  3. Last-Modified header
  4. Expires

Following are the references to start with:

  1. http://dev.mobify.com/blog/beginners-guide-to-http-cache-headers/
  2. https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching
  3. https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM