why would creating a database pool take a long time...

28 views
Skip to first unread message

Gregory Mace

unread,
Dec 22, 2016, 2:33:20 PM12/22/16
to OrientDB
I'm using this code:




String orientUrlFormat = "remote:%s/%s";

try {

    long start = Calendar.getInstance().getTimeInMillis();
String url = String.format(orientUrlFormat, host, db);
oPartitionedDatabasePool = new OPartitionedDatabasePool(url, username, password);
OObjectDatabaseTx db = new OObjectDatabaseTx(oPartitionedDatabasePool.acquire());
// REGISTER THE CLASS ONLY ONCE AFTER THE DB POOL IS CREATED
db.getEntityManager().registerEntityClasses("com.blablabla.domain");
long end = Calendar.getInstance().getTimeInMillis();
System.out.println("creating Database Pool tool : "+(end-start)+" milliseconds");
initialized = true;
} catch (Exception e ) { ...




and the result:

creating Database Pool tool : 18341 milliseconds 

the database is on the localhost. It seems quick enough after the pool is created.


Roberto Franchini

unread,
Dec 22, 2016, 4:00:41 PM12/22/16
to orient-...@googlegroups.com
You're even measure the time to register the classes. 
How many classes are there in the package? 
Can you measure only the pool creation?
Or at least take two measures, pool creation and class registration

 
--
Best regards,
 
Roberto Franchini

OrientDB LTD  -  http://orientdb.com

Gregory Mace

unread,
Dec 23, 2016, 10:02:42 AM12/23/16
to OrientDB
Yes, I realized that right when I posted.  I've now moved my web server to another host on the same network and did some more timing, what I get is:

creating Database Pool took : 560 milliseconds
acquiring first connection from Pool took : 820 milliseconds
registering classes tool : 46260 milliseconds

and I can see from that that perhaps I'm registering too many classes.  I'll have to evaluate my domain jar and see if there is a way to optimize that.  
Still it seems like 1/2 a second for pool creation and .820 seconds for acquiring the first connection seems a bit much to me.

Also, in light of the sizable hit for registering classes, is there a way to move the registration of domain jar to the server itself. Perhaps in a plugin or dropped into the lib directory?

Roberto Franchini

unread,
Dec 23, 2016, 11:19:48 AM12/23/16
to orient-...@googlegroups.com


On Fri, 23 Dec 2016 at 16:02 Gregory Mace <mace...@gmail.com> wrote:
[cut]
 
Still it seems like 1/2 a second for pool creation and .820 seconds for acquiring the first connection seems a bit much to me.


Yes, but we don't know how much of this time is related to orient and how much is related to the system itself: lot of processes, full ram and so on.
I will measure on my side 

Also, in light of the sizable hit for registering classes, is there a way to move the registration of domain jar to the server itself. Perhaps in a plugin or dropped into the lib directory?


NOTE : I put the "software architech" hat.

For sure, you can do that, even if in the mid/long term It looks very error prone: 
- domain is updated, nobody deploy the new jar, nothing works anymore. 
- domain is updated, ready to dploy the new jar, the db can't be switched off 
- ...
So, take in consideration ALL the tradeoffs, even the impossible ones, because impossible happen. 
If you need to register only the very fisrt time, put a flag, or use a dedicated "register process" to do that job only one time.

My 2€cents


Reply all
Reply to author
Forward
0 new messages