Connection leaks are easy to introduce, hard to spot, can go undetected for a long time and have disastrous consequences. It's not enough to fix a connection leak or code against them, you must write tests that would fail in their presence. Here I will discuss a number of techniques that could apply to many different languages and frameworks. I have also provided some concrete examples on github which make use of Dropwizard , JerseyClient and WireMock . What is a connection leak? Each time system A talks to system B over a protocol like http, it requires a TCP/IP connection to send and receive data. Connections can be re-used for different requests, via a connection pool, or a new connection can be established for each request. Once system A has finished with the connection, it needs to either return the connection to the pool, or close it. If this doesn't happen you have a connection leak. Given a connection leak, everything will continue to work ju
Hello.
ReplyDeleteI have seen the record of this talk on youtube and it was very interesting for me.
So, there was some question at 54:18 (link for it https://youtu.be/q2vADSqi6XI?t=3257 ) and i could not understand what it was about (could not hear it).
Could you repeat that question and answer for it here, please?
Hi Djasan,
DeleteGlad that you found the talk interesting.
The question was "Why does ratpack default the number of threads to two times the number of CPU cores?".
...I had a quick check and yes indeed it does default to two threads per CPU core - see here: https://ratpack.io/manual/current/api/ratpack/server/ServerConfig.html#DEFAULT_THREADS
My answer was "I don't know". I then went on to guess that perhaps a little bit of thread switching is ok (i.e. one cpu core switching between two threads of execution is better for performance - however in retrospect this seems wrong as the entire idea is thread switching is to be avoided).
Someone else from the audience then said (it was very muffled so might be wrong here...) that it might be due to the fact that some CPUs will perform hyper-threading on each core which means a single core could perform more than one task in parallel. See wikipedia here: https://en.wikipedia.org/wiki/Hyper-threading
If you are really thinking about performance (likely if you're using ratpack) perhaps the best bet is to adjust this property based on what (if any) hyper-threading your CPU will do.
Hope this helps.
Phill
Hi Phill,
ReplyDeletethanks for a great presentation! I am quite curious about the way who you've tested the performance. Could you please provide a bit more information (about an environment, HW, etc..)
Thanks!