CockroachDB Limits

Thinking of using CockroachDB for a multi-tenant service.

What are the hard and practical limits in terms of maximum number of databases and maximum number of tables?

What are the practical limits for the Go Postgres driver in terms of maximum database connections on the client side of things?


1 Like

There are no hard limits on the number of tables, but every node has a copy of the schema and metadata for every table in memory, so having a huge number of tables could cause memory problems. I’m not aware of any testing that’s been done with more than tens of tables.

I would expect Cockroach to be able to handle more client connections than PostgreSQL itself can, because goroutines are cheaper than the full processes that Postgres uses for its connections. Tools like pgbouncer and pgpool should work to concentrate client connections if it becomes an issue. But again, I don’t think anyone has done any testing for the limits in this area.

Hi Ben, I’m considering Cockroach for a multi-tenant app where each tenant would be able to customize their schema. Because of that I was thinking of creating a separate database for each tenant. But after reading your comment it seems that this can quickly cause memory issues as the number of tables in my DB is roughly multiplied by the number of tenants. What’s your advice for creating a multi-tenant setup with schema-modification capabilities for each tenant?

The schemas that the nodes hold in memory are not very big structures. I doubt that the memory use itself will become a problem until we get to millions of tables, or more. There might however be other limitations related to schema management that we don’t know about. I’d encourage you to try a simulation with the number of tables you’re expecting and telling us if you run into problems.

Ok, that’s good to hear. I’ll definitely try a simulation at some point. Will update with my findings then.

Any updates on this topic? We’re facing similar questions

Any update on this topic? We are willing to use CockroachDB for large scale multi tenant applications. Maximum number of tables and databases are important to know before using CockroachDB. I am expecting quick reply from from CockroachDB lab team members.