小编An *_*ung的帖子

基于位置的水平可伸缩约会app数据库模型

我正在评估类似于Tinder的位置基础约会应用程序的后端.

  • 应用功能显示附近的在线用户(性别和年龄过滤器)
  • 一些数据库引擎是Redis,Cassandra,MySQL Cluster
  • 应用程序应通过在高流量时间添加节点来水平扩展

经过研究,我很困惑是否有一个共同的"最佳实践"数据模型,为此算法.我的方法是使用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)

我没有经验,如果数百万并发用户发生扩展,我无法预见潜在的问题.

希望任何退伍军人都能解释一下.

database architecture algorithm cassandra redis

10
推荐指数
1
解决办法
790
查看次数

标签 统计

algorithm ×1

architecture ×1

cassandra ×1

database ×1

redis ×1