Forum: Building VoltDB Applications

Post: How to have a createConnection fast ?

How to have a createConnection fast ?
l.brun
Mar 7, 2012
Hi,

I'm testing and benchmarking voltdb solution.

The platform is
HOST: CPU INFO: 4 Cores, 1 Sockets, 8 Hardware Threads
HOST: CPU DESC: Intel(R) Xeon(R) CPU W3520 @ 2.67GHz HOST: HOST MEMORY (MB): 24104
HOST: OS PROFILE: Linux 2.6.18-274.18.1.el5 amd64 fr_FR
HOST: JAVA VERSION: 1.6.0_26
HOST: JAVA RUNTIME: Java(TM) SE Runtime Environment (1.6.0_26-b03)
HOST: JAVA VM: Java HotSpot(TM) 64-Bit Server VM (20.1-b02, mixed mode)

I test to run several stored procedure to query a database with a single table in a java client as in samples with same configuration files.

The problem is that it takes the whole time only to connect... (400 to 600 ms, and 40ms for querying)

Here's the first part of the code and the result :
public static void main(String[] args) throws Exception {
/*
* Instantiate a client and connect to the database.
*/
Date dat = new Date();
org.voltdb.client.Client myApp;
Date datLoginStep1 = new Date();
System.out.printf("Time to login step 1 = %s ms
",(datLoginStep1.getTime()-dat.getTime()));
myApp = ClientFactory.createClient();
Date datLoginStep2 = new Date();
System.out.printf("Time to login step 2 = %s ms
",(datLoginStep2.getTime()-datLoginStep1.getTime()));
myApp.createConnection("localhost");
Date datLoginStep3 = new Date();
System.out.printf("Time to login step 3 = %s ms
",(datLoginStep3.getTime()-datLoginStep2.getTime()));
Result :
Time to login step 1 = 0 ms
Time to login step 2 = 154 ms
Time to login step 3 = 412 ms


So is there a bestpractice to avoid the connexion, i have to create a connexion pooling ?

regards,
Lilian.
Hi,The first time you run
aweisberg
Mar 9, 2012
Hi,

The first time you run this you are measuring the overhead of class loading. I set it to run in a loop.

Here is my first run:
Time to login step 1 = 0 ms
Time to login step 2 = 84 ms
Time to login step 3 = 416 ms

Second
Time to login step 1 = 0 ms
Created distributer in 3
Full end 0
Time to login step 2 = 3 ms
Time to login step 3 = 1 ms

Last after running for a few seconds
Time to login step 1 = 0 ms
Time to login step 2 = 1 ms
Time to login step 3 = 1 ms

You don't need connection pooling. You can use the Java client library safely from multiple threads. Create it once at startup and reuse it.

I do see that the way accept is implemented you will see 400 millisecond connection times in some cases. I created an issue for this. https://issues.voltdb.com/browse/ENG-2598

The problem is the IO here https://github.com/VoltDB/voltdb/blob/master/src/frontend/org/voltdb/ClientInterface.java#L457
If you change that sleep to a Thread.yield() you will get better performance, but it really needs to be fixed properly.

Creating a connection for every request will never work well because you will run out of local ports and be bottlenecked to about 20k txns/sec by the TCP accept rate. To even get to 20k you will have to muck with various kernel parameters to get ports to free up faster.

-Ariel