inthefabric / RexConnect

Connect to Rexster/RexPro via TCP connection.
www.inthefabric.com
Other
10 stars 0 forks source link

Share client/connection for all commands within a request #10

Closed zachkinstner closed 11 years ago

zachkinstner commented 11 years ago

From issue #7:

RexConnect currently creates a brand new RexsterClient for every single query command.

To avoid overhead of creating a new client and connection for each command, move the client up to the request level.

zachkinstner commented 11 years ago

What happens if something goes wrong with a query execution and breaks the client/connection? Once issue #6 is complete, a command failure would short-circuit the request. The final rollback/close queries should share a new client/connection, to avoid potential corruption caused by the command error.

zachkinstner commented 11 years ago

I have implemented this as a fix for #14. Each request gets a single [SessionContext] instance, and now, each SessionContext maintains a single [RexConnectClient]. The client is closed at the end of the request.

The performance gain here is noticeable, but I don't have proper measurements. I'd say it's on the order of 10 to 20% faster for my batch operations in #14.