How do I make jmeter use the same hostname/port for all HTTP requests in a thread, but different values for each thread? - jmeter

I am testing a clustered application, and want to define a different thread to test each machine in the cluster. I have a thread group with two HTTP Requests, a login that is done once, and a POST that is repeated many times. I set up a CSV Data Set Config to configure the Server Name and Port Number for the HTTP Requests. A HTTP Cookie Manager holds the login cookie resulting from the login request.
The problem is that for each time a HTTP Request runs the CSV file is read again. Often the same thread reads hostname and port values, and the login cookie is then not sent because it only applies to the original machine the thread logged into.
Is there any way to get make the CSV Data Set Config only read once per thread? Or perhaps some other way to set the hostname/port on a per thread basis instead of a per request basis like I am doing now?

I believe default settings of the CSV Data Set Config provide what you're looking for:
Other option is to distribute the threads using If Controller like:
If Controller, condition: (${__threadNum} % 2 == 0)
HTTP Request for even threads
If Controller, condition: (${__threadNum} % 2 != 0)
HTTP Request for odd threads
Both options use __threadNum() function which basically returns the number of current thread, maybe you'll be able to test your approach or come up with a better one knowing this.
In general testing clustered applications by hitting different hosts separately isn't the best idea. End user usually accesses such applications via software of hardware Load Balancer so he sees single hostname or IP address. The load balancer distributes the requests between servers using various algorithms.
I think this is the situation you need to simulate and it is better to add DNS Cache Manager to your test plan so each thread could resolve hostname on its own.

You can use HTTP request Defaults.
Update your Server IP, Port and protocol details. All the HTTP requests in Thread Group will take the default ip, port etc from the HTTP request Defaults.
Check here for more details

Related

Best way to load test application under same machine

I've used Gatling and Siege to load test my application. However, at certain points (especially when my load is higher), I would get a lot of gateway and requestTimeoutException errors. Since the requests doesn't seems to even get to the app, I presume the issue is to be my IP address being blocked due to the influx of traffic from 1 IP address. How do you overcome this? I'm assuming that the users that Gatling and Siege create to send concurrent requests are all under the same IP of my machine?
This is not possible for Gatling, the relevant feature request has been closed, you might want to consider using Apache JMeter instead, JMeter's HTTP Request sampler has "Source IP" field where you can put the needed IP address or alias
More information: Using IP Spoofing to Simulate Requests from Different IP Addresses with JMeter

If request sent through jmeter, in glassfish clustering requests are not segregating to different servers

For the application server set as clustering in glass fish. I have sent request through jmeter and all the requests hits to only one server . Expected was requests should be distributed to multiple servers in the cluster. But if sent requests manually clustering is working. Please help to sort out this issue
There could be different clustering load balancing mechanisms, as far as I can see from the GlassFish Server High Availability Administration Guide:
Cookie Method
The Loadbalancer Plug-In uses a separate cookie to record the route information. The HTTP client (typically, the web browser) must support cookies to use the cookie based method. If the HTTP client is unable to accept cookies, the plug-in uses the following method.
Explicit URL Rewriting
The sticky information is appended to the URL. This method works even if the HTTP client does not support cookies. To implement explicit URL rewriting, the application developer must use HttpResponse.encodeURL() and encodeRedirectURL() calls to ensure that any URLs in the application have the session information appended to them.
So depending on your Load Balancer configuration you need to
Either define either different cookies in the HTTP Cookie Manager
Or make sure different threads send requests to different URLs i.e. via HTTP URL Re-writing Modifier
In any case it is recommended to add DNS Cache Manager so each virtual user would resolve the underlying IP address of the application under test on its own.

Can send SNMP requests from manager to multiple agents concurrently?

