Deploying a Volume License for a Mature Enterprise Application

I was tasked with making a multi-user business application. It has Java / Glassfish BLL using SOAP web services and the PostgreSQL backend. Each tenant has its own database, so (in my case, at least) “multi-tenant” means supporting multiple databases on each application server.

The current peer application server initializes the C3P0 connection pool with the connection string that it receives from the configuration file. I think that now for each client / database serviced by the application server, there should be one connection pool.

Once the user logs in, I can match it to the correct connection pool by viewing its tenant. My main problem is how to achieve this - when the user is first registered, the User backend table is requested, and the corresponding User object is served. It seems I will need to find out which database to use only with a username for work.

My only worthy idea is that there should be a “config” database - a centralized database for managing tenant information such as connection strings. The BLL may query this database for sufficient information to initialize the required connection pools. But since I only have a username to work with, it seems that I also need a centralized search for a username, in other words, a UserName table with a foreign key in the Tenant table.

That's where my design plan starts to smell, giving me doubts. Now I will have user information in two separate databases that need to be maintained synchronously (user add, update and delete). In addition, usernames should now be globally unique, whereas before they should be unique for each tenant.

I strongly suspect that I am inventing the wheel, or perhaps even a more advanced architecture exists. I had never done this before, and there was nobody on my team, hence our ignorance. Unfortunately, the application practically does not use existing technologies (for example, ORM was scanned at home), so our path can be difficult.

I ask the following:

  • Criticism of my existing design plan and suggestions for improving or redesigning the architecture.
  • Recommendations from existing technologies that provide a solution to this problem. I hope that it can be easily connected at the end of the game, although it may be unrealistic. I read about jspirit but found little information about it - any feedback on this or other frameworks would be helpful.

UPDATE: The solution was successfully implemented and deployed and passed initial testing. Thanks to @mikera for his helpful and encouraging answer!

+6
source share
1 answer

Some quick thoughts:

  • You will definitely need some form of common user management index (otherwise, you will not be able to associate the client input with the correct instance of the target database). However, I would suggest making it very easy and use it only for the initial login. A custom object can be pulled from a client-specific database after you determine which database.
  • You can make the primary key [clientID, username] so that usernames are not unique to all clients.
  • In addition to this thin user index layer, I would save most of the user's information where he is in the client databases . Refactoring it right now is likely to be too disruptive, you must first use the basic ability of several tenants.
  • You need to keep the general index in sync with individual client databases. But I don’t think it should be too complicated. You can also “test” the synchronization and fix any errors with a batch job that can be run overnight or by your database administrator on demand if something fails to synchronize. I would consider client databases as a wizard and use this to restore the general user index on demand.
  • Over time, you can reorganize to a completely general level of user management (and even ultimately completely separate client databases if you want, but save this for future iteration ..... li>
+5
source

Source: https://habr.com/ru/post/897996/


All Articles