3

I am setting up a test against single EC2 instance. In that EC2 it has only Django application. It has no S3/CloundFront or RDS assist it. Everything purely run on Docker and basic setup of memory and CPU.

My goal is I want to see the empirical performance of my single EC2. It will help me do roughly cost estimation on the production.

You can skip this and jump to my problem:
Here is my production setup
1 load balance
2 nodes with identical setup by using docker image
1 bucket/cloudfront
1 rds

Softwares:
django==2.0.5
djangorestframework-jwt==1.11.0
djangorestframework==3.8.2

Tools:
JMeter 4.0 r1823414
javac 10.0.1
java 10.0.1 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode) javac 1.8.0_171

Parameters:

Thread Group
- Number of Threads: 10
- Ramp-up period: 1
- Loop Count: 1

HTTP Header Manager
- Content-Type, Application/json
- Authorization: jwt ${token}

HTTP Request
- http
- localhost
- port: 8000
- POST
- Path: /api-token-auth/
- Body data : {"username": "myname", "password": "mysecretpassword"}

At this point test is good. All are green I can have token back from Django.

Problem:

org.apache.http.NoHttpResponseException: localhost:8000 failed to respond
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:141)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$5.doReceiveResponse(HTTPHC4Impl.java:401)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:842)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:581)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:67)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1231)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1220)
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
at java.lang.Thread.run(Thread.java:748)

Additional Parameters
JSON Extractor
- Main sample only
- Names of created variables: token
- JSON Path expressions: $.token
- Match No. (0 for Random): 1

HTTP Request
- http
- localhost
- port: 8000
- PATCH
- /api/branches/5/
- Body Data: {"name": "Bangkok"}

I have tried this But I could not get it work. Here is my navigator bar
nav bar jmeter

Debug Sampler:
Jmeter's token is empty

JMeterVariables:
JMeterThread.last_sample_ok=false
JMeterThread.pack=org.apache.jmeter.threads.SamplePackage@79e6c86e
START.HMS=095906
START.MS=1526612346142
START.YMD=20180518
TESTSTART.MS=1526639371341
__jm__Users__idx=0
__jmeter.USER_TOKEN__=Users 1-1
token=
token_matchNr=0

Questions:
How to let jmeter grab jwt token and shoot another endpoints?

Update1:
When I disable Patch Branch. Debug Sampler does show me the token value

Update2:
I was wrongly call the variable. But PATCH problem still persist. Now I can call token. Here is my request

PATCH http://localhost:8000/api/branches/5/

PATCH data:
{
    "name": "Bangkok"
}


[no cookies]

Request Headers:
Connection: keep-alive
Autorization: jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxMCwidXNlcm5hbWUiOiJ0b255b2QiLCJleHAiOjE1MjY2NzIzOTMsImVtYWlsIjoidG9ueW9kQG1teC5jb20iLCJvcmlnX2lhdCI6MTUyNjY0MzU5M30.mjKJ2sRFx26pyChET1ORzLmv6umL7B1_Sy8wnNJO-iQ
Content-Type: Application/json
Content-Length: 26
Host: localhost:8000
User-Agent: Apache-HttpClient/4.5.5 (Java/10.0.1)

Update3:
Problem seems to be jmeter side because. When I open the backend log. PATCH never reach the backend

INFO|18/May/2018 11:52:04|"POST /api-token-auth/ HTTP/1.1" 200 224
INFO|18/May/2018 12:01:35|"POST /api-token-auth/ HTTP/1.1" 200 224

Update:4
Found the clue. It might be the problem from HTTPClient4

Update:5
Try imitate the original java8 environment. It raises the same problem https://jmeter.apache.org/download_jmeter.cgi

http://www.jmeter-archive.org/org-apache-http-NoHttpResponseException-td5719349.html

joe
  • 8,383
  • 13
  • 61
  • 109

2 Answers2

1

Since when you uncheck "Use KeepAlive" it works, it means the Connection becomes stale most probably because the JMeter defaults are not working for your use case.

You need to adjust :

  • httpclient4.idletimeout
  • httpclient4.validate_after_inactivity : Reduce it
  • httpclient4.time_to_live

See:

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
  • Thank you for very much for answer. It is a good starting point for me to adjust the parameter. Jmeter is huge! – joe May 21 '18 at 16:09
0

oleg does answer to my problem. I have to uncheck Use KeepAlive

joe
  • 8,383
  • 13
  • 61
  • 109