MySQL表中有20M用户,如何扩展?
虽然我目前没有它,但我有兴趣了解某人如何扩展 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
20M 记录通常被认为是“小”。根据记录的大小和执行的查询类型,您可能会在最低的服务器上获得非常好的性能。
几乎所有的服务器都可以在内存中保存这样的数据库。我们假设一条记录占用 1024 个字节,包括索引。这是一个相当大的记录,但 20M 行仍然只有 20Gb,完全适合普通服务器的 RAM。
虽然您的数据库适合 RAM,但查询可能会非常快。
但无论如何,您都需要考虑访问模式是什么。
您的
如果这两个问题的答案都是“否”,那么您可能根本不需要特殊设备。
当然你不想分片。它很复杂,它使您的应用程序变得非常复杂,并且需要大量的开发人员时间,这些时间最好花在功能上(您实际上可以将其出售给客户)
为了提高大数据的性能,按照大致的偏好顺序,您想要:
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
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: