What is the best graph db pooling mechanism to use when scaling to 
thousands of Orient database users? I found a few forum threads on this 
using OPartitionedDatabasePoolFactory , but I could not find any mention of 
it in the user docs - so wanted to confirm the usage. I'm also assuming 
that this pool is a must when using Orient db-level security that depends 
on having user specific connections (as opposed to just a generic admin 
user to do everything)

Based on the javadoc, as far as I can tell, this is the usage pattern:

//One time
//Keep a single static instance of the pool factory. Default LRU cache size 
is 100
//Pools may be evicted when capacity is used
private static OPartitionedDatabasePoolFactory PDF = new 
OPartitionedDatabasePoolFactory();
PDF.setMaxPoolSize(...); //All pools from this factory will have this max 
pool size (default is 64)

//Everytime the user does something. 
//Depending on concurrency, thousands of these pools will get 
created/evicted.
try {
  //Pool for this db/user
  OPartitionedDatabasePool 
<http://orientdb.com/javadoc/latest/com/orientechnologies/orient/core/db/OPartitionedDatabasePool.html>
 pool 
= PDF.get("remote:host/dbname", "uname", "upwd");
  
  //Get a db connection for this thread
  ODatabaseDocumentTx db = pool.acquire();
  //We need an Orient graph, so wrap it. This is a lightweight operation
  OrientGraph g = new OrientGraph(db, true);

  //Do cool stuff with g (tx is auto start)

  g.commit();
} catch (Exception e) {
  g.rollback();
  throw e;
} finally {
  //Return the connection to the pool. Is this right?
  g.shutdown(); //This is confusingly called shutdown, but apparently just 
returns to pool? Is this right?
}


//One time on application shutdown.
PDF.close();


--

Question: Is this usage pattern correct, and will it scale to thousands of 
users? 

I based the above usage on what I found in an older thread reproduced below:

"But problem with creation of OrientGrah instances with many users have 
already been solved by us .You see OrientGraph is merely thin wrapper on 
ODatabaseDocumetTX instance , creation of which I agree is expensive task . 
To solve problem when you have millions of users in database we have 
created OPartitionedDatabasePoolFactory which is  lock free LRU list of 
connection pools for each user , each connection pool not only lock free 
but for many classes wait free because it tries to partition load between 
active CPU cores ( indirectly of course ) . According to our benchmarks 
acquiring of connection from this pool requires nanoseconds . When you 
acquire database instance you merely wrap it in OrientGraph instance which 
is cheap operation"


Thanks,

--Harish.




-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to