Why use subdomains to designate tenants in a multi-tenant web application?

There are several ways to determine tenant on HTTP level: domain – tenant is determined by whole Host header sub-domain – sub-domain part of Host header, path based – path segment, usually by prefix host.com/tenantId/… cookie based – cookie value contains tenant id (good framework encrypts this!) user based – user session or some data … Read more

How to design a multi tenant mysql database [closed]

There are several approaches to multi-tenant databases. For discussion, they’re usually broken into three categories. One database per tenant. Shared database, one schema per tenant. Shared database, shared schema. A tenant identifier (tenant key) associates every row with the right tenant. MSDN has a good article on the pros and cons of each design, and … Read more

How can queues be made private/secure in RabbitMQ in a multitenancy system?

TLDR: The relevant information can be found here: https://www.rabbitmq.com/access-control.html. However, since the rabbitmq documentation is very verbose, below I will describe what seems like the only solution to locking down access to resources. Summary Virtual hosts As Michael Dillon mentions, you should start by making everything happen inside vhosts (virtual hosts) and block the generic … Read more

PostgreSQL Schemas — Usage Scenario/Case

I’ve seen people in my Google searches about schemas make a separate schema+tables for each online customer to their website. They have like 100,000 schemas. Q3: What am I missing here? This seems extreme to say the least. They should be adding record(s) to standard table(s) for each customer not making schemas and tables for … Read more

Creating a multi-tenant application using PostgreSQL’s schemas and Rails

Update Dec 5, 2011 Thanks to Brad Robertson and his team, there’s the Apartment gem. It’s very useful and does a lot of the heavy lifting. However, if you’ll be tinkering with schemas, I strongly suggest knowing how it actually works. Familiarize yourself with Jerod Santo’s walkthrough , so you’ll know what the Apartment gem … Read more

PostgreSQL’s schemas for multi-tenant applications

Performance isn’t worse, necessarily. As the article explains, there are specific conditions which make the schema approach better or worse depending on your application design and workload. Let me explain the tradeoffs of the “tenant-schema” vs. “shared-table” approaches: tenant-schema is best when you have a relatively small number of fairly large tenants. An example of … Read more

optimal architecture for multitenant application on django

We built a multitenancy platform using the following architecture. I hope you can find some useful hints. Each tenant gets sub-domain (t1.example.com) Using url rewriting the requests for the Django application are rewritten to something like example.com/t1 All url definitions are prefixed with something like (r’^(?P<tenant_id>[\w\-]+) A middleware processes and consumes the tenant_id and adds … Read more

Should I use a single or multiple database setup for a multi-client application? [closed]

I usually add ClientID to all tables and go with one database. But since the database is usually hard to scale I will also make it possible to run on different database instances for some or all clients. That way you can have a bunch of small clients in one database and the big ones … Read more