Multi-Tenant Applications

Many SaaS applications—especially B2B apps—are multi tenant. So the apps have a natural dimension on which to distribute data across nodes: just shard by tenant_id. Our Citus extension to Postgres enables you to scale out your database to millions of tenants, without having to re-architect your application.

Is Your SaaS Application Hitting the Limits on Single-Node Postgres?

Are your database queries taking too long?

Lorem ipsum dolor sit amet consectetur adipisicing elit. Quos consequuntur amet molestiae quidem ut. Illum, eligendi provident. Ea, id quod.

Do you have more data than you can store in single-node Postgres?

Lorem ipsum dolor sit amet consectetur adipisicing elit. Est reprehenderit repellendus impedit a in fuga obcaecati vero possimus vitae? Consequuntur, commodi?

Are you worried about whether your database infra can handle new customer signups?

Lorem ipsum dolor sit amet consectetur adipisicing elit. Ullam, magni similique, nulla pariatur vel, veritatis perspiciatis saepe aliquid necessitatibus ducimus illo quaerat odio cupiditate soluta!

Are you worried you might have to give up SQL in order to scale out your database?

Lorem ipsum dolor sit, amet consectetur adipisicing elit. Deleniti corporis odio est blanditiis inventore rem!

Does your database performance deteriorate with a high number of concurrent requests?

Lorem ipsum dolor sit amet consectetur, adipisicing elit. Praesentium voluptates blanditiis, accusamus enim atque recusandae placeat incidunt aut repellat veritatis excepturi. Itaque, a?

Are lots of your developers spending time micro-optimizing your database?

Lorem ipsum dolor sit, amet consectetur adipisicing elit. Cum, similique odio molestias aspernatur velit soluta ipsa iusto et quibusdam, est nostrum nam error, asperiores libero officiis.

Are you looking for a way to scale that doesn’t require your engineers to figure out sharding?

Lorem ipsum dolor sit amet consectetur adipisicing elit. Ut labore commodi odit mollitia molestias temporibus sapiente animi quasi, accusamus aut iste impedit, assumenda praesentium!

Is it taking you too long to analyze metrics across your customer base?

Lorem ipsum dolor sit amet consectetur adipisicing elit. Amet hic error voluptates ipsum libero porro quod laudantium rerum.

Is your largest customer creating performance issues for the rest of your customers?

Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsam illo sint laudantium perferendis consequuntur fuga, facilis consequatur voluptas aspernatur!

SQL code for scaling out

Scale Out Without Sacrificing SQL (Keep Postgres, too)

Most SaaS applications are inherently relational. By sharding on customer_id, Citus gives you the ability to scale out your database with full SQL coverage, so you don’t have to give up the relational semantics you need, like joins, foreign key constraints, transactions, ACID, consistency. By scaling out, your app gets to use a much bigger memory, compute, and disk footprint—ensuring performance even in the face of fast growth. And since Citus is an extension to Postgres, you can leverage all of your existing expertise—plus all the Postgres reliability, rich data types (think: JSON and PostGIS), Postgres extensions (our favorites include HyperLogLog), and ongoing innovation in the amazing Postgres open source community.

Icons of supported platforms

Get an Elastic Database That Works With Rails & Django

So you want a database that can handle peak workloads and boatloads of concurrent users; act as a system of record and provide business analytics; offer high availability and provide elastic scale as your customer base triples in size. Check. The icing on the cake is for the database to integrate seamlessly with your frameworks like Rails, Django, Hibernate, and Sequelize. Because Citus is an extension to Postgres, we’ve been able to build on top of the robust, existing Postgres integrations and make it easy for multi tenant apps to use Citus: recent additions include an activerecord-multi-tenant gem for Ruby on Rails, and a Python django-multitenant library for Django. More to come.

Shard re-balancer dashboard

Shard by Tenant to Scale Out Your Multi-Tenant Application

While you may have a lot of data and your SaaS database may soon be too big for single-node Postgres, it’s likely that any given customer of yours can get the database performance they need from a single node. With our Citus extension to Postgres, the database is scaled out and yet data for each of your SaaS customers is co-located on the same worker node. As you grow and sign up new customers, adding nodes (and memory, compute, and storage) to your Citus database cluster is as simple as dragging a slider in Citus Cloud. And our Citus shard rebalancer balances the workload across the cluster as you add nodes—with zero downtime.

cross-tenant queries diagram

Analyze Activity with Powerful Cross-Shard Queries

A Citus database cluster includes a coordinator node and multiple worker nodes, with Postgres and Citus installed on each node. With HA turned on in Citus Cloud, secondary nodes exist, too. Citus shards the database based on the distribution key, and distributes the shards across the worker nodes. Meanwhile, the coordinator stores metadata about the shards. All of your queries are executed via the Citus coordinator node, which transforms the query into smaller fragments that can be run independently on individual shards. The pièce de résistance: Because Citus can parallelize query fragments across multiple nodes cluster, you can run powerful cross-shard queries across all of your customer data quickly and easily.

Why Citus for Multi-Tenant SaaS Applications?

  1. Need a database with performance that can support the growth of your SaaS business.
  2. Want to take advantage of Postgres reliability, data types, extensions, toolset, & expertise.
  3. Would like an open source solution (do not want lock-in).
  4. Fully-managed cloud database fits strategy of focusing on core application & product.
  5. Citus is easy to try out: Can install & setup dev environments locally with Docker.
  1. Don’t want to give up JOINS, transactions, & consistency of relational database semantics.
  2. Don’t want to divert developers from core business app to spend eons sharding.
  3. Can’t afford opportunity cost of re-architecting SaaS app to go to NoSQL.
  4. Easier to run on a database that has direct integration with Rails & Django frameworks.
  5. Need to enable developers to experiment & analysts to analyze, without production impact.

Citus Cloud = A Fully-Managed Database As a Service

Run by a team with decades of experience managing Postgres databases in the cloud, our database as a service is ideal for SaaS data models. Hosted on AWS and available in most AWS regions, we take care of monitoring, backups, auto-HA, and seamlessly distributing Postgres across multiple nodes. One of our customers even refers to Citus Cloud as “scalability as a service.

We were able to migrate relatively easily to run on top of Citus, even though our app had zero knowledge of sharding beforehand. And now that we’re using Citus Cloud, we don’t have to worry about how to manage our growth—not even 10X growth.

Kelly Cheng, CTO at ProsperWorks

Learn More About Citus & Multi-Tenant SaaS Apps

Ready to See if Citus is Right for You?