Citus 6.1 Released–Horizontally scale your Postgres database

Microservices and NoSQL get a lot of hype, but in many cases what you really want is a relational database that simply works, and can easily scale as your application data grows. Microservices can help you split up areas of concern, but also introduce complexity and often heavy engineering work to migrate to them. Yet, there are a lot of monolithic apps out that do need to scale. If you don’t want the added complexity of microservices, but do need to continue scaling your relational database then you can with Citus. With Citus 6.1 we’re continuing to make scaling out your database even easier with all the benefits of Postgres (SQL, JSONB, PostGIS, indexes, etc.) still packed in there.

With this new release customers like Heap and Convertflow are able to scale from single node Postgres to horizontal linear scale. Citus 6.1 brings several improvements, making scaling your multi-tenant app even easier. These include:

  • Integrated reference table support
  • Tenant Isolation
  • View support on distributed tables
  • Distributed Vaccum / Analyze

All of this with the same language bindings, clients, drivers, libraries (like ActiveRecord) that Postgres already works with.

Give Citus 6.1 a try today on Citus Cloud, our fully managed database-as-a-service on top of AWS, or read on to learn more about all that’s included in this release.

Reference table support: Sharing data across tenants

Applications that are B2B fit smoothly into a model of sharding by customer. This means your customer only interacts with their own data, and all that data can be automatically co-located together–giving you all the power of SQL while still maintaining flexibility. Still in cases you may have smaller lookup or reference tables that don’t make sense to distribute. This could be something like a list of countries or an order status table. These type of tables don’t have the same large write volume as tables you’ll want to shard, but may have a relationship to them still. As of today you now have cleanly defined APIs to create these tables. To create a reference table you’d first create your table then run the function to distribute it:

-- a reference table
CREATE TABLE states (
  code char(2) PRIMARY KEY,
  full_name text NOT NULL,
  general_sales_tax numeric(4,3)
);

-- distribute it to all workers
SELECT create_reference_table('states');

Under the covers when interacting with this table we perform two phase commit (2PC) to gurantee all nodes are in a consistent state when you write/update/delete from it. This allows you to have the same data consistency guarantees as you would on a single node Postgres, without having to build extra logic into your application.

Tenant isolation: More resources for bigger tenants

Under the covers when you choose to distribute your tables multiple customers or tenants will live in the same table. Each shard is essentially just a Postgres table under the covers. This means if you were to shard something like a pageviews table by customer you would have 32 tables under the covers: pageviews_001, pageviews_002, etc. When you then insert data in your application you would insert into a normal pageviews table, and based on a hash of the customer_id it would be placed in the appropriate table.

For most data distributions this works well. Data at large enough scale that you need to shard tends to smooth out across your distributed tables–you’ll have some customers with larger datasets and some with smaller contained within one table. But, in some cases you may want even further isolation to improve performance. Citus makes this trivial by allowing you to isolate a specific tenant. To isolate your very large tenant you’d run the following which includes the table you want to isolate as well as the id of the tenant:

SELECT isolate_tenant_to_new_shard('table_name', tenant_id);

Once run the above will split the shard it was in into three shards in total. One table will contain all the lower range hash values, this tenant will live in their own table, and another table for the higher range hash values. The new shard is created on the same node as the shard from which the tenant was removed. For true hardware isolation you can then move that shard to a separate node if you see fit. And you can do this while keeping your database up and running.

View support on distributed tables

With Citus 6.0 we saw a number of customers start to leverage Citus for distributed roll-ups of data to help power real-time analytics. Once using this, we heard requests to make it easy to create various views across the entire dataset to make it easier to query within your application. Now when you create a view across a distributed table that view is automatically propagated to all of your distributed nodes.

Distributed Vaccum / Analyze

Being able to scale out all the resources your database needs, not only storage but also memory and compute is at the core of how Citus is able to give significant performance gains to applications over single node Postgres. On the compute side there’s a lot of tasks that may not happen every transaction, but do routinely such as creating indexes or vacuum. Vacuum is one operation that can be quite intensive within Postgres. In Citus 6.1 Vacuum is now distributed and run in parallel automatically across your cluster

Get started

We’re excited to continue expanding the capabilities of Citus it applies to an even broader set of use cases. You can give it a try today by creating an account on Citus Cloud or setup a local installation with Docker.

If you’re curious to learn more about how Citus might be able to help you feel free to drop us a line or join our upcoming webcast: a tour of Citus Cloud.