Multi Tenancy in Phoenix

I got a new video up on doing multi tenancy in phoenix 1.3 using Apartmentex.

Lemme know if any questions. :grinning:


Hi @Corys, great post. I have been working with this kind of approach for some time, but after read a blog post by Influitive, the creators of gem Apartment, which inspired the Apartmentex Hex Package, I started to think if this is the best approach.

After some research I found a new feature in postgreSQL that could be an alternative, Row Security Level, and a great post by 2ndQuadrant

Let us know what do you think.

1 Like

Now wha? PostgreSQL finally added RSL? I’ve been wanting that for years! Whoo hoo! I like its implementation!

1 Like

It’s a good approach, but one of the big perks of the apartment approach with schema per tenant is total separation of indexes across all tables in addition to just the isolation aspect. The approach of schema per tenant also makes it a lot easier for you to scale horizontally by tenant, or even breaking things into entirely regionalized zones. When the tenant doesn’t need access to other tenant info it’s a big perk.

You don’t necessarily need Apartment to do it, but the approach has a lot of benefits.

Yes, in Phoenix is straightforward to achieve this without the help of any package.

It’s in since 9.5

1 Like