开发者

Is there a way or technology to implement database resource allocation based on user?

开发者 https://www.devze.com 2023-04-10 01:33 出处:网络
Typically, when platforms want to provide database resource to user (developer) for applications development, they use limit database access APIs to restrict behaviors of the application, in order to

Typically, when platforms want to provide database resource to user (developer) for applications development, they use limit database access APIs to restrict behaviors of the application, in order to enforce some constraints on resources occupied, an example is social API.

Is there a same way that we can implement and use in database layer, nor application layer. If then, we just need to assign database quota for specific user and let database handle the resource usage. Furthermore, it's better to have some programming APIs fr开发者_JAVA技巧om database server to support this.

I found some similar questions, as follow:

  • Oracle [might has]: Is there a way to throttle or limit resources used by a user in Oracle?
  • MySQL [no]: https://serverfault.com/questions/124158/throttle-or-limit-resources-used-by-a-user-in-a-database
  • SQL Server [not sure]: Databases with utilization constraints

Since i am focus on open source solutions, how about PostgreSQL or NoSQL? As open source database, I think PostgreSQL compares better favourably with Oracle.


With MySQL (which is currently released under the open source GPL license), you can impose the following resource limits inside the database:

The number of queries that an account can issue per hour

The number of updates that an account can issue per hour

The number of times an account can connect to the server per hour

The number of simultaneous connections to the server by an account

For postgres, their wiki states:

PostgreSQL has no facilities to limit what resources a particular user, query, or database consumes, or correspondingly to set priorities such that one user/query/database gets more resources than others. It's necessary to use operating system facilities to achieve what limited prioritization is possible.

But the question to me really is -- no matter which database is used -- what is the expectation when a user exceeds their limits? If the database enforces limits, should queries beyond those limits simply return an error and cause the application to fail? I'd suspect that this might have unexpected negative impacts on the applications. It's hard to say what will happen when suddenly the database starts returning errors.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号