I’m building a web application where all database connectivity is done through a proxy running on the same machine (specifically, Couchbase Moxi). I’ve heard that there’s overhead (in time and memory) for establishing TCP connections to external servers, which is the rationale behind connection pooling (which Moxi handles for its external connections). But does this overhead also exist for TCP connections to localhost/loopback? Specifically, will I need connection pooling between my app and the local proxy, or can I establish a new connection there for every request? More generally (for my own education, I suppose), if there is any overhead in establishing the TCP connection to localhost, how is it introduced?
I’m building a web application where all database connectivity is done through a proxy
Share
For localhost the same applies as for remote tcp, but the response time is a factor lower – (0.019 instead of 0.19 ms for a simple test i just made)
This is only one part of the overhead, though – it influences the time it takes to establish an connection.
(TCP SYN-ACK Sequence, you can look this up at wikipedia: http://en.wikipedia.org/wiki/SYN_%28TCP%29#Connection_establishment)
Apart from that, other overhead might be introduced by the database itself – accept connection, check security, check authoriation, maybe load any user-specific setup,… – this overhead will stay even with a localhost connection.