The Genius System Behind the Uber App’s Real-Time Map — Transcript
Full transcript
- 0:00We've all done it. You open the Uber
- 0:01app, enter your location and desired
- 0:03destination, and then click a button to
- 0:04get a ride. From this point on, two
- 0:07things happen. On the one hand, your
- 0:09location as the rider is shared with
- 0:11Uber. And on the other hand, nearby
- 0:13drivers positions are shared with you.
- 0:15And what seems like such a simple thing
- 0:17comes with massive complexities on
- 0:19Uber's end to make this system work
- 0:21fluently for hundred millions of users.
- 0:24How does the Uber app on back end really
- 0:26achieve to update it so fluently for
- 0:28this many drivers even in bad network
- 0:30conditions? Let's take a look. Uber must
- 0:32keep millions of driver devices, rider
- 0:35devices, and backend services in sync in
- 0:37near real time. And originally, Uber
- 0:39stick to an approach that ended up
- 0:41getting them into huge problems. Back
- 0:43then, they've actually implemented a
- 0:44polling based approach where the app
- 0:46simply asks the server for new data. So
- 0:48in a simple loop, the client has asked
- 0:50the server things like, "Hey, are there
- 0:52new locations for nearby drivers? Are
- 0:53there new locations? Are there new
- 0:55locations?" So this was Uber going full
- 0:57founders mode. But it was clear that
- 0:59this approach won't scale. On the one
- 1:01hand, every polling request made that
- 1:03way that does not result in new data for
- 1:06the client is in the end unnecessary
- 1:07load for the server. It also drains a
- 1:09lot of battery. It comes with a lot of
- 1:11overhead because every polling request
- 1:13adds additional headers to the request.
- 1:15And what this has led to at some point
- 1:17is that 80% of network requests made to
- 1:19Uber server from the app were polling
- 1:21calls. It has also made the cold startup
- 1:24time of the app skyrocket because
- 1:26multiple concurrent polling calls were
- 1:28competing which prevented the app from
- 1:30rendering UI because the data came from
- 1:32the polling calls. And as a result of
- 1:33these polling problems, Uber has moved
- 1:35to a pushbased communication approach.
- 1:38So instead of the client asking for new
- 1:40data, the server now pushes it to the
- 1:43client once it's available. And for that
- 1:45they've created ramen. Okay, not
- 1:47actually instant noodles. Ramen stands
- 1:50for realtime asynchronous messaging
- 1:52network. And in theory this works much
- 1:55better, but still comes with challenges.
- 1:58So now instead of the client blindly
- 1:59asking for new data, they needed logic
- 2:02deciding when to push, what to push, and
- 2:05how to push that data to the client. And
- 2:07for a scaling infrastructure, they
- 2:09decided to separate these three
- 2:11responsibilities. First of all, they've
- 2:13introduced Firewall, which is a micros
- 2:15service responsible for the decision
- 2:16behind when to push. So, it's really
- 2:19just a service that listens to all kinds
- 2:20of different events and then decides if
- 2:22it's worth pushing an update to the
- 2:23client. So, these events could be a user
- 2:26requesting a ride. This could be a
- 2:28driver accepting a ride. It could be a
- 2:30new location of a rider or a driver. And
- 2:32while locations may change very
- 2:34frequently, not every little change
- 2:36definitely has to be sent. So Fireball
- 2:37may compare a new location with a
- 2:39previous one and only send the new one
- 2:41if it has changed enough, for example.
- 2:43[music] And when Fireball then decides
- 2:45that a push should happen, it takes this
- 2:47information and it sends it to Uber's
- 2:48API gateway. This gateway now has the
- 2:51purpose to take a look at that minimal
- 2:53push data and gather the entire data
- 2:55necessary for the client. For example,
- 2:57the users locale, the operating system
- 2:59they use, and so on. Finally, the client
- 3:01then connects directly to the ramen
- 3:03server, which pushes the determine
- 3:05payload to the client. How does Ramen
- 3:07actually work internally? Well,
- 3:08originally it was built on top of SS.
- 3:11So, server sent events and ramen is in
- 3:13the end just a protocol, a technology
- 3:15built on top of that that makes sure
- 3:17that at least once delivery is
- 3:18guaranteed. So that events being pushed
- 3:20to the client will definitely also
- 3:21arrive there. Nowadays, however, they've
- 3:23migrated it to use gRPC as it allows
- 3:26sending messages from both client and
- 3:28server. So, it's not just a pushbased
- 3:30approach anymore where just the server
- 3:31can push data to the client at any time,
- 3:33but the client can also share data with
- 3:35the server that way. So this
- 3:36infrastructure now allows Uber to push
- 3:38data to clients efficiently. However,
- 3:40there was still a big challenge. Uber in
- 3:42the end receives realtime updates for
- 3:44millions of locations around the world
- 3:47every minute. So how do you actually
- 3:49send just the locations a specific
- 3:51client cares about? So exactly those of
- 3:54nearby drivers of that client app? One
- 3:56approach you may think could work is to
- 3:57simply take a look at the riders
- 3:58position and then calculate the distance
- 4:00to all drivers positions to only show
- 4:02those in a given [music] radius. But as
- 4:04you can imagine, at high scale,
- 4:06calculating millions of distances for
- 4:08millions of active riders results in
- 4:10unmanageable load for the server. So
- 4:12instead, Uber actually came up with a
- 4:15much much more genius approach called
- 4:17spatial partitioning. And the idea
- 4:19behind that is really to take a
- 4:20geographic space and then divide it into
- 4:22smaller regions where we can then take a
- 4:24driver's position and map it to a clear
- 4:26region. since this way we don't have to
- 4:29calculate millions of distances anymore
- 4:31but just check which drivers are in our
- 4:33region and the ones around it. Splitting
- 4:36up the world into squares however has a
- 4:38major problem and it is that squares
- 4:41don't have the same distance to all the
- 4:43neighbors which can lead to what we call
- 4:44corner bias since squares diagonal to
- 4:47the one you're looking at are further
- 4:49away than squares to the top of it or to
- 4:51the left and right. Wouldn't it be much
- 4:53better if we could simply query nearby
- 4:55drivers based on at least an approximate
- 4:57radius? And that is why Uber has created
- 4:59H3, which is an open-source hexagonal
- 5:02spatial index. So instead of dividing
- 5:04the world into squares, it divides it
- 5:06into a honeycom of hexagons, each really
- 5:09having the same distance to all of its
- 5:11neighbors. So given any GPS coordinate,
- 5:13H3 computes which hexagon it's in, and
- 5:16then returns that H3 index. And instead
- 5:18of computing distances for every driver,
- 5:20you instead ask for the so-called K
- 5:22ring. So those hex's within K steps of
- 5:25your rider cell. So for example, if K is
- 5:28equal to one, then that includes the
- 5:29first layer of neighbors making up seven
- 5:31cells in total. If K is equal to two,
- 5:33then the second layer of neighbors is
- 5:35also included. And this new system
- 5:37effectively brings down the time
- 5:39complexity from O of N where N could
- 5:42literally be millions of active drivers
- 5:44to O of K^ squ plus O of M where K is
- 5:48the radius and M is the number of nearby
- 5:50drivers.
- 5:51So this means if there are 100 nearby
- 5:53drivers, Uber now only has to iterate
- 5:55over those 100 drivers instead of
- 5:57possibly millions. And the genius thing
- 5:59behind this new strategy is not just
- 6:02that it can be used for finding nearby
- 6:04drivers, but actually for so so much
- 6:06more that is important to Uber. [music]
- 6:08For example, to create dynamic pricing
- 6:10zones for predicting the estimated time
- 6:12of arrival or for things like
- 6:14forecasting demand. And now that spatial
- 6:17index helps Uber to really optimize load
- 6:19on the server side since when receiving
- 6:21a rider's location, the server can now
- 6:22look up nearby drivers positions much
- 6:24faster and therefore give the client a
- 6:26faster response. This however is only
- 6:28one side of the metal. Especially with a
- 6:30mobile app, you can't count on its
- 6:32internet connection being super stable
- 6:34at all times. And in the case of a ride
- 6:36sharing app like Uber, it's completely
- 6:37expected that most people using it
- 6:39aren't at home and therefore likely
- 6:41won't connect via stable Wi-Fi
- 6:42connection, but much more likely a
- 6:44cellular one. So, how did Uber's
- 6:46engineers optimize the mobile app to run
- 6:48super smoothly even under bad network
- 6:51conditions? And here there are two
- 6:52things that have to be looked at. First
- 6:54of all, how do we actually minimize the
- 6:56network latency between mobile app and
- 6:58server? And second, how do we make sure
- 7:02the app still feels fluent even when not
- 7:04receiving many GPS updates? Let's start
- 7:06with keeping network traffic fast. Here,
- 7:09Uber actually sticks to so-called edge
- 7:10servers. And those are really nothing
- 7:12else than hundreds, if not thousands of
- 7:14servers spread around the globe where
- 7:16each server is responsible for nearby
- 7:18users. So instead of a user in Berlin
- 7:21talking to a server in California, Uber
- 7:23instead uses service relatively close,
- 7:25for example, in Frankfurt. And these
- 7:26edge servers then not only serve as a
- 7:28primary entry point for requests for
- 7:30nearby drivers and users, but also cache
- 7:32all kinds of relevant data, so data
- 7:34access is even faster. And when
- 7:36considering a typical 4G connection,
- 7:38this change alone can result in requests
- 7:40being approximately 100 milliseconds
- 7:42faster when talking to a closed local
- 7:44server versus one that is 10,000 km
- 7:47away. However, even with closed servers,
- 7:49there is no guarantee that new location
- 7:51data arrives reliably at the same
- 7:52intervals. [music]
- 7:53In mobile apps, you in the end always
- 7:55need to account for connection drops at
- 7:57any time. So, let's imagine the Uber app
- 7:59now receives three location updates from
- 8:00a driver over the period of 20 seconds.
- 8:03Our goal is now to not make the location
- 8:05jump from one coordinate to another when
- 8:07a new location is received from the
- 8:08server. So instead, we need a way to
- 8:10take a look at a few known locations and
- 8:12use that information to kind of predict
- 8:14what is likely the new current location
- 8:16of the driver, even if it doesn't send a
- 8:19new one. And for that, Uber uses what we
- 8:21call that reckoning, which really tries
- 8:23to predict where the driver should be if
- 8:26they kept the last known speed and
- 8:28direction. This is then used in
- 8:29combination with so-called Kelman
- 8:31filters, which combines these predicted
- 8:33coordinates with real measured
- 8:34coordinates. [music] And that's in the
- 8:36end what makes the car marker move
- 8:38around smoothly even when a new measured
- 8:40coordinate is quite different than the
- 8:41last predicted one. But I actually also
- 8:43have something for the conspiracy
- 8:44theorists among you. There are actually
- 8:46claims and discussions about Uber
- 8:48showing fake cars in the mobile app.
- 8:50cars that don't even exist. Because if
- 8:52we think about it, for cars that don't
- 8:54even exist, [music]
- 8:55you obviously don't have to listen to
- 8:57serverside location updates, and you
- 8:59could also artificially make more
- 9:01drivers appear to riders to not show
- 9:03them a dead area, which may make them
- 9:04open a competitor's app. This phenomenon
- 9:06of phantom cars is however something
- 9:08that Uber denies. But what this shows is
- 9:10that most simple looking interfaces
- 9:12often have the most complex back ends,
- 9:14especially when things really have to
- 9:16scale. And with this video, I really
- 9:17tried something new here and a lot of
- 9:19work went into this video and that is
- 9:21why I need your feedback here. Is there
- 9:23anything that wasn't clear? Uh would you
- 9:24like to see more such videos every now
- 9:26and then? And if so, which app would you
- 9:28like me to take a look at next? So, if
- 9:30mobile development and especially with
- 9:31cotton is a thing for you, then
- 9:33subscribe for all kinds of in-depth
- 9:35tutorials about that. Thanks so much for
- 9:37watching. I will see you back in the
- 9:38next one. Have an amazing rest of your
- 9:39week. Bye-bye.
About this transcript
This page contains the full transcript of The Genius System Behind the Uber App’s Real-Time Map by Philipp Lackner, generated from the public captions YouTube serves with the video. The transcript has 1,967 words across 291 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.