SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
Daniel Hochman, Engineer
@
Geospatial Indexing at Scale
The 10 15 Million QPS Redis Architecture Powering Lyft
Agenda
Case Study: scaling a geospatial index
- Original Lyft architecture
- Migrating to Redis
- Iterating on data model
Redis on the Lyft platform
- Service integration
- Operations and monitoring
- Capacity planning
- Open source work and roadmap
Q&A
API
Monolith
PUT /v1/locations
5 sec
loop
{
"lat": 37.61,
"lng": -122.38
}
{
"drivers": [ ... ],
"primetime": 0,
"eta": 30,
...
}
200 OK
Index on users collection
(driver_mode, region)
Lyft backend in 2012
Location stored on user record
Monolithic architecture issues
Global write lock, not shardable, difficult refactoring, region boundary issues
drivers_in_region = db.users.find(
driver_mode: {$eq: True},
region: {$eq: "SFO"},
ride_id: {$eq: None}
)
eligible_drivers = sort_and_filter_by_distance(
drivers_in_region, radius=.5
)
dispatch(eligible_drivers[0])
Horizontally scalable
and highly available
from day zero
Unwritten architecture rule at Lyft
nutcracker
locations_cluster:
listen: locations.sock
distribution: ketama
hash: md5
eject_hosts: true
failure_limit: 3
servers:
- 10.0.0.1:6379:1
- 10.0.0.2:6379:1
...
- 10.0.0.255:6379:1
Redis Cluster
.
.
.
n shards
Application Instance
Nutcracker overview
Ketama provides consistent hashing!
Lose a node, only lose 1/n data
nutcracker
Pipelining
PIPELINE (
HGETALL foo
SET hello world
INCR lyfts
)
RESPONSE (
(k1, v1, k2, v2)
OK
12121986
)
md5(foo) % 3 = 2
md5(hello) % 3 = 0
md5(lyfts) % 3 = 2
0: SET hello world
0
1
2
2: PIPELINE (
HGETALL foo
INCR lyfts
)
return ordered_results
1. hash the keys
2. send concurrent requests to backends
3. concatenate and return results
location = json.dumps({'lat': 23.2, 'lng': -122.3, 'ride_id': None})
with nutcracker.pipeline() as pipeline:
pipeline.set(user_id, location) # string per user
if driver_mode is True:
pipeline.hset(region_name, user_id, location) # hash per region
Parity data model
Fetching inactive drivers when doing HGETALL. Network and serialization
overhead. The obvious fix? Expiration.
Hash expiration
- pipeline.hset(region_name, user_id, location) # hash per region
# hash per region per 30 seconds
bucket = now_seconds() - (now_seconds() % 30)
hash_key = '{}_{}'.format(region_name, bucket)
pipeline.hset(hash_key, user_id, location)
pipeline.expire(hash_key, 15)
Expiring a hash
HGETALL current bucket plus next and previous to handle clock drift and boundary
condition, merge in process.
12:00:00 12:00:30 12:01:00 12:01:30 ...
Region is a poor hash key (hot shards)
Bulk expiration blocks Redis for longer than expected
Redis used for inter-service communication with new dispatch system
Growing pains
Let's fix it!
Redis is used for inter-service communication
- Replicate existing queries and writes in new service
- Replace function calls that query or write to Redis with calls to new service
- With contract in place between existing services and new service, refactor data model
- Migrate relevant business logic
Proper service communication
fd
a
Region is a poor hash key
Geohashing is an algorithm that provides arbitrary precision with gradual precision degradation
Geohashing
b c
d e f
ihg
>>> compute_geohash(lat=37.7852, lng=-122.4044, level=9)
9q8yywefd
fa fb fc
fe ff
fifhfg
Google open-sourced an alternative geohashing algorithm, S2
loc = {'lat': 23.2, 'lng': -122.3, 'ride_id': None}
geohash = compute_geohash(loc['lat'], loc['lng'], level=5)
with nutcracker.pipeline() as pipeline:
# string per user
pipeline.set(user_id, json.dumps(loc))
# sorted set per geohash with last timestamp
if driver_mode is True:
pipeline.zset(geohash, user_id, now_seconds())
pipeline.zremrangebyscore(geohash, -inf, now_seconds() - 30) # expire!
Data model with geohashing
Sorted set tells you where a driver might be. Use string as source of truth.
On query, look in neighboring geohashes based on desired radius.
Why not GEO?
Stable release in May 2016 with Redis 3.2.0
Point-in-radius, position of key
Uses geohashing and a sorted set under-the-hood
No expiration or sharding
No metadata storage
Great for prototyping
Much more data model complexity behind the scenes
- Additional metadata
- Writing to multiple indices to lower cost of high frequency queries
- Balancing scattered gets and hot shards with geohash level
GEOADD
GEODIST
GEOHASH
GEOPOS
GEORADIUS
GEORADIUSBYMEMBER
Redis on the Lyft platform
Creating a new cluster is a self-service process that takes
less than one engineer hour.
2015: 1 cluster of 3 instances
2017: 50 clusters with a total of 750 instances
Cluster creation
Golang and Python are the two officially supported backend languages at Lyft
Python features
- Fully compatible with redis-py StrictRedis
- Stats
- Retry
- Pipeline management for interleave and targeted retry
from lyftredis import NutcrackerClient
redis_client = NutcrackerClient('locations')
Internal libraries
{% macro redis_cluster_stats(redis_cluster_name, alarm_thresholds) -%}
Observability
Capacity planning
Combine APIs and stats for global capacity plan
- Difficult to track 50 clusters
- Google Sheets API for display
- Internal stats for actual usage, EC2 API for capacity
- Automatically determine resource constraint (CPU, memory, network)
- Currently aim for 4x headroom due to difficulty of cluster resize
- At-a-glance view of peak resource consumption, provisioned resources, cost, resource constraint
Object serialization
Benefits
- Lower memory consumption, I/O
- Lower network I/O
- Lower serialization cost to CPU
708 bytes
69%
1012 bytes
(original)
190 bytes
18%
Nutcracker issues
- Deprecated internally at Twitter and unmaintained
- Passive health checks
- No hot restart (config changes cause downtime)
- Difficult to extend (e.g. to integrate with service discovery)
- When EC2 instance of Redis dies, we page an engineer to fix the problem
The road ahead
Open-source C++11 service mesh and edge proxy
As an advanced load balancer, provides:
- Service discovery integration
- Retry, circuit breaking, rate limiting
- Consistent hashing
- Active health checks
- Stats, stats, stats
- Tracing
- Outlier detection, fault injection
Envoy was designed to be extensible!
What is Envoy?
envoy
by
In production at Lyft as of May 2017
Support for INCR, INCRBY, SET, GET (ratelimit service)
Service discovery integration (autoscaling!)
Active healthcheck using PING (self-healing!)
Pipeline splitting, concurrency
Basic stats
Introducing Envoy Redis
Envoy Redis Roadmap
Additional command support
Error handling
Pipeline management features
Performance optimization
Replication
- Failover
- Mitigate hot read shard issues with large objects
- Zone local query routing
- Quorum
- Protocol overloading? e.g. SET key value [replication factor] [timeout]
More!
Q&A
- Thanks!
- Email technical inquiries to dhochman lyft.com
- Participate in Envoy open source community! lyft/envoy
- Lyft is hiring. If you want to work on scaling problems in a fast-moving, high-growth
company visit https://www.lyft.com/jobs

Contenu connexe

Tendances

HBaseCon 2015: HBase Performance Tuning @ Salesforce
HBaseCon 2015: HBase Performance Tuning @ SalesforceHBaseCon 2015: HBase Performance Tuning @ Salesforce
HBaseCon 2015: HBase Performance Tuning @ SalesforceHBaseCon
 
Building a Data Pipeline using Apache Airflow (on AWS / GCP)
Building a Data Pipeline using Apache Airflow (on AWS / GCP)Building a Data Pipeline using Apache Airflow (on AWS / GCP)
Building a Data Pipeline using Apache Airflow (on AWS / GCP)Yohei Onishi
 
Stl meetup cloudera platform - january 2020
Stl meetup   cloudera platform  - january 2020Stl meetup   cloudera platform  - january 2020
Stl meetup cloudera platform - january 2020Adam Doyle
 
Using LLVM to accelerate processing of data in Apache Arrow
Using LLVM to accelerate processing of data in Apache ArrowUsing LLVM to accelerate processing of data in Apache Arrow
Using LLVM to accelerate processing of data in Apache ArrowDataWorks Summit
 
SeaweedFS introduction
SeaweedFS introductionSeaweedFS introduction
SeaweedFS introductionchrislusf
 
Hadoop Overview & Architecture
Hadoop Overview & Architecture  Hadoop Overview & Architecture
Hadoop Overview & Architecture EMC
 
