I’m wondering to what degree establishing repeated TCP connections with .NET’s TcpClient could affect application performance.
The application I am working on was originally a client/server application designed to have the clients and server on the same LAN network.
We’ve removed the ODBC database connections on the client and are using a custom server that serves binary data using Protocol Buffers after reading it from the Database.
Our code makes a connection to the server for each SQL statement, and the serialized result is returned in a structure that resembles a DataTable.
On our company network the application is quite fast, however we have begun testing with remote clients and are having latency issues. Our server is on the east coast and our remote clients are on the west coast.
I suspect that the overhead of opening up a connection for each SQL statement is actually a bottleneck for distant clients, however I am not certain about this.
My question: is opening TCP connections repeatedly a performance bottleneck? Would a persistent connection improve performance? And what gotchas would there be if we went to persistent connections?
Yes it is. Use a connection pool. There are many available.