Jmeter Cache manager videos - jmeter

We want to learn about cache manager how can be used in jmeter.. and cookie manager too.

You can read more about Cache Manager at:
http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cache_Manager
https://blog.flood.io/understanding-the-jmeter-cache/
And for Cookie Manager:
http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cookie_Manager
To use them, just add them to your Test Plan and configure them as per documentation depending on your test case.

Related

How to simulate the browser load in JMeter?

We need to test our web application with 100+ users with JMeter tool.
Should we use JMeter webdriver plugin to launch the real browsers or can we use the blazemeter plugin to generate the script and run in JMeter? Will the script created with blazemeter simulate the real browser load?
Theoretically you can use real browsers, but be aware that browsers are very resource intensive so my expectation is that you will need at least one CPU core and at 1 GB of RAM per browser instance in order to have enough resources.
This means you will have to go for distributed testing and on average you will have one slave per 5 browsers. If this is something you can afford - go for it. If don't - be aware that you can configure JMeter to behave like a real browser, to wit:
Tell JMeter to Retrieve All Embedded Resources from HTML Files and Use concurrent pool of 6 threads. This can be done using HTTP Request Defaults, the settings live under "Advanced" tab
Add HTTP Cache Manager to simulate browser cache
Add HTTP Cookie Manager to mimic browser cookies
Add HTTP Header Manager to send browser-like headers (i.e. User-Agent, Accept-Encoding, etc.)
If your application uses AJAX requests - put the relevant HTTP Request samplers under the Parallel Controller

Replicate browser and user behavior with JMeter

I am new on JMeter and would like to get insight on how to replicate browser and user behavior in JMeter.
What is the best practice when using JMeter to test web application (mainly for httpd, php, angular etc)
i.e from some reading documentation I should use timer to delay each sampler for more realistic use case
after reading JMeter documentation, I still have some confusion about:
HTTP Request configuration:
- should we use Java instead of HTTPClient4?
- should we enable embedded resources from HTML files?
Cookie Manager:
- should we keep or clear cookies on each iteration
Cache Manager:
- should we clear cache on each iteration or keep it?
- should we use cache-control header?
- what is the best value for max number elements in cache?
Where i should put cache manager, cookies manager?
Under test plan or under thread group if i have more than 1 thread group?
How to configure keepalive in JMeter sampler or header manager?
My use cases is to replicate 10 concurrent unique user accessing a web application
HTTP Request configuration:
should we use Java instead of HTTPClient4? - The recommended implementation is HTTPClient4, this way you will be able to use DNS Cache Manager, HTTP Authorization Manager with Kerberos, etc.
should we enable embedded resources from HTML files? - Of course, but make sure to exclude "external" ones which are not related to your application, i.e. fonts or scripts which reside in other domain. See Web Testing with JMeter: How To Properly Handle Embedded Resources in HTML Responses for more information.
Cookie Manager:
should we keep or clear cookies on each iteration Depending on your scenario, for example if it starts from login and ends with logout - it makes sense to clear the cookies to represent "clean" session
Cache Manager:
should we clear cache on each iteration or keep it? Depending on your scenario, like Cookie Manager
should we use cache-control header? Depending on how caching is implemented in your application under test
what is the best value for max number elements in cache? It needs to be sufficient to keep all cacheable content in your application. You can clear i.e. Chrome browser cache, execute your test scenario manually, open chrome://net-internals/#httpCache URL and see how many Entries do you have. Amend this setting to be equal or a little bit more
Where i should put cache manager, cookies manager?
Under test plan or under thread group if i have more than 1 thread group? These "managers" obey JMeter Scoping Rules, if you put them under Test Plan -
they will be applied to all Thread Groups, if you put them under Thread Groups - they will be applied to current Thread Group only
How to configure keepalive in JMeter sampler or header manager? - If you tick Use KeepAlive under HTTP Request sampler - it will AUTOMATICALLY add Connection: keep-alive header. If you untick it - JMeter will send Connection: close header. Don't use HTTP Header Manager for amending Connection header value

How can I cache network data in service worker?

I have created Progressive Web Application (PWA) with angular 5.0 and .net core 2.0. It works fine in offline mode. But only static data are cached for offline mode. I need to store previously requested network data in service worker cache, so that I can fetch these data through service worker cache in offline mode.
You can use also angular service worker for it.
Data Groups - Cache External API Data
The data groups config allows you to cache external API calls, which makes it possible for your app to use an external data source without a network connection. This data is not known at build-time, so it can only be cached at runtime. There are two possible strategies for caching data sources - freshness and performance.
api-freshness - This freshness strategy will attempt to serve data from the network first, then fallback to th cache. You can set a maxAge property that defines how long to cache responses and a timeout that defines how long to wait before falling back to the cache.
api-performance - The performance cache will serve data from the cache first and only reach out to the network if the cache is expired.
Example you could find here in section ngsw-config.json.
Try to check HTTP Caching.
All you need to do is ensure that each server response provides the
correct HTTP header directives to instruct the browser on when and for
how long the browser can cache the response.
For further info, you can check the whole documentation. It provides example and illustrations to understand better about HTTP Caching.

How to login a large number of users in Jmeter?

I have a project and need to test a large number of of users in Jmeter but the problem I am facing is how to login lots of users, it will be tedious for me to enter their data manually and the token.
Can we remove or bypass the session id/token? So I won't need to input it manually. Is there any simple way to login lacks of user so I can test the load and stress testing. Or is there any other open source tool in which I test this?
I think you should read the Apache JMeter User Manual first.
You work around to be like:
Try to record only one user login session using the Apache JMeter HTTP(S) Test Script Recorder.
Use CSV Dataset Config to pass all your login credentials in JMeter.
Add a Cookie manager in your test plan.
Use regular expression extractor or JSON path processor (Depending on your request type) if you need bypass any data in your subsequent request. Check this article.
You won't be able to simulate one lack users from your machine I guess.Actually, it depends on your hardware configuration. So check for the Distributed testing.
You have run your test in Non-GUI mode. You can use GUI mode for the only debugging purpose.
Do not add any listeners when you perform your load test since they consume more memory.
Try to tweak your JDK heap size accordingly.
Try to use updated JMeter version and JDK both.
It actually depends on your application design, for instance if usernames are matching some pattern like:
user1
user2
user3
etc.
you should be able to just add __threadNum() function as a postfix
If your users are present in a database table you can use JDBC Test Elements to read usernames from the database
When it comes to logging in, it is not about single request which performs login operation, your web application test must always represent real users using real browsers as close as possible, so the login flow should look like:
Open Login Page
Extract token using one of JMeter Post Processors
Perform login providing credentials and the token from the previous step
More information:
Building a Web Test Plan
Building an Advanced Web Test Plan
How To Login Into A Web Application with JMeter

Persist the (Set Cookie) JSESSIONID throughout a TestPlan in jmeter

I have to test the webserver which has to maintain sessions. For this purpose I need to maintain session ids in jmeter. It has been working for ThreadGroup as I am using HTTP Cookie Manager for every Thread Group.
But i want to use the same JSESSIONID across the test plan which includes several Thread Groups. Not able to achieve this. I tried using HTTP Cookie Manager globally for a Test Plan, but it didnt work.
I am using jmeter 2.5 version.
Can anybody help me with this?
You might want to try this in the current 2.9 release, it seems to have been improved a lot.

Resources