0 Replies Latest reply on Mar 16, 2011 4:05 PM by alexaraujo

    Multi-Tenant Seam + JPA Application

    alexaraujo

      I work on an existing Seam 2.2.0 + JPA (Hibernate 3.3.1) application that needs to be converted to a 'single database per client' environment where each database schema is the same.  The application runs on Glassfish, uses IceFaces,  and has several pages that utilize Conversations. It also uses a single EJB for authentication.  Unfortunately, the decision to split clients off into their own databases is outside of my control.


      As a proof of concept, I have already made the application aware of multiple databases by moving the management of EntityManagerFactory(ies) and DataSource(s) into the application using Spring JPA abstractions, resource local transactions, and ThreadLocal for context information.  For example, each time a user logs in a new EntityManagerFactory is initialized using a new DataSource that communicates with their database if it has not already been initialized.  This is working well in a test environment with a handful of databases.


      My question is, will this approach scale to hundreds of databases?  I expect to add application servers to a load balancer to handle additional load, but will the overhead of the first-level cache and/or Seam context management (a.k.a., memory consumption) require significantly more servers to scale compared to a typical load balanced application?  If so, can this be mitigated by allocating servers with lots of RAM and/or a large distributed cache?


      Any insight would be greatly appreciated.


      Cheers,


      Alex Araujo