📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
查看: 2002| 回复: 1
跳转到指定楼层
上一主题 下一主题
收起左侧

[题目讨论] 系统设计面试:讨论Uber backend的存储问题

🔗
pxuu | 只看该作者 |倒序浏览
全局:

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
Uber司机每4秒更新一下location,比方说有400K司机同时在线,那么#write per sec = 400K/4 = 100K. 这是一个write-heavy的问题。同时这些location又要被query得到nearby drivers,请教大神用什么storage既可以做到write fast,又可以query fast?
Uber当然有自己的solution,但是太深了,貌似不太适合面试。就算背会了,用来面试的话,明显就是背的,没有什么意义。


我的想法是,首先把latitude/longitude转化为geo-hash,然后query on geo-hash.
SQL不太合适,因为这个write speed太大了,SQL要不停地更新index,不太可用。
我搜了一下,下面的这个链接里用的是Redis,因为Redis原生支持 Sorted Sets with Range Queries 和 Geospatial Indexes with Radius Queries。
请问在面试的时候,如果不让用现成的产品,请问自己怎么设计类似的功能?大佬们可不可以shed点light?

https://djangostars.com/blog/bui ... tion-based-service/
Data storage — Live location
To process the live driver coordinates, we opted for GEOADD – a Redis command that adds geospatial data — longitude, latitude, and name — to the specified item. The data is stored as a sorted set. When required, we can retrieve the required items (location data) using the query by radius (the above mentioned GEORADIUS).
After an item is added to the set, Redis lets us update its location using the same GEOADD command. When called with existing items in the list, GEOADD updates the spatial data (longitude and latitude) associated with each item with the new values. This allowed us to provide live locations in the application.


上一篇:关于LoadBalancer的不同算法
下一篇:讨论打车软件的DB设计
🔗
iuysyjdmuvew 2021-6-28 10:47:30 | 只看该作者
全局:
不可能不让用redis的,这就是一个memory key value store,肯定可以用的 我觉得就用redis存就好了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表