Introduction to Map Reduce
Introduction to Map ReduceIntroduction to Map Reduce
Introduction to Map ReduceApache Apex
 
The Columnar Era: Leveraging Parquet, Arrow and Kudu for High-Performance Ana...
The Columnar Era: Leveraging Parquet, Arrow and Kudu for High-Performance Ana...The Columnar Era: Leveraging Parquet, Arrow and Kudu for High-Performance Ana...
The Columnar Era: Leveraging Parquet, Arrow and Kudu for High-Performance Ana...DataWorks Summit/Hadoop Summit
 
Improving Hadoop Cluster Performance via Linux Configuration
Improving Hadoop Cluster Performance via Linux ConfigurationImproving Hadoop Cluster Performance via Linux Configuration
Improving Hadoop Cluster Performance via Linux ConfigurationAlex Moundalexis
 
From airflow to google cloud composer
From airflow to google cloud composerFrom airflow to google cloud composer
From airflow to google cloud composerBruce Kuo
 
Kafka replication apachecon_2013
Kafka replication apachecon_2013Kafka replication apachecon_2013
Kafka replication apachecon_2013Jun Rao
 
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요Jo Hoon
 
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
The Rise of ZStandard: Apache Spark/Parquet/ORC/AvroThe Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
The Rise of ZStandard: Apache Spark/Parquet/ORC/AvroDatabricks
 
Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & FeaturesDataStax Academy
 
HBase and Hadoop at Adobe
HBase and Hadoop at AdobeHBase and Hadoop at Adobe
HBase and Hadoop at AdobeCosmin Lehene
 
Introduction to HiveQL
Introduction to HiveQLIntroduction to HiveQL
Introduction to HiveQLkristinferrier
 

Tendances (20)

HBaseCon 2015: HBase Performance Tuning @ Salesforce
HBaseCon 2015: HBase Performance Tuning @ SalesforceHBaseCon 2015: HBase Performance Tuning @ Salesforce
HBaseCon 2015: HBase Performance Tuning @ Salesforce
 
Node Labels in YARN
Node Labels in YARNNode Labels in YARN
Node Labels in YARN
 
Building a Data Pipeline using Apache Airflow (on AWS / GCP)
Building a Data Pipeline using Apache Airflow (on AWS / GCP)Building a Data Pipeline using Apache Airflow (on AWS / GCP)
Building a Data Pipeline using Apache Airflow (on AWS / GCP)
 
The Stream Processor as a Database Apache Flink
The Stream Processor as a Database Apache FlinkThe Stream Processor as a Database Apache Flink
The Stream Processor as a Database Apache Flink
 
Stl meetup cloudera platform - january 2020
Stl meetup   cloudera platform  - january 2020Stl meetup   cloudera platform  - january 2020
Stl meetup cloudera platform - january 2020
 
Using LLVM to accelerate processing of data in Apache Arrow
Using LLVM to accelerate processing of data in Apache ArrowUsing LLVM to accelerate processing of data in Apache Arrow
Using LLVM to accelerate processing of data in Apache Arrow
 
SeaweedFS introduction
SeaweedFS introductionSeaweedFS introduction
SeaweedFS introduction
 
Hadoop Overview & Architecture
Hadoop Overview & Architecture  Hadoop Overview & Architecture
Hadoop Overview & Architecture
 
Introduction to Map Reduce
Introduction to Map ReduceIntroduction to Map Reduce
Introduction to Map Reduce
 
The Columnar Era: Leveraging Parquet, Arrow and Kudu for High-Performance Ana...
The Columnar Era: Leveraging Parquet, Arrow and Kudu for High-Performance Ana...The Columnar Era: Leveraging Parquet, Arrow and Kudu for High-Performance Ana...
The Columnar Era: Leveraging Parquet, Arrow and Kudu for High-Performance Ana...
 
Improving Hadoop Cluster Performance via Linux Configuration
Improving Hadoop Cluster Performance via Linux ConfigurationImproving Hadoop Cluster Performance via Linux Configuration
Improving Hadoop Cluster Performance via Linux Configuration
 
