TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How we built a back end system for Uber-like maps with animated cars

297 pointsby dcuover 8 years ago

11 comments

Animatsover 8 years ago
Nice. You have to choose between fast and realistic. If you run one fix, 15 seconds, behind real time, and compute a route between the last two fixes, the paths will look good. But, as the author points out, when you order a car, nothing will move for the first 15 seconds. The author doesn&#x27;t say how they dealt with that.<p>This is an old problem in multiplayer games. The usual solution is that the sending client predicts the position linearly from the last two fixes, and when the actual position differs from the prediction by some constant amount, it sends an update. The receiving end uses the same prediction algorithm, so its positions match the sending end with a maximum error of the same constant amount, (plus some additional error due to lag.) Updates are also sent periodically in case one gets lost, but those are not frequent.<p>Incidentally, Uber&#x27;s display of cars on a map on the home screen is totally fake.
评论 #13690715 未加载
评论 #13690815 未加载
评论 #13691176 未加载
评论 #13694013 未加载
marknadalover 8 years ago
For those interested, you can build a system like this that tracks sub-second GPS information, and easily scale to 100M+ writes for $10&#x2F;day with 1KB payload (compare to the 62bytes in the article).<p>Here is a demo we threw together of it working in real life: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;7ALHtbC9aOM" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;7ALHtbC9aOM</a><p>Here is a prototype of saving 100M+ writes for $10&#x2F;day: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=x_WqBuEA7s8" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=x_WqBuEA7s8</a><p>Our sync system: <a href="https:&#x2F;&#x2F;github.com&#x2F;amark&#x2F;gun" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;amark&#x2F;gun</a><p>And since we are on the topic, I highly recommend this engineering blog post by Discord on how they scaled up append-only writes in a way similar to how our system does: <a href="https:&#x2F;&#x2F;blog.discordapp.com&#x2F;how-discord-stores-billions-of-messages-7fa6ec7ee4c7?gi=de801bddfd20#.dzqq7q4o7" rel="nofollow">https:&#x2F;&#x2F;blog.discordapp.com&#x2F;how-discord-stores-billions-of-m...</a> .
评论 #13694114 未加载
dheeraover 8 years ago
One thing that always annoys me about the Uber UI is that the oversized cars appear to be moving horribly slowly when they are sometimes actually moving pretty fast. Every time I am waiting for an Uber I find myself wanting to scream at the driver to step on the gas and go at least more than 5 mph which is what it looks like on the UI. The scaling makes it hard to tell the actual speed of the cars and the reasons when they slow down when they actually do slow down. I don&#x27;t have a good solution to this though. Maybe:<p>- a car-game-like 3D interface where you can see the view from the driver&#x27;s seat, moving at the actual sensed speed of the car, with fake (or Street View) scenery whizzing by, so while you are waiting you can see that the driver is actually moving at close to the speed limit.<p>- render a bunch of other random cars on the road, emulating the actual real-time density of traffic, so if the guy is chugging along slowly I as the user will blame the traffic, not the app or driver<p>- render rain and snow in the 3D view if that is what is slowing the driver, so I will curse at the weather for creating an unsafe situation and not the driver for going slow<p>- render ambulances and police cars in the 3D view if a traffic accident is reported, so i will understand that a human is hurt instead of cursing at the Uber app<p>- show the state of red lights in real time so that when a driver is stopped i know it is for a red light and not lazing around or lost directions. there are enough Uber cars driving around that based on aggregate GPS statistics they should be able to determine the cycle times and phases of every traffic light on major streets.
评论 #13696252 未加载
nevi-meover 8 years ago
This is an interesting challenge, I&#x27;m building something similar for public transport, and the latency in updates tends to make things bad.<p>On browsers I&#x27;m using turf.js to calculate movements and then animate them. I calculate where the bus&#x2F;train is likely to be in the next 30 seconds, and then send that data through to the user. Then I keep updating the vehicle marker frequently until that 30 seconds time out, or until another update comes in.<p>I&#x27;m struggling to do the same on Android because I haven&#x27;t found a good turf.js equivalent there.
评论 #13689367 未加载
评论 #13689964 未加载
评论 #13690274 未加载
评论 #13690160 未加载
abusaidmover 8 years ago
Hello, a question about mapping on mobile, How can one run mobile offline map using OSM with an open source library, their screenshots doesn&#x27;t contain copyright, so am assuming their own solution.<p>thank you
评论 #13689179 未加载
评论 #13689030 未加载
m3kw9over 8 years ago
What accuracy people care is the car that you have just ordered. The other times when you see a map of cars you can get away 80% of the time using averages
perfmodeover 8 years ago
How does one manage sessions for mobile clients when communicating over UDP? Do you just save the client&#x27;s IP address and address the client by that IP? Are the IPs of mobile devices relatively stable?
iamleppertover 8 years ago
You don&#x27;t need to send the full precision lat&#x2F;lng in every update. Instead, send only the change in position from the last update (in meters), which you can calculate on the client.<p>You could also further reduce data by indexing the city into a grid, of, say 1 meter squares, or potentially a hilbert curve would be fun to experiment with.
评论 #13693709 未加载
rv11over 8 years ago
for geoindices why not use redis?
评论 #13689241 未加载
xt00over 8 years ago
&quot;Also we found challenge near Kremlin where car appeared at airport.&quot; &#x2F;s
kozikowover 8 years ago
Why not PostGIS?