Lostsoul
Lostsoul

Reputation: 25999

In GCP Spanner, can I set a size limit of a table?

I'm exploring Multi-Tenancy with a spanner and was looking at the table approach (each customer gets a table), but I'm not sure how to enforce limits on a table. Is that possible? For example, can I say table A can be 5GB and table B can be 20GB?

I tried to find it in the API docs but I am no sure if it exists or I just was looking up the wrong things.

Is anyone aware?

Upvotes: 0

Views: 1036

Answers (2)

Robert G
Robert G

Reputation: 2055

It is not possible to place a limit on Google Cloud Spanner, whether setting a limit on the table or database.

Google Cloud Spanner uses nodes for database instances. Maximum storage for each node is 2 TB. Each node can do 1000 processing units or larger. If your project will not reach 1000 processes, it would take less than 1 node, that's around 205 GB per 100 processing units. Storage and network usage are measured in binary gigabytes or gibibytes where 240 bytes is 1024 GB or 1 TB.

Maximum number of tables that Cloud Spanner can handle is 5000 tables per database and maximum number of databases it can handle is 100 databases per instance.

Instead of limiting tables, databases or storage, Google Cloud Spanner has the ability of increase quota by following this steps on increasing quotas.

In addition, backups are stored separately and are not included in the storage limit.

You can check the full documentation on database limits under Quotas and Limits.

Upvotes: 1

Knut Olav Løite
Knut Olav Løite

Reputation: 3512

Setting a size limit for a table is not possible, so that would be something you would have to enforce in your application.

The best practice for multi-tenancy in Cloud Spanner is however that you should in most cases use a single table for all your customers and segregate these using a separate customer key in that table. See https://cloud.google.com/spanner/docs/schema-and-data-model#multitenancy for more information. There are two important reasons two follow that best-practice:

  1. It will automatically use the database and load splitting built into Cloud Spanner with zero maintenance on your side.
  2. There is a limit on the number of tables per database, which would limit the number of customers that you could have per database.

Upvotes: 1

Related Questions