Rds data lake @ Robinhood
Rds data lake @ Robinhood Rds data lake @ Robinhood
Rds data lake @ Robinhood
 
From airflow to google cloud composer
From airflow to google cloud composerFrom airflow to google cloud composer
From airflow to google cloud composer
 
Kafka replication apachecon_2013
Kafka replication apachecon_2013Kafka replication apachecon_2013
Kafka replication apachecon_2013
 
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
 
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
The Rise of ZStandard: Apache Spark/Parquet/ORC/AvroThe Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
 
Achieving 100k Queries per Hour on Hive on Tez
Achieving 100k Queries per Hour on Hive on TezAchieving 100k Queries per Hour on Hive on Tez
Achieving 100k Queries per Hour on Hive on Tez
 
Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & Features
 
HBase and Hadoop at Adobe
HBase and Hadoop at AdobeHBase and Hadoop at Adobe
HBase and Hadoop at Adobe
 
Introduction to HiveQL
Introduction to HiveQLIntroduction to HiveQL
Introduction to HiveQL
 

En vedette

Counting image views using redis cluster
Counting image views using redis clusterCounting image views using redis cluster
Counting image views using redis clusterRedis Labs
 
Open-source Infrastructure at Lyft
Open-source Infrastructure at LyftOpen-source Infrastructure at Lyft
Open-source Infrastructure at LyftDaniel Hochman
 
Building Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSocketsBuilding Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSocketsSergi Almar i Graupera
 
"Building Data Foundations and Analytics Tools Across The Product" by Crystal...
"Building Data Foundations and Analytics Tools Across The Product" by Crystal..."Building Data Foundations and Analytics Tools Across The Product" by Crystal...
"Building Data Foundations and Analytics Tools Across The Product" by Crystal...Tech in Asia ID
 
Taxi Startup Presentation for Taxi Company
Taxi Startup Presentation for Taxi CompanyTaxi Startup Presentation for Taxi Company
Taxi Startup Presentation for Taxi CompanyEugene Suslo
 
Uber's new mobile architecture
Uber's new mobile architectureUber's new mobile architecture
Uber's new mobile architectureDhaval Patel
 
Just Add Reality: Managing Logistics with the Uber Developer Platform
Just Add Reality: Managing Logistics with the Uber Developer PlatformJust Add Reality: Managing Logistics with the Uber Developer Platform
Just Add Reality: Managing Logistics with the Uber Developer PlatformApigee | Google Cloud
 
Kafka + Uber- The World’s Realtime Transit Infrastructure, Aaron Schildkrout
Kafka + Uber- The World’s Realtime Transit Infrastructure, Aaron SchildkroutKafka + Uber- The World’s Realtime Transit Infrastructure, Aaron Schildkrout
Kafka + Uber- The World’s Realtime Transit Infrastructure, Aaron Schildkroutconfluent
 
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...DataStax
 

En vedette (10)

Counting image views using redis cluster
Counting image views using redis clusterCounting image views using redis cluster
Counting image views using redis cluster
 
Open-source Infrastructure at Lyft
Open-source Infrastructure at LyftOpen-source Infrastructure at Lyft
Open-source Infrastructure at Lyft
 
Building Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSocketsBuilding Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSockets
 
"Building Data Foundations and Analytics Tools Across The Product" by Crystal...
"Building Data Foundations and Analytics Tools Across The Product" by Crystal..."Building Data Foundations and Analytics Tools Across The Product" by Crystal...
"Building Data Foundations and Analytics Tools Across The Product" by Crystal...
 
Taxi Startup Presentation for Taxi Company
Taxi Startup Presentation for Taxi CompanyTaxi Startup Presentation for Taxi Company
Taxi Startup Presentation for Taxi Company
 
Uber's new mobile architecture
Uber's new mobile architectureUber's new mobile architecture
Uber's new mobile architecture
 
Just Add Reality: Managing Logistics with the Uber Developer Platform
Just Add Reality: Managing Logistics with the Uber Developer PlatformJust Add Reality: Managing Logistics with the Uber Developer Platform
Just Add Reality: Managing Logistics with the Uber Developer Platform
 
Kafka + Uber- The World’s Realtime Transit Infrastructure, Aaron Schildkrout
Kafka + Uber- The World’s Realtime Transit Infrastructure, Aaron SchildkroutKafka + Uber- The World’s Realtime Transit Infrastructure, Aaron Schildkrout
Kafka + Uber- The World’s Realtime Transit Infrastructure, Aaron Schildkrout
 
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
Cassandra on Mesos Across Multiple Datacenters at Uber (Abhishek Verma) | C* ...
 
31 - IDNOG03 - Bergas Bimo Branarto (GOJEK) - Scaling Gojek
31 - IDNOG03 - Bergas Bimo Branarto (GOJEK) - Scaling Gojek31 - IDNOG03 - Bergas Bimo Branarto (GOJEK) - Scaling Gojek
31 - IDNOG03 - Bergas Bimo Branarto (GOJEK) - Scaling Gojek
 

Similaire à Geospatial Indexing at Scale: The 15 Million QPS Redis Architecture Powering Lyft

Startup Case Study: Leveraging the Broad Hadoop Ecosystem to Develop World-Fi...
Startup Case Study: Leveraging the Broad Hadoop Ecosystem to Develop World-Fi...Startup Case Study: Leveraging the Broad Hadoop Ecosystem to Develop World-Fi...
Startup Case Study: Leveraging the Broad Hadoop Ecosystem to Develop World-Fi...DataWorks Summit
 
Overview of stinger interactive query for hive
Overview of stinger   interactive query for hiveOverview of stinger   interactive query for hive
Overview of stinger interactive query for hiveDavid Kaiser
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop OverviewShubhra Kar
 
Hadoop Summit San Jose 2015: What it Takes to Run Hadoop at Scale Yahoo Persp...
Hadoop Summit San Jose 2015: What it Takes to Run Hadoop at Scale Yahoo Persp...Hadoop Summit San Jose 2015: What it Takes to Run Hadoop at Scale Yahoo Persp...
Hadoop Summit San Jose 2015: What it Takes to Run Hadoop at Scale Yahoo Persp...Sumeet Singh
 
What it takes to run Hadoop at Scale: Yahoo! Perspectives
What it takes to run Hadoop at Scale: Yahoo! PerspectivesWhat it takes to run Hadoop at Scale: Yahoo! Perspectives
What it takes to run Hadoop at Scale: Yahoo! PerspectivesDataWorks Summit
 
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...Jürgen Ambrosi
 
Pivotal Real Time Data Stream Analytics
Pivotal Real Time Data Stream AnalyticsPivotal Real Time Data Stream Analytics
Pivotal Real Time Data Stream Analyticskgshukla
 
Coherence RoadMap 2018
Coherence RoadMap 2018Coherence RoadMap 2018
Coherence RoadMap 2018harvraja
 
TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...
TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...
TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...Debraj GuhaThakurta
 
TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...
TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...
TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...Debraj GuhaThakurta
 
Hadoop Summit Dublin 2016: Hadoop Platform at Yahoo - A Year in Review
Hadoop Summit Dublin 2016: Hadoop Platform at Yahoo - A Year in Review Hadoop Summit Dublin 2016: Hadoop Platform at Yahoo - A Year in Review
Hadoop Summit Dublin 2016: Hadoop Platform at Yahoo - A Year in Review Sumeet Singh
 
Using HBase Co-Processors to Build a Distributed, Transactional RDBMS - Splic...
Using HBase Co-Processors to Build a Distributed, Transactional RDBMS - Splic...Using HBase Co-Processors to Build a Distributed, Transactional RDBMS - Splic...
Using HBase Co-Processors to Build a Distributed, Transactional RDBMS - Splic...Chicago Hadoop Users Group
 
Stateful Interaction In Serverless Architecture With Redis: Pyounguk Cho
Stateful Interaction In Serverless Architecture With Redis: Pyounguk ChoStateful Interaction In Serverless Architecture With Redis: Pyounguk Cho
Stateful Interaction In Serverless Architecture With Redis: Pyounguk ChoRedis Labs
 
Hannes end-of-the-router-tnc17
Hannes end-of-the-router-tnc17Hannes end-of-the-router-tnc17
Hannes end-of-the-router-tnc17Hannes Gredler
 
Querying Druid in SQL with Superset
Querying Druid in SQL with SupersetQuerying Druid in SQL with Superset
Querying Druid in SQL with SupersetDataWorks Summit
 
Tajo_Meetup_20141120
Tajo_Meetup_20141120Tajo_Meetup_20141120
Tajo_Meetup_20141120Hyoungjun Kim
 
