Hi Everyone,
Seeing how multi-tenant is a growing topic, I could share how I’ve designed my multi-tenant setup. Now, my configuration might not help anyone else, because I’ve essentially built a system a little bit like Craigslist.
What’s distinct
- The tenants are U.S. states and countries, each with their own subdomain, e.g.:
www.public.law
texas.public.law
oregon.public.law
- Tenants have their own CSS themes:
- Tenants have their own custom template adaptations if needed. (You can see in that screenshot above, oregon.public.law is labelled OregonLaws for historical & branding reasons.)
- Tenants sometimes have custom view logic, when the jurisdiction’s laws are arranged “unconventionally”.
What’s shared
- User accounts are gobal, because each user should have access to all jurisdictions.
- The tenant data is all in shared tables to enable cross-jurisdictional searches. E.g., there’s a single
statutes
table with a record for each law or section, for every state. - A single Heroku app with a single Postgresql database
- A single Cloudfront Web Application Firewall config
- A single Rails codebase
- A single Elasticsearch service for the internal search feature. I’ve taken the first small step to enabling cross-tenant/cross-document-collection search:
- Shared image and JS assets.
- 99% of CSS is shared.
I think those are the major pieces. It’s very solid and has been running in prod for a couple of years like this. I’m currently adding a new tenant, colorado
.
tldr; This might not be the usual “multi-tenant” use-case, but if it’s helpful, I can answer questions or maybe do a presentation.