I require to send get requests to several snmp agents from a client process.
I have implemented client/agent based on below urls
http://www.jitendrazaa.com/blog/java/snmp/create-snmp-client-in-java-using-snmp4j/
http://www.jitendrazaa.com/blog/java/snmp/creating-snmp-agent-server-in-java-using-snmp4j/
I would like to know whether the client/manager can send requests to the agents concurrently? (e.g. using background threads within the process)
or whether it would be necessary to poll each agent individually?
From the samples,
CommunityTarget has address set as udp:127.0.0.1/161 - which is then used in the snmp 'get' request.
The agent has address set as 0.0.0.0/2001 - which is used when creating TransportMappings.
I don't understand how the addressing is working / how I would configure to handle agents at other/non local IP addresses?
Thank you
For question #1:
You are asking about synchronous vs. asynchronous API usage.
Google "snmp4j asynchronous" for examples.
This is orthogonal to single-thread vs. multi-thread.
Ie. you can have a single-thread application which asynchronously sends requests and handles multiple agents' responses.
As an example, the MIMIC Recorder is a single-threaded, asynchronous app.
Multi-thread is only needed for complicated applications which handle complicated management state machines.
For question #2:
It looks like the sample code only connects to the agent 127.0.0.1 on the local system. To connect remotely, you would have to use the IP address where the agent is running.

How to send data to client browsers when a server side change occurs

I have an intranet based CRM application developed in CodeIgniter 2.1 where the application is running on a local Apache server and around 20 clients are accessing it over LAN. This is to be connected to a call center setup where the call center application (running on a separate server) will do a HTTP post with caller's number as well as terminal number of the agent where the call is arriving to a URL of my Codeigniter application. I am using this data to populate a database table of call records.
Now from the terminal number (each terminal has static IP, and a session in Codeigniter is linked to IP as well) I can find out which user (login session) of my application is about to receive the call. I want to find a way out how I can send data from server side (it will be regarding the call like the number who is calling, past call records etc.) to that specific user's browser via AJAX or something similar? The agent's browser needs to display this information sent from server.
Periodic polling from browser by jquery etc. is not possible as the data needs to be updated almost instantaneously and rapid polling up to this extent will lead to high CPU usage at client end as well as extra load on network.
P.S.: I only want to know how to modify the browser data from server end.
In AJAX, asynchronous request/response doesn't involve polling; there's just an open TCP connection and non-blocking I/O. The client makes a request but returns immediately; when the server sends the response, the client is notified. So you can achieve what you want with AJAX's XMLHttpRequest without polling[1]. All you need is a url from which to serve your notifications. You could have one request thread and a general dispatch method, or different urls and different threads for each, depending on how you needed to scale.
[1] Well, to be honest, with very little polling. You'd really need to establish what the session/global timeout was and reissue requests within that time limit.

2 connections per server?

i´ve read somewhere that you can just have 2 connections (eg. ajax requests) to the same server. is this correct?
so you can´t run 3 ajax requests simultaneously? what will happen to the 3rd one?
and if I´ve got one iframe, then i can just run 1 ajax request at the time?
what is the easiest way to get around this?
what keywords could i use to search for more information regarding this on google?
The 2 connection maximum pr server is mandated in the HTTP RFC 2616 section 8.1 http://www.ietf.org/rfc/rfc2616.txt
Clients that use persistent connections SHOULD limit the number of
simultaneous connections that they maintain to a given server. A
single-user client SHOULD NOT maintain more than 2 connections with
any server or proxy. A proxy SHOULD use up to 2*N connections to
another server or proxy, where N is the number of simultaneously
active users. These guidelines are intended to improve HTTP response
times and avoid congestion.
Q:what will happen to the 3rd one?
The third one will be queued untill one of the other HTTP calls return
Q:and if I´ve got one iframe, then i can just run 1 ajax request at the time?
The iFrame will be loaded through a HTTP connection, but once the HTML content has be returned the HTTP call has been completed and you again have 2 available HTTP connections
Q:what is the easiest way to get around this?
The most important is not to have long running HTTP requests, i.e. speed up processing on the server side. As long as HTTP requests are responded to in less than 100 ms, it is for normal apps not a problem.
You read it right, browsers limit simultaneous connection to the exact same domain to 2 for any type of requests (script src, image src, ajax etc.) originating from a given document, it can be changed in registry for IE and about:config in Firefox.
One way to get around this is to have additional CNAMEs to your host.

Resources