Resource limitation per tenant

If one takes database as a tenant, how to limit resources usage like CPU, RAM and iops per database? I only found how to set connection limit when creating database, but nothing about limiting resources utilization. Could you give advice on how to achieve it?

Hi @olivan139

This is not currently possible. I don’t know of any database on the market that offers this though.

Custom coding. Or using containers/cgroups and have separate servers/processes for each tenant.

Greenplum offers resource groups and users can be assigned to these groups. So adding all users which have access to a tenant (database) will be limited in using resources. So I thought that you might have smth similar :slight_smile:

What do you think, where is the best place to add this logic in code?

If database is taken as a tenant, then I guess separating it by server will be not that effective. But I am interested in processes. If limiting resources to processes, than how to separe them by database?

As a possible solution, you can consider a mix of tablespaces and partitions. For example, you can create a multi-node YugabyteDB cluster. Then assign each node to one of the custom tablespaces. After that, create partitions for each tenant and pin those partitions to respective tablespaces.

As a result, you’ll have a cluster of nodes with each node(s) storing data and serving traffic for a particular tenant.

1 Like

Also we’d like to add this functionality in our version. First step is to limit disk space per database and as soon as we add this functionality, we can make a PR in github, if you are interested in it.

Looks like Greenplum uses cgroups too from their docs.

See Contribute to YugabyteDB | YugabyteDB Docs. It’s best to create an issue with the design of the feature before making a PR.

Before that you probably need to calculate the size of the db [YSQL] Support for pg_database_size() · Issue #19158 · yugabyte/yugabyte-db · GitHub, so I guess you can start on this.