Yep no probs at all. You can have multiple databases open at the same time and open and close them on different threads as you like.

You'll just need to do the appropriate connection handling linked to the session open / close.

Scaling is going to depend on your application architecture too. If you are horizontally scaling it isn't going to work with embedded databases?. Or are you using TCP and having a h2 server on a different server?

The downside I can think of is that you can't query all databases for any non-user tasks. Have to update all schemas individually, etc. So on each session start it is going to almost be like starting a separate application.

Probably fits quite nicely with vaadin architecture. Just link it to the Application start and end (Don't they call a session an application?)


Ryan


On 2/07/2015 6:06 AM, Basil Bourque wrote:

Is it possible to start up and shut down multiple H2 <http://h2database.com/html/main.html> databases within a JVM?

My goal is to support multi-tenancy <https://en.m.wikipedia.org/wiki/Multitenancy> by giving each user/account their own database. Each account has very little data. Data between the accounts is never accessed together, compared, or grouped; each account is entirely separate from the others. Each account is only accessed briefly once a day or a few times a month. So there are few upsides to housing the data together in a single database, and some serious downsides.

So my idea is that when a user logs in for a particular account, that account’s database is loaded. When that user logs out, or their web app session (Vaadin <https://www.vaadin.com/> app) times out, that account’s database is closed, it's data flushed to storage, and possibly a backup performed. This opening and closing would be happening for any number of databases in parallel.

Benefits include minimizing the amount of memory in use at any one time for caching data and indexes, minimizing locking and other contention, and allowing for smooth scaling.

I'm new to H2, so I'm not sure if its architecture can support this. I'm asking for a denial or confirmation of this capability, along with any tips or caveats.

----

Taken from my Question <http://stackoverflow.com/q/31150193/642706> on StackOverflow.com.
--
You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to h2-database+unsubscr...@googlegroups.com <mailto:h2-database+unsubscr...@googlegroups.com>. To post to this group, send email to h2-database@googlegroups.com <mailto:h2-database@googlegroups.com>.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to