Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The application dies under high load #13

Open
fanifieiev opened this issue Nov 21, 2019 · 1 comment
Open

The application dies under high load #13

fanifieiev opened this issue Nov 21, 2019 · 1 comment

Comments

@fanifieiev
Copy link

fanifieiev commented Nov 21, 2019

I did some testing using 'ab' tool.
So,
./ab -n 100000 -c 10000 -s 120 http://localhost:9999/
makes the application stop with stack trace:
Socket accepted: java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:9999 remote=/0:0:0:0:0:0:0:1:64822] Socket accepted: java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:9999 remote=/0:0:0:0:0:0:0:1:64823] Socket accepted: java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:9999 remote=/0:0:0:0:0:0:0:1:64824] Socket accepted: java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:9999 remote=/0:0:0:0:0:0:0:1:64825] Socket accepted: java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:9999 remote=/0:0:0:0:0:0:0:1:64826] Socket accepted: java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:9999 remote=/0:0:0:0:0:0:0:1:64827] Exception in thread "Thread-0" java.lang.IllegalStateException: Queue full at java.util.AbstractQueue.add(AbstractQueue.java:98) at java.util.concurrent.ArrayBlockingQueue.add(ArrayBlockingQueue.java:312) at com.jenkov.nioserver.SocketAccepter.run(SocketAccepter.java:44) at java.lang.Thread.run(Thread.java:748)

@jjenkov
Copy link
Owner

jjenkov commented Jan 7, 2020

That looks to me like a too small capacity is used for the ArrayBlockingQueue between the accepting thread and the connection managing thread. Increase capacity of that queue, and the problem will be mitigated. Or, use a blocking "put" method on the queue, so that the accepting thread is blocked until there is space in the queue for another connection.

By the way, this is not a problem of "high load" - but a problem of a high number of connections being opened (and accepted) within a very short time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants