An *_*ung 10 database architecture algorithm cassandra redis
我正在评估类似于Tinder的位置基础约会应用程序的后端.
经过研究,我很困惑是否有一个共同的"最佳实践"数据模型,为此算法.我的方法是使用Redis Cluster:
// Store all online users in same location (city) to a Set. In this case, store user:1 to New York set
SADD location:NewYork 1
// Store all users age to Sorted Set. In this case, user:1 has age 30
ZADD age 30 "1"
// Retrieve users in NewYork age from 20 to 40
ZINTERSTORE tmpkey 2 location:NewYork age AGGREGATE MAX
ZRANGEBYSCORE tmpkey 20 40
Run Code Online (Sandbox Code Playgroud)
我没有经验,如果数百万并发用户发生扩展,我无法预见潜在的问题.
希望任何退伍军人都能解释一下.
对于您的用例,mongodb 将是一个不错的选择。
您可以将每个用户及其当前位置存储在单个文档中。
在您想要查询的字段上创建索引,例如年龄、性别、位置
Mongodb 内置了对地理空间查询的支持,因此可以轻松找到另一个用户 1 公里半径范围内的用户。
| 归档时间: |
|
| 查看次数: |
790 次 |
| 最近记录: |