Python Multitenancy Patterns — ELI5

Imagine an apartment building. Lots of families live there, each in their own unit. They share the same building, the same hallways, the same plumbing system. But each family has their own front door with their own lock. Family A can’t walk into Family B’s apartment. Their mail goes to separate mailboxes. Their electricity is metered separately.

Multitenancy is your Python app being that apartment building.

When a company builds software (like a project management tool or an accounting app), they don’t build a separate copy for every customer. That would be like building a brand-new house for every family — incredibly expensive and impossible to maintain.

Instead, they build one app that serves everyone. Company A logs in and sees their projects. Company B logs in and sees their projects. They’re using the same app running on the same servers, but each company only sees their own stuff.

Each company is called a tenant — like a tenant in an apartment.

The tricky part is keeping everything separate:

  • Company A’s data should never leak to Company B
  • Company A going crazy with usage shouldn’t slow down Company B
  • Company A’s custom settings shouldn’t affect Company B

Just like in an apartment building — if one family is having a loud party, ideally the soundproofing keeps the neighbors peaceful. If one family uses too much water, each unit has its own meter so others don’t pay for it.

One thing to remember: Multitenancy means one application serving many customers, where each customer’s data and experience is isolated — like separate apartments in one building.

pythonarchitecturesaas

See Also