-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Play Version
Play 2.5 (Play 2.4 is not affected by this bug).
Reproduced with play.server.netty.transport = native AND jdk
API
Scala (not tested with Java)
Operating System
Tested on :
- Ubuntu 14.04 64bits
- Amazon Linux AMI
JDK
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)
Library Dependencies
N/A
Expected Behavior
Returning a 204 No Content should not create a connection leak.
Actual Behavior
When a controller return a 204, the connection seems to not be closed.
With a netstat -n, I can see that the connection is open, stuck in TIME_WAIT.
Consequently, running a wrk -t 32 -c 32 -d10s http://localhost/nocontent open more than 50000 connections, and the server is not able to respond to any requests until the OS recycle the sockets.
Reproducible Test Case
Sample project here : https://github.com/studiodev/microservices-benchmark-scala/tree/play25-simplified/microservice-play25
You can easily reproduce the bug by launching a bench on the /nocontent route, whereas the /ok is not affected.
# Terminal 1
watch -n 0,5 'echo NETSTAT> TOTAL: $(netstat -n | grep "127.0.0.1:9000" | wc -l) - TIME_WAIT: $(netstat -n | grep "127.0.0.1:9000" | grep "TIME_WAIT" | wc -l)'
# Terminal 2
## NOMINAL case
➜ wrk -c32 -t32 -d10s http://localhost:9000/ok
Running 10s test @ http://localhost:9000/ok
32 threads and 32 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 88.55ms 288.11ms 1.64s 91.77%
Req/Sec 712.51 413.42 4.55k 66.50%
192970 requests in 10.10s, 13.80MB read
Requests/sec: 19106.94
Transfer/sec: 1.37MB
NETSTAT> TOTAL: 18 - TIME_WAIT: 18
## ERROR case
➜ wrk -c32 -t32 -d10s http://localhost:9000/nocontent
Running 10s test @ http://localhost:9000/nocontent
32 threads and 32 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 5.04ms 4.72ms 79.04ms 90.03%
Req/Sec 214.03 100.66 515.00 65.50%
50107 requests in 10.04s, 3.97MB read
Socket errors: connect 32, read 0, write 0, timeout 0
Requests/sec: 4989.46
Transfer/sec: 404.42KB
NETSTAT> TOTAL: 44196 - TIME_WAIT: 44196
I've not tested all the others HTTP code, but it must be the only one (which not expect a body).