Apache Hadoop YARN - The Future of Data Processing with Hadoop
Apache Hadoop YARN - The Future of Data Processing with HadoopApache Hadoop YARN - The Future of Data Processing with Hadoop
Apache Hadoop YARN - The Future of Data Processing with HadoopHortonworks
 
[SSA] 04.sql on hadoop(2014.02.05)
[SSA] 04.sql on hadoop(2014.02.05)[SSA] 04.sql on hadoop(2014.02.05)
[SSA] 04.sql on hadoop(2014.02.05)Steve Min
 
Interactive SQL POC on Hadoop (Hive, Presto and Hive-on-Tez)
Interactive SQL POC on Hadoop (Hive, Presto and Hive-on-Tez)Interactive SQL POC on Hadoop (Hive, Presto and Hive-on-Tez)
Interactive SQL POC on Hadoop (Hive, Presto and Hive-on-Tez)Sudhir Mallem
 

Similaire à Geospatial Indexing at Scale: The 15 Million QPS Redis Architecture Powering Lyft (20)

Startup Case Study: Leveraging the Broad Hadoop Ecosystem to Develop World-Fi...
Startup Case Study: Leveraging the Broad Hadoop Ecosystem to Develop World-Fi...Startup Case Study: Leveraging the Broad Hadoop Ecosystem to Develop World-Fi...
Startup Case Study: Leveraging the Broad Hadoop Ecosystem to Develop World-Fi...
 
Overview of stinger interactive query for hive
Overview of stinger   interactive query for hiveOverview of stinger   interactive query for hive
Overview of stinger interactive query for hive
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
 
Hadoop Summit San Jose 2015: What it Takes to Run Hadoop at Scale Yahoo Persp...
Hadoop Summit San Jose 2015: What it Takes to Run Hadoop at Scale Yahoo Persp...Hadoop Summit San Jose 2015: What it Takes to Run Hadoop at Scale Yahoo Persp...
Hadoop Summit San Jose 2015: What it Takes to Run Hadoop at Scale Yahoo Persp...
 
What it takes to run Hadoop at Scale: Yahoo! Perspectives
What it takes to run Hadoop at Scale: Yahoo! PerspectivesWhat it takes to run Hadoop at Scale: Yahoo! Perspectives
What it takes to run Hadoop at Scale: Yahoo! Perspectives
 
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...
6° Sessione - Ambiti applicativi nella ricerca di tecnologie statistiche avan...
 
Pivotal Real Time Data Stream Analytics
Pivotal Real Time Data Stream AnalyticsPivotal Real Time Data Stream Analytics
Pivotal Real Time Data Stream Analytics
 
Coherence RoadMap 2018
Coherence RoadMap 2018Coherence RoadMap 2018
Coherence RoadMap 2018
 
TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...
TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...
TWDI Accelerate Seattle, Oct 16, 2017: Distributed and In-Database Analytics ...
 
TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...
TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...
TDWI Accelerate, Seattle, Oct 16, 2017: Distributed and In-Database Analytics...
 
Hadoop Summit Dublin 2016: Hadoop Platform at Yahoo - A Year in Review
Hadoop Summit Dublin 2016: Hadoop Platform at Yahoo - A Year in Review Hadoop Summit Dublin 2016: Hadoop Platform at Yahoo - A Year in Review
Hadoop Summit Dublin 2016: Hadoop Platform at Yahoo - A Year in Review
 
Hadoop Platform at Yahoo
Hadoop Platform at YahooHadoop Platform at Yahoo
Hadoop Platform at Yahoo
 
Using HBase Co-Processors to Build a Distributed, Transactional RDBMS - Splic...
Using HBase Co-Processors to Build a Distributed, Transactional RDBMS - Splic...Using HBase Co-Processors to Build a Distributed, Transactional RDBMS - Splic...
Using HBase Co-Processors to Build a Distributed, Transactional RDBMS - Splic...
 
Stateful Interaction In Serverless Architecture With Redis: Pyounguk Cho
Stateful Interaction In Serverless Architecture With Redis: Pyounguk ChoStateful Interaction In Serverless Architecture With Redis: Pyounguk Cho
Stateful Interaction In Serverless Architecture With Redis: Pyounguk Cho
 
Hannes end-of-the-router-tnc17
Hannes end-of-the-router-tnc17Hannes end-of-the-router-tnc17
Hannes end-of-the-router-tnc17
 
