您将如何使用 Azure 表存储来处理类似 Twitter 的应用程序?
我正在考虑在一个非常简单的类似 Twitter 的应用程序中,我正在考虑仅支持推特和时间线。
但我的头脑已经习惯了关系模型……无法在 Azure 表或 noSql 中提出合理的模型。基本上,我在想:
- 用户可以将其他用户添加为 朋友们。
- 用户可以写消息(最多 200 人物)。
- 消息始终按以下顺序显示 时间,最新的在前。
- 用户页面显示他的最后 20 消息。
- 主页(时间线)显示 他和他的人的最后 20 条消息 朋友们。
非常简单:D
如果我将所有消息放在一个表中,并将 userId 作为分区键...一切都很简单,但是...我认为该解决方案的扩展性不是很好。但其他解决方案使时间线页面变得非常复杂或非常低效,因为它不是要从每个朋友那里获取最新的 20 条消息,而是要从所有人那里获取最新的 20 条消息……这让我大吃一惊。可能您有一个非常烦人的朋友,而最新的 20 条消息来自他:D
什么是一种可扩展且高效的方法来以 Azure 表的方式存储此信息?
提前致谢。
I was thinking in a very simple Twitter-like app, I was considering support just twits and the time line.
But my head, pretty much used to relational models... cannot come up with an reasonable model in Azure tables or noSql. Basically, I was thinking in:
- A user can add other users as
friends. - A user can write messages (up to 200
characters). - Messages are always shown ordered by
time, the newest the first. - The user page shows his last 20
messages. - The main page (time line) shows the
last 20 messages from him and his
friends.
Pretty simple :D
If I put all messages in a single table, and I put the userId as partition key... everything is easy, BUT ... I don't think that that solution scales very well. But other solutions make the time line page very complex or very unefficient, because it's not about get the latest 20 messages from every of your friends, it's about get the latest 20 from all together... and that is blowing my mind. It could be that you have a very annoying friend and the latest 20 messages are from him :D
What could be a scalable and efficient way to store this information in a Azure tables fashion?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想说仅使用 Azure 表存储是不够的。您还应该使用 Azure 队列。
当消息进来时,它被放入队列中。工作人员从队列中获取消息并处理它们。
这似乎可能是一种浪费的方法,但您正在优化读取性能并实现写入的最终一致性。从读取端删除连接可以简化事情。
I'd say using Azure Table Storage alone isn't enough. You should use Azure Queues as well.
When a message comes in it gets put in the queue. A worker takes the messages from the queue and processes them.
It seems like this might be a wasteful method but you're optimizing for read performance with eventual consistency on the writes. Removing joins from the read side simplifies things.