504 gateway timeout while runnning the Load Test jmeter
Asked Answered
O

1

5

I have been working on performing the load test on jmeter for 500 users per second. I am using JMeter for the same. While running the load test I am continuously getting the error on login API. Below is the request and response which I am sending and receiving timeout.

Sample Request

POST https://example.com//9000/v1/api/user/login

POST data:
{
        "email":"[email protected]",
        "password":"abcdef"
}

[no cookies]

Request Headers:
Connection: keep-alive
Content-Type: application/json
: 
Content-Length: 79
Host: botstest.smartbothub.com
User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_151)

sample response

Thread Name: Thread Group 1-310
Sample Start: 2017-12-27 11:30:06 IST
Load time: 61422
Connect Time: 1148
Latency: 61422
Size in bytes: 363
Sent bytes:286
Headers size in bytes: 171
Body size in bytes: 192
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 504
Response message: Gateway Time-out

Response headers:
HTTP/1.1 504 Gateway Time-out
Server: nginx/1.10.3 (Ubuntu)
Date: Wed, 27 Dec 2017 06:01:07 GMT
Content-Type: text/html
Content-Length: 192
Connection: keep-alive


HTTPSampleResult fields:
ContentType: text/html
DataEncoding: null

The nginx config file for the server is as shown below. https://drive.google.com/file/d/1_XWYeqSAWZz6dtnTTCeLOEMzDwvEWwY1/view

Overplus answered 27/12, 2017 at 6:39 Comment(4)
A 504 probably means that nginx ( or the upstream application ) is under high load and can not properly respond.Norty
so how to fix this do I need to change my nginx configuration for same?Overplus
Configuration? Probably not much to do. You can check the tuning guide. But my guess is that the physical server you are running on is probably overloaded. Check CPU usage of the server.Norty
you need to increase timeout in ngynx more than 60 secondsNostoc
U
7

Most likely your Nginx server is overloaded therefore request cannot be processed in the timely fashion causing the error.

It might be caused by several issues:

  1. Nginx server simply lacks hardware resources (CPU, RAM, Network or Disk). Make sure it has enough headroom to operate by monitoring the aforementioned resources on Nginx side using i.e. JMeter PerfMon Plugin
  2. Nginx server configuration is not suitable for high loads. Default configuration might not be suitable for handling 500 concurrent users so check out How to Configure nginx for Optimized Performance article to see whether your setup matches recommendations. Basically you need to combine points 1 and 2 to get most of your Nginx setup, if the machine is relatively idle and you're getting high response times and/or low throughput - something is wrong either with your web application or with infrastructure setup.
  3. It might be a problem with your application which cannot generate response faster than Nginx times out. Check out its logs and inspect what's going on using profiling tools - it will allow you to detect where application spends the most of time
  4. It might be an network infrastructure problem, i.e. you're using WiFi instead of LAN or there is a faulty router or you reached the limits of corporate proxy. It might be also a good idea to capture network traffic using a sniffer tool like Wireshark

But first of all read logs: JMeter logs, Nginx logs, OS logs, whatever exists and relevant. Most probably you will figure out the cause from them.

Upward answered 27/12, 2017 at 6:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.