Querying Druid in SQL with Superset
Querying Druid in SQL with SupersetQuerying Druid in SQL with Superset
Querying Druid in SQL with Superset
 
Tajo_Meetup_20141120
Tajo_Meetup_20141120Tajo_Meetup_20141120
Tajo_Meetup_20141120
 
Apache Hadoop YARN - The Future of Data Processing with Hadoop
Apache Hadoop YARN - The Future of Data Processing with HadoopApache Hadoop YARN - The Future of Data Processing with Hadoop
Apache Hadoop YARN - The Future of Data Processing with Hadoop
 
[SSA] 04.sql on hadoop(2014.02.05)
[SSA] 04.sql on hadoop(2014.02.05)[SSA] 04.sql on hadoop(2014.02.05)
[SSA] 04.sql on hadoop(2014.02.05)
 
Interactive SQL POC on Hadoop (Hive, Presto and Hive-on-Tez)
Interactive SQL POC on Hadoop (Hive, Presto and Hive-on-Tez)Interactive SQL POC on Hadoop (Hive, Presto and Hive-on-Tez)
Interactive SQL POC on Hadoop (Hive, Presto and Hive-on-Tez)
 

Dernier

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 

Dernier (20)

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 

Geospatial Indexing at Scale: The 15 Million QPS Redis Architecture Powering Lyft

  • 1. Daniel Hochman, Engineer @ Geospatial Indexing at Scale The 10 15 Million QPS Redis Architecture Powering Lyft
  • 2. Agenda Case Study: scaling a geospatial index - Original Lyft architecture - Migrating to Redis - Iterating on data model Redis on the Lyft platform - Service integration - Operations and monitoring - Capacity planning - Open source work and roadmap Q&A
  • 3. API Monolith PUT /v1/locations 5 sec loop { "lat": 37.61, "lng": -122.38 } { "drivers": [ ... ], "primetime": 0, "eta": 30, ... } 200 OK Index on users collection (driver_mode, region) Lyft backend in 2012 Location stored on user record
  • 4. Monolithic architecture issues Global write lock, not shardable, difficult refactoring, region boundary issues drivers_in_region = db.users.find( driver_mode: {$eq: True}, region: {$eq: "SFO"}, ride_id: {$eq: None} ) eligible_drivers = sort_and_filter_by_distance( drivers_in_region, radius=.5 ) dispatch(eligible_drivers[0])
  • 5. Horizontally scalable and highly available from day zero Unwritten architecture rule at Lyft
  • 6. nutcracker locations_cluster: listen: locations.sock distribution: ketama hash: md5 eject_hosts: true failure_limit: 3 servers: - 10.0.0.1:6379:1 - 10.0.0.2:6379:1 ... - 10.0.0.255:6379:1 Redis Cluster . . . n shards Application Instance Nutcracker overview Ketama provides consistent hashing! Lose a node, only lose 1/n data
  • 7. nutcracker Pipelining PIPELINE ( HGETALL foo SET hello world INCR lyfts ) RESPONSE ( (k1, v1, k2, v2) OK 12121986 ) md5(foo) % 3 = 2 md5(hello) % 3 = 0 md5(lyfts) % 3 = 2 0: SET hello world 0 1 2 2: PIPELINE ( HGETALL foo INCR lyfts ) return ordered_results 1. hash the keys 2. send concurrent requests to backends 3. concatenate and return results
  • 8. location = json.dumps({'lat': 23.2, 'lng': -122.3, 'ride_id': None}) with nutcracker.pipeline() as pipeline: pipeline.set(user_id, location) # string per user if driver_mode is True: pipeline.hset(region_name, user_id, location) # hash per region Parity data model Fetching inactive drivers when doing HGETALL. Network and serialization overhead. The obvious fix? Expiration.
  • 10. - pipeline.hset(region_name, user_id, location) # hash per region # hash per region per 30 seconds bucket = now_seconds() - (now_seconds() % 30) hash_key = '{}_{}'.format(region_name, bucket) pipeline.hset(hash_key, user_id, location) pipeline.expire(hash_key, 15) Expiring a hash HGETALL current bucket plus next and previous to handle clock drift and boundary condition, merge in process. 12:00:00 12:00:30 12:01:00 12:01:30 ...
  • 11. Region is a poor hash key (hot shards) Bulk expiration blocks Redis for longer than expected Redis used for inter-service communication with new dispatch system Growing pains Let's fix it!
  • 12. Redis is used for inter-service communication - Replicate existing queries and writes in new service - Replace function calls that query or write to Redis with calls to new service - With contract in place between existing services and new service, refactor data model - Migrate relevant business logic Proper service communication
  • 13. fd a Region is a poor hash key Geohashing is an algorithm that provides arbitrary precision with gradual precision degradation Geohashing b c d e f ihg >>> compute_geohash(lat=37.7852, lng=-122.4044, level=9) 9q8yywefd fa fb fc fe ff fifhfg Google open-sourced an alternative geohashing algorithm, S2
  • 14. loc = {'lat': 23.2, 'lng': -122.3, 'ride_id': None} geohash = compute_geohash(loc['lat'], loc['lng'], level=5) with nutcracker.pipeline() as pipeline: # string per user pipeline.set(user_id, json.dumps(loc)) # sorted set per geohash with last timestamp if driver_mode is True: pipeline.zset(geohash, user_id, now_seconds()) pipeline.zremrangebyscore(geohash, -inf, now_seconds() - 30) # expire! Data model with geohashing Sorted set tells you where a driver might be. Use string as source of truth. On query, look in neighboring geohashes based on desired radius.
  • 15. Why not GEO? Stable release in May 2016 with Redis 3.2.0 Point-in-radius, position of key Uses geohashing and a sorted set under-the-hood No expiration or sharding No metadata storage Great for prototyping Much more data model complexity behind the scenes - Additional metadata - Writing to multiple indices to lower cost of high frequency queries - Balancing scattered gets and hot shards with geohash level GEOADD GEODIST GEOHASH GEOPOS GEORADIUS GEORADIUSBYMEMBER
  • 16. Redis on the Lyft platform
  • 17. Creating a new cluster is a self-service process that takes less than one engineer hour. 2015: 1 cluster of 3 instances 2017: 50 clusters with a total of 750 instances Cluster creation
  • 18. Golang and Python are the two officially supported backend languages at Lyft Python features - Fully compatible with redis-py StrictRedis - Stats - Retry - Pipeline management for interleave and targeted retry from lyftredis import NutcrackerClient redis_client = NutcrackerClient('locations') Internal libraries
  • 19. {% macro redis_cluster_stats(redis_cluster_name, alarm_thresholds) -%} Observability
  • 20. Capacity planning Combine APIs and stats for global capacity plan - Difficult to track 50 clusters - Google Sheets API for display - Internal stats for actual usage, EC2 API for capacity - Automatically determine resource constraint (CPU, memory, network) - Currently aim for 4x headroom due to difficulty of cluster resize - At-a-glance view of peak resource consumption, provisioned resources, cost, resource constraint
  • 21. Object serialization Benefits - Lower memory consumption, I/O - Lower network I/O - Lower serialization cost to CPU 708 bytes 69% 1012 bytes (original) 190 bytes 18%
  • 22. Nutcracker issues - Deprecated internally at Twitter and unmaintained - Passive health checks - No hot restart (config changes cause downtime) - Difficult to extend (e.g. to integrate with service discovery) - When EC2 instance of Redis dies, we page an engineer to fix the problem The road ahead
  • 23. Open-source C++11 service mesh and edge proxy As an advanced load balancer, provides: - Service discovery integration - Retry, circuit breaking, rate limiting - Consistent hashing - Active health checks - Stats, stats, stats - Tracing - Outlier detection, fault injection Envoy was designed to be extensible! What is Envoy? envoy by
  • 24. In production at Lyft as of May 2017 Support for INCR, INCRBY, SET, GET (ratelimit service) Service discovery integration (autoscaling!) Active healthcheck using PING (self-healing!) Pipeline splitting, concurrency Basic stats Introducing Envoy Redis
  • 25. Envoy Redis Roadmap Additional command support Error handling Pipeline management features Performance optimization Replication - Failover - Mitigate hot read shard issues with large objects - Zone local query routing - Quorum - Protocol overloading? e.g. SET key value [replication factor] [timeout] More!
  • 26. Q&A - Thanks! - Email technical inquiries to dhochman lyft.com - Participate in Envoy open source community! lyft/envoy - Lyft is hiring. If you want to work on scaling problems in a fast-moving, high-growth company visit https://www.lyft.com/jobs