I apologize for my post being confusing. I was talking about the alternative to using shards, which I have set up as a test right now. Since each request in my application will be using one and only one database, with identical schema on each database (one per corporate account), there's really no need for me to use shards, from what I gathered. Heres an example of what I'm currently sandboxing (this is an excerpt from my HibernateUtil class):
Code:
public static SessionFactory getSessionFactory(Account a){
if(!sessionFactoryMap.containsKey(a.getId())){
String account_db = a.getDatabase();
configuration.setProperty("hibernate.connection.url", "jdbc:mysql://" + DB_HOST + "/" +account_db);
sessionFactoryMap.put(a.getId(), configuration.buildSessionFactory());
}
return sessionFactoryMap.get(a.getId());
}
(sessionFactoryMap is an object of a Map subclass, right now I am using a HashMap)
My question is, how expensive are these SessionFactory objects, and at what point am I going to max out of memory? A ballpark figure here would be great... Obviously if I go down this road much further some logic will be needed to expire these factories after a certain period of inactivity.