Response time difference in Jmeter and Postman - performance

I'm trying to test an API Get method when I run the same API for 1000 records in postman the response time is 4 seconds (installed postman in windows 7 and ran the test), whereas in JMeter it is taking 22 seconds, any idea what might be the reason for this?
Steps followed for JMeter run:
GUI mode
Non-GUI mode
Both Postman and JMeter are in same system/network.
Below is the Jmeter result:
Thread Name: Test/TestAPI 1-1
Sample Start: 2018-05-22 17:15:00 IST
Load time: **21406** // this is the issue , same in postman taking only 4712 ms
Connect Time: 425
Latency: 1990
Size in bytes: 3962439
Sent bytes:1130
Headers size in bytes: 175
Body size in bytes: 3962264
Sample Count: 1
Error Count: 0
Data type ("text"|"bin"|""): text
Response code: 200
Response message: OK
Response headers:HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
api-supported-versions: 1
Date: Tue, 22 May 2018 11:45:06 GMT
Content-Length: 3958179
Server: Web Server
HTTPSampleResult fields:
ContentType: application/json; charset=utf-8
DataEncoding: utf-8
Post Man Results:
api-supported-versions →1
content-encoding →gzip
content-type →application/json; charset=utf-8
date →Tue, 22 May 2018 12:00:11 GMT
server →Web Server
transfer-encoding →chunked
vary →Accept-Encoding

You need to compare similar request. In your case at least 1 header is missing. Add to JMeter's HTTP Header Accept-Encoding gzip,deflate
Follow JMeter's Best Practices to get the best performance, the main one is not to use listeners:
Use non-GUI mode: jmeter -n -t test.jmx -l test.jtl
Use as few Listeners as possible; if using the -l flag as above they can all be deleted or disabled.

Related

Server responded with 400 Bad Request during HTTP Post request

I am using SIM800 to send HTTP Post request to a remote InfluxDB database. I have successfully sent HTTP Post request to the database from my computer using Curl as shown below.
01:~$ curl -i -XPOST 'http://<ip address>:8086/write?db=mydb' --data-binary 'location,host=server01,region=us-west value=0.99'
HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: 3c958273-edb2-11eb-88ca-000000000000
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.6.3
X-Request-Id: 3c958273-edb2-11eb-88ca-000000000000
Date: Mon, 26 Jul 2021 01:38:54 GMT
After that when I tried using SIM800, I received 400 Bad Request after executing AT+HTTPACTION=1 . The remote server responded with "+HTTPACTION: 1,400,0" . Below are the AT Commands.
AT+SAPBR=3,1,"CONTYPE","GPRS"
AT+SAPBR=3,1,"APN","myAPN"
AT+SAPBR=1,1
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","http://<ip address>:8086/write?db=mydb"
AT+HTTPPARA="CONTENT","application/json"
AT+HTTPPARA="USERDATA","location,host=server01,region=us-west value=0.55"
AT+HTTPDATA=300,5000
AT+HTTPACTION=1
AT+HTTPREAD
AT+HTTPTERM
AT+SAPBR=0,1
Besides that, i captured the packets when SIM800 sent http post request but could not find the http post body.
The http post body can be seen in the captured packets when sending http post using Curl.
I appreciate if anyone can shed some light on this matter. Thank you in advance.
I managed to get it to work. Here are the AT commands:-
AT+SAPBR=3,1,"CONTYPE","GPRS"
AT+SAPBR=3,1,"APN","myAPN"
AT+SAPBR=1,1
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","http://<ip address>:8086/write?db=mydb"
AT+HTTPPARA="CONTENT","application/json"
AT+HTTPDATA=48,5000
location,host=server01,region=us-west value=0.55
AT+HTTPACTION=1
AT+HTTPREAD
AT+HTTPTERM
AT+SAPBR=0,1
after executing the AT+HTTPDATA, quickly execute the HTTP data (location,host...).

Robot Framework, How to download a file returned in a response body using only request api

I'm using robot framework to send requests without opening a browser. One of the requests is supposed to download a file. But when I send this request the file is not downloaded (even if I have a 200 status code).
${uri} set variable /api/pricing/ExportImportParams/downloadExportParams
Create Session test ${url} cookies=&{cookies}
${resp}= Get Request test ${uri} headers=&{headers}
${resp_code} = Set Variable ${resp.status_code}
${resp_code} = Convert To String ${resp_code}
Run Keyword And Continue On Failure Should be Equal ${resp_code} 200
The test is passed while the status code is 200.
But no file is downloaded
Here is the response Headers
content-disposition: attachment;
filename="Export Site Parameter_2020-01-03_09-21-39.xlsx";
filename*=UTF-8''Export%20Site%20Parameter_2020-01-03_09-21-39.xlsx
content-length: 3767 content-type:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
date: Fri, 03 Jan 2020 09:21:38 GMT server: Kestrel x-powered-by:
ASP.NET
Thanks for helping
Making an assumption that you are using the RequestsLibrary to perform the HTTP Get request to retrieve the file. Althought the documentation does not specify it, the content attribute of the returned response object contains the data. This can then be easily stored in a file using the standard OperatingSystem library.
*** Settings ***
Library RequestsLibrary
Library OperatingSystem
*** Test Cases ***
File Download Using RequestsLibrary
${file_name} Set Variable file_example_XLS_10.xls
${uri} Set Variable /wp-content/uploads/2017/02/${file_name}
Create Session test https://file-examples.com
${response}= Get Request test ${uri}
Run Keyword And Continue On Failure Should Be Equal As Numbers ${response.status_code} 200
Create Binary File ${EXECDIR}/${file_name} ${response.content}

