MySQL表中有20M用户,如何扩展?

发布于 2024-11-15 18:10:45 字数 95 浏览 2 评论 0原文

虽然我目前没有它,但我有兴趣了解某人如何扩展 MySQL 中可能拥有(比如 2000 万)用户的单个表。您会为此使用分片吗?人们可以使用哪些策略来使这种规模的单个表“可扩展”?

Although I currently do not have it, I'm interested in learning how someone would scale an individual table in MySQL that might have, say 20 million users. Is this something you would use sharding for? What are some strategies one might use to make an individual table of this magnitude "scalable" ?

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

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

发布评论

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

评论(1

锦上情书 2024-11-22 18:10:45

20M 记录通常被认为是“小”。根据记录的大小和执行的查询类型,您可能会在最低的服务器上获得非常好的性能。

几乎所有的服务器都可以在内存中保存这样的数据库。我们假设一条记录占用 1024 个字节,包括索引。这是一个相当大的记录,但 20M 行仍然只有 20Gb,完全适合普通服务器的 RAM。

虽然您的数据库适合 RAM,但查询可能会非常快。

但无论如何,您都需要考虑访问模式是什么。

您的

  • 写入速率是否非常高 - 每秒超过 100 个事务?
  • 很多硬查询/报告?

如果这两个问题的答案都是“否”,那么您可能根本不需要特殊设备。

当然你不想分片。它很复杂,它使您的应用程序变得非常复杂,并且需要大量的开发人员时间,这些时间最好花在功能上(您实际上可以将其出售给客户)

为了提高大数据的性能,按照大致的偏好顺序,您想要:

  • 购买更好的硬件(在合理范围内)
  • 减少需要存储的数据量
  • 使用水平分区
  • 使用垂直分区/功能分区
  • 获得更好的数据库引擎,可以更有效地使用现有硬件(可能的例子:Infobright,Tokutek)
  • 分片(你真的不想这样做!)

20M records is generally considered "small". Depending on the size of records and the kind of queries performed, you are likely to get very good performance on the lowliest of servers.

Almost all servers can keep such a database in memory. Let's consider that a record takes 1024 bytes, including indexes. This is quite a large record, yet 20M rows is still only 20Gb, which fits comfortably within the RAM of a modest server.

While your database fits in RAM, queries are likely to be very fast.

But in any case, you need to consider what the access patterns are.

Do you have

  • Very high write rates - more than 100 transactions per second?
  • Lots of hard queries / reports?

If the answer to both of these is "no", you probably need no special equipment at all.

Certainly you don't want to shard. It's complicated, it massively complicates your application, and will require a LOT of developer time which is better spent on features (which you can actually sell to customers)

In order to improve performance with big data, in approximate order of preference, you want to:

  • Buy better hardware (within reason)
  • Reduce the amount of data you need to store
  • Use horizontal partitioning
  • Use vertical partitioning / functional partitioning
  • Get a better database engine which can use existing hardware more efficiently (possible examples: Infobright, Tokutek)
  • Shard (you really don't want to do this!)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文