I have been running on Jmeter from past few weeks. There is no end-to-end use case in my Jmeter tests (e.g. login >> go to profile page >> logout). I am simply hitting few important pages of my application directly. e.g. Registration page, Home Page, About Us etc.
How these pages are served:
Scenario 1: User >> Akamai >> Server >> Akamai >> User
Scenario 2: User >> Akamai >> User (i.e. after all pages cached in Akamai)
There are 99% chances that when I run Jmeter tests, they are getting served from Akamai i.e. Scenario 2.
Questions:
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?
Only if answer to #1 is Yes: Is this mandatory/optimum to use cache manager with cookie manager?
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:
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
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.
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:
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:
Cache-Control header (max-age directive)
ETag header
Last-Modified header
Expires
Following are the references to start with:
http://dev.mobify.com/blog/beginners-guide-to-http-cache-headers/
https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching
https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
Related
I've configured 1 thread, loop count 2 and Aggregate Report as a listener with some http request sampler. Caching is enabled. When I run my test plan I get only one sample of each request in Aggregate Report. Some Cached requests are not even hitting second time to server whereas for some are getting executed again. Can anyone explain what settings I need to configure for getting report of all request samples. Thank you in advance.
please find image of result here
This is by design, JMeter's HTTP Cache Manager respects Cache-Control headers like Etag and If-Modified-Since so on second requests embedded resources like image, scripts, fonts, styles are being returned from cache, no actual request is being made. This is what real browsers would do.
If for any reason you want all requests to be executed each time you need to:
Tick Clear cache each iteration box in the HTTP Cache Manager
Remove Loop Controller from the Test Plan
Set desired number of loops on Thread Group level
See Using the HTTP Cache Manager for more information on embedded resources caching if needed.
My Application is using CDN which is a caching server. Now when I use JMETER for recording the functional flow. Browser doesn't load any CSS,JS or image being cached at CDN server. Removing CDN is alo not good option because I need to judge performance with CDN in place. Please Guide
JMeter records only HTTP requests sent by browser, so if you have already visited this page your browser may already have these resources in its own cache therefore it doesn't send actual requests. If you want these requests to be recorded - you should clear your browsing history and especially delete cache. The procedure differs from browser to browser so check your browser documentation for details or check out How do I clear my web browser's cache, cookies, and history? article.
In general you should not be recording these calls as real browsers download these images, scripts and styles using concurrent thread pool, i.e. one main request followed by parallel requests to get the resources. The same behavior can be set up in JMeter using "Advanced" tab of the HTTP Request sampler (or even better HTTP Request Defaults, this way the setting will be applied to all HTTP Request samplers in scope)
I accepted the Security certificate for CDN server through browser only. And problem was solved.
I am getting Result as Cache for particular request in Httpfox and type as application/json
Real browsers download embedded resources like images, scripts, styles, asynchronous requests results, but do it only once. During subsequent requests aforementioned entities are being returned from the browser cache.
JMeter provides HTTP Cache Manager in order to simulate above behavior.
I think that you might also like to add the following test elements to your test plan to make your JMeter test even more realistic:
HTTP Cookie Manager - to represent browser cookies
HTTP Header Manager - to send browser headers like User-Agent
Configure HTTP Request Defaults to download embedded resources using thread pool as per How to make JMeter behave more like a real browser guide
What is the use of HTTP Cache Manager and HTTP Cookie Manager
and how it performs if we enable/disable the options to clear them in each iteration?
Both are to make load test more realistic.
HTTP Cookie Manager - holds cookies which usually are being used for identifying user session including login information.
HTTP Cache Manager - represents browser cache. Real browsers download different embedded stuff like images, styles, scripts, etc. during rendering web page but do it only once or based on what specific cache control headers tell.
Clear above each iteration - if enabled new test cycle starts "clean" i.e. each virtual user will have to log in, fetch all the data, etc. so it'll look like a new user to the system under test. If disabled - it'll just be another test iteration for the same virtual user
So if your idea is to make your test more close to real browser testing you need to use above test elements in combination with HTTP Header Manager and configuring HTTP Request Defaults to tell all the HTTP Samples to download embedded resources and use concurrent pool of 2-5 threads for it.
You should read those 2 docs:
http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cache_Manager
http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cookie_Manager
Question?
To stimulate browser behavior more realistic do we have to enable "Use Cache-Control/Expires header when processing get request"? during Load Test.
I am asserting the response for get request. If is use this then is there any chance for me to get null response?
I was confused with the detail gathered?
I am testing particular application using JMeter 2.9.There My test plan is Thread group--> Transaction Controller.Inside that various recorded requests are there.I am using HTTP request defaults,HTTP Cookie manager and HTTP header manager,and a view result tree for validation.I found one token i.e. CSRF token to be correlated and I did correlation.But for a particular request I am finding "Session expired..Login again" response much before the logout request.My transaction flow is to Login--> Search a content-->Logout.
Please help me finding a solution.
Try put the element: HTTP Cookie Manager in Thread Group, first item.
the problem can be in the following areas:
-you were redirected automatically instead of following redirects
-login hasn't succeeded
-the session id has not been successfully passed on to the request after login
The JMeter documentation states this:
I've set up JMeter to sample the same URLs as my browser, why is JMeter not seeing the same responses?
There are various different reasons for this:
Cookies - make sure you added a Cookie Manager. Browsers process cookies unless you set them up otherwise, but JMeter does not process cookies unless you add a Cookie Manager.
User-Agent - the User-Agent is a header that is sent by browsers; it identifies the browser type. Some servers are sensitive to this setting and generate different results for what they think are different browsers. The Header Manager is used to add headers such as User-Agent.
Hidden fields - if you did not use the JMeter Proxy (or other application) to record the test plan, then it is easy to miss hidden fields from forms.
Dynamic field names/content - some servers use varying names for fields. So although the test plan may be correct at the time of creation, it does not work when replayed.
URL rewriting - TBA
from http://wiki.apache.org/jakarta-jmeter/DifferentBehaviour