Jmeter: lots of Connection: close in response header

I am using Jmeter to do load testing against index page(static page) of my websit.
There are lots of errors in the test reulst because of connection closed.
Any tips why server(apache 2.2) decide to close the connection?
=============http headers===============
Load time:1055
Connect Time: 845
Latency: 1055
Size in bytes:98
Body size in bytes: 0
GET https://mysite/index.html
GET data:
[no cookies]
Request Headers:
Connection: keep-alive
Content-Length: 0
Content-Type: text/plain; charset=ISO-8859-1
Host: mysite
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_121)
Response headers:
HTTP/1.0 302 Found
Location: http://mysite/splash.html
Connection: close
Check your Mysql database connection pool size, During the load test you create number of thread it may insufficient to your mysql connection configuration.
you can increase max_connections in my.cnf
Try out the following JMeter configuration amendment:
Change "Implementation" of all your HTTP Request samplers to HttpClient4. The fastest and the easiest way of doing this for all the samplers is using HTTP Request Defaults
Add the next line to user.properties file (located in the "bin" folder of your JMeter installation)
httpclient4.retrycount=1
hc.parameters.file=hc.parameters
In the hc.parameters file add the next line:
http.connection.stalecheck$Boolean=true
Restart JMeter to pick the properties up
More information: Connection Reset since JMeter 2.10 ?

JMeter - Non HTTP response message: URI can't be null

I need to test a web login using jmeter but this is the response in the results tree:
Thread Name: Thread Group 1-1
Sample Start: 1970-01-01 05:30:00 IST
Load time: 0
Latency: 0
Size in bytes: 1089
Headers size in bytes: 0
Body size in bytes: 1089
Sample Count: 1
Error Count: 1
Response code: Non HTTP response code: java.lang.IllegalArgumentException
Response message: Non HTTP response message: URI can't be null.
Response headers:
HTTPSampleResult fields:
ContentType:
DataEncoding: null
can someone please help me?
You entered a bad url in http sampler, check fields:
host
port
path
Another option is to read:
http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf
I got this issue resolved, in my own with several testing..
Try to open the file in notepad and check it,
Links should be in this format
"GET /
"GET /css/bootstrap.min.css
"GET /theme/css/daterangepicker/daterangepicker+AC0-bs3.css
and in the Access Log Sampler
Server: works only on hosted site..example test.com if you enter ip. address for test.com it will not work based on my testing

HTTP server with Ruby

I am trying to make a small HTTP server in Ruby. Its just meant to learn how stuff works, nothing big. So what i did is to send the server an ajax request. The server is listening on port 2000, and so the ajax request is also on port 2000.
The problem i am facing is that the ajax request is returned only with the headers, the content is missing. I tried everything i could find, but it seems to fail too...
I have attached the code, for you to take a look
require 'socket' # Get sockets from stdlib
server = TCPServer.new(2000) # Socket to listen on port 2000
loop { # Servers run forever
client = server.accept # Wait for a client to connect
headers = "HTTP/1.1 200 OK\r\nDate: Tue, 14 Dec 2010 10:48:45 GMT\r\nServer: Ruby\r\nContent-Type: text/html; charset=iso-8859-1\r\n\r\n"
client.puts headers # Send the time to the client
client.puts "<html>amit</html>"
client.close # Disconnect from the client
}
The ajax request is working when pointed to a PHP script running on Apache. the only problem seems to occur when using this server.
Any help is as always, deeply appreciated :)
Regards,
Amit
Your code works fine.
$ telnet localhost 2000
HTTP/1.1 200 OK
Date: Tue, 14 Dec 2010 10:48:45 GMT
Server: Ruby
Content-Type: text/html; charset=iso-8859-1
<html>amit</html>
Connection to host lost.
Now you'll have to find out what's wrong with your AJAX request...
I also included the Content-Length header and that seemed to clear up the errors I was getting with curl:
require 'socket' # Get sockets from stdlib
server = TCPServer.new(2000) # Socket to listen on port 2000
loop { # Servers run forever
client = server.accept # Wait for a client to connect
resp = "<html>amit</html>"
headers = ["HTTP/1.1 200 OK",
"Date: Tue, 14 Dec 2010 10:48:45 GMT",
"Server: Ruby",
"Content-Type: text/html; charset=iso-8859-1",
"Content-Length: #{resp.length}\r\n\r\n"].join("\r\n")
client.puts headers # Send the time to the client
client.puts resp
client.close # Disconnect from the client
}
You're missing the Access-Control-Allow-Origin HTTP header in your response headers.
Since you're trying an AJAX request, and it is basically an XHTTPRequest, you need to pass it in the response to the client, in order to accomplish the Cross-Origin Resource Sharing implementations of your browser.
Just add in your HTTP server:
headers = "HTTP/1.1 200 OK\r\n"
headers += "Access-Control-Allow-Origin: *\r\n"
headers += "Date: Tue, 14 Dec 2010 10:48:45 GMT\r\nServer: Ruby\r\nContent-Type: text/html; charset=iso-8859-1\r\n\r\n"
and then you can try to see if works.

Resources