Announcement Announcement Module
No announcement yet.
Architecture question - Multi-tenancy architecture Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Architecture question - Multi-tenancy architecture


    I am designing a service with multi-tenancy (i.e. multiple customers co-existing on a single cluster and a single DB).

    I am using JPA, and assign a schema per customer (I am on Postgres, which supports this well).

    I am new to Spring, and I am trying to figure out the right architecture wrt to dependency injection, specifically EMFs.

    One approach I am considering is to use a single application context, and whenever I need an EMF, delegate to an object (my own EMFFactory) that manages all my PUs (one per customer) and not rely on injection for EMFs.

    Another idea I had is to have an ApplicationContext per customer, and have a single instance of every bean per customer, including an EMF. I am not clear on how that would work with the injection mechanism: when we set the customer in the servlet or controller (which dictates which app context to use), how does would the right app context get propagated properly?

    Any recommendations/advice much appreciated.


  • #2
    Multi Tenancy matters.


    Here is a good article...

    As you are undoubtedly finding, rolling your own multi-tenancy is more than just inserting TenantID in all your tables/schemas.

    Also have a look at