skip to Main Content

Im totally newbie in stress testing, just to mention.

A little bit info to understand project, not the question itself:
I have webapp in nextjs14. Got requirement from a client to be able to support 400-500 simultaneous users connected and working with it.
Also app designed to be real-time. All data on same page for every user must be updated for every user automatically. I use websockets for this part, to send a signal to connected clients to fetch fresh data. So, in worst scenario, if all users connected to the same page, server must complete 500 requests simultaneously.

So, i set a jmeter test to simulate user’s first login, fetching necessary data.

Test look like this:

I set test to 400 users, ramp-up to 10sec. And test in 2 ways. One time loop and then 50 loops.

  1. Load login page and get csrf token.
  2. POST credentials (i have http cookie manager)
  3. Load page with some data
  4. GET data from api (simulating JS "loaded" with fetching all required data on this page)

Quiestions part SHORTLY:

If i run test once, everything is ok. If i run loop for 50 times, then i have problem with exhausted ports, no matter if i check or uncheck keep-alive checkbox in JMeter. In a few seconds of test in the end i reach limit of 65535 ports. Netstat shows that mostly all of them in TIME_WAIT state. And server start returning errors after i hit limit.

A little bit more description:

First i was trying do this on my local pc on win10.

I got very poor performance, nextjs server was unable to handle this amount of requests. So i set up nginx and set round-robin for 5 nextjs servers. That fix the issue with performance, but after 1000 samples i get error responses.

Figured out that win10 have a low limit of ports can be used. So i set up linux on a virual machine and did same test. Performance now is much better, but i reach limit of ports of 65535.

Never did apps that can be under heavy load, so im a bit lost. Im pretty sure i can fix poor performance for code, but with limits of system iteself i need a hints please.

What i probably did wrong and what i can do to bypass this issues.

I cant even say if this jmeter test is represet something real, or behaviour in browser will be different. I thought to test with selenium plugin, but 400-500 browsers nearly impossible for me to run for test.

Any info and links that can be helpful to read is very appreciated! Thanks in advance.

2

Answers


  1. Chosen as BEST ANSWER
    upstream http_backend {
        server 127.0.0.1:8080;
    
        keepalive 16;
    }
    
    server {
        ...
    
        location /http/ {
            proxy_pass http://http_backend;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            ...
        }
    }
    

    proxy_http_version 1.1 solved my problem. now TIME_WAIT ports are very low for amout of connections JMeter creates, most of the connections now have status ESTABLISHED.

    NGINX Keep-Alive settings options


  2. I fail to see how can you reach the limit of 65535 ports with 500 virtual users.

    So either you’re not terminating the connections properly on JMeter side or on the server side.

    1. Try ticking "Same user on each iteration" box on Thread Group level

      enter image description here

      this way the existing TCP/SSL session will be re-used instead of creating a new one

    2. Try un-ticking Use KeepAlive box on HTTP Request sampler level

      enter image description here

      this way JMeter will send Connection: close header terminating the session from JMeter end

    3. If you’re using WebSocket Samplers plugin go for WebSocket Open Connection and WebSocket Close samplers for setting up and terminating the connection and use the relevant Samplers with the "existing connection" option

    4. Make sure that JMeter has the same network footprint as a real browser, check requests which are being sent from both using a 3rd-party sniffer tool like Fiddler or Wireshark and amend JMeter’s configuration to behave exactly like a real browser

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search