MySQL 中数千种模式的优化

发布于 2024-10-08 20:44:39 字数 330 浏览 0 评论 0原文

我有一个应用程序,它将隔离(和分片)的用户数据存储在单独的 MySQL 模式(也称为数据库)中,具有相同的表结构(3 个 InnoDB 表),每个帐户一个。我们使用 Amazon RDS 来存储数据,目前每个 RDS 实例大约有 30k 个架构。我的问题是如何针对大量模式优化 MySQL 设置(或就 RDS 而言,参数组设置)。

我知道人们本能地谴责拥有数千个相同模式的做法,建议改为使用一个具有索引“account_id”列之类的模式。通常给出的论点是,分片行走或模式更改的惩罚超过了好处。在我们的例子中,我们需要保持数据隔离,并且不同帐户之间不存在任何交互。

在这种情况下,有哪些方法可以最大限度地提高性能?

I have an application that stores isolated (and sharded) user data in separate MySQL schemas (aka databases) with with identical table structure (3 InnoDB tables), one for each account. We're using Amazon RDS to store the data and there are currently about 30k schemas per RDS instance. My question is about how to optimize the MySQL settings (or in terms of RDS, the Parameter Group settings) for a large number of schemas.

I know there is a reflex to condemn the practice of having thousands of identical schemas, suggesting instead that there be a single schema with something like an indexed "account_id" column. The argument generally given is that the penalty for shard-walking or schema changes outweigh the benefits. In our case, we need to keep the data isolated and there is never any interaction between different accounts.

What are some ways to maximize performance in a situation like this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧时光的容颜 2024-10-15 20:44:39

提前警告:我对Amazon RDS一无所知,所以这个答案可能绝对是无稽之谈。我是从通用 MySQL 的角度来回答的。

嗯,您的设置并不完全是最佳的,但是有一些方法可以对其进行调整。您希望防止过于频繁地打开/关闭表,因此您希望同时打开许多表。

为此:

  • 确保您的操作系统允许 MySQL 有大量打开的文件
  • 设置 table_cache 正确

您可以在 MySQL 手册

您实际想要的限制有多高取决于您的资源限制。每个打开的表都会占用内存 - 我不确定有多少。类似于调整入门mysqltuner.pl 可以帮助您防止内存过度使用。

Warning in advance: I have no clue about Amazon RDS, so this answer may be absolute nonsense. I am answering from a generic MySQL perspective.

Well, your setup is not entirely optimal, but there are some ways to tune it. You want to prevent opening/closing tables too often, so you want a lot of tables open at the same time.

To do this:

  • Make sure your OS allows MySQL to have a lot of open files
  • Set the table_cache properly

You can find some more references in the MySQL manual.

How high you actually want this limit depends on the constraints of your resources. Each open table takes memory - I'm not sure how much. A script like the tuning primer or mysqltuner.pl can help you to prevent overcommitting your memory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文