SlideShare a Scribd company logo
1 of 31
Threading Needles in a Haystack:
Sessionizing Uber Trips in Real Time
Amey Chaugule
Uber Technologies, Inc.
Agenda
● The Marketplace Org @ Uber
● Sessionization use cases at Uber
● Some unique challenges about Sessions @ Uber
● Anatomy of an Uber Session
● Our Sessions DSL
● Sessions in Production
● Scale
● Q & A
The Uber Marketplace
The Uber Marketplace
In our marketplace, there are models that describe the world and the
decision engines that act upon them.
Marketplace @ Uber
Real-time events in the physical world drive marketplace dynamics
which then affect the algorithmic engines in the Marketplace which in
turn influence the events in the real world in a continuous feedback
loop.
Some examples of marketplace dynamics:
Supply
Demand
Forecast
Trips
Need for a sessionized view of the Uber experience
Given the scale and complexity of our systems, events are distributed
across multiple disparate real-time streams over the twin dimensions of
time and space.
How do we contextualize these event streams so they can be logically
grouped together and quickly surface useful information to downstream
decision engines?
Real-time Use cases
For instance, the some algorithms need to adjust to spikes in demand to
balance the supply in near real-time.
While some machine learning-models need information about
pre-request activities in real-time.
To understand rider behaviour we need to understand the full user
experience from start to finish.
Post-Dispatch Rider
Cancel
Completed Trip
Pre-Dispatch Rider
Cancel
Unfulfilled
Dispatched
Exit pre-request
screen
Exit at request
screen
RequestSession Start
Driver Cancel
Get to Request
Screen
R/S
C/R
C/S
The definition of this experience, a SESSION, is critical to understanding our
internal business operations.
Some unique challenges
Given the ride-sharing marketplace Uber operates, our Sessions state
machine needs to model interactions between riders, driver partners
and back-end systems
The Anatomy of an Uber Session
The Sessions State Machine
The Sessions State Machine - The shopping state
The Sessions State Machine - Requesting a ride
The Sessions State Machine - Cancellation (the sad path ☹ )
The Sessions State Machine - On Trip (The happy path )
The Sessions State Machine - Session End (The happy path )
The Sessions State Machine - On trip (the happy path )
Implementation
Pickup Experience at Super Bowl 2017
Sessions DSL
type Condition = SessionInput => Boolean
/**
* This class defines a single transition. It takes in two functions:
*
* @param condition Function of type (SessionInput => Boolean) representing conditions that trigger this transition.
* @param nextState Function of type (State, SessionInput) => State, which results in the next state.
*/
class Transition(condition: Condition, nextState: (State, SessionInput) => State) {
def isConditionValid(event: SessionInput) = condition(event)
def transition(event: SessionInput, fromState: State): State = nextState(fromState, event)
}
e.g.
val requestRideAndRiderLookingTransition = new Transition(isRequestEvent and isRiderLooking, RequestRideState.transitionTo)
Sessions DSL
sealed trait State {
val ts: Long
val name: RiderSessionStateName.Value
val transitionReason: Option[String]
val jobUuid: Option[String]
val originLocation: Option[GeoLocation]
val destinationLocation: Option[GeoLocation]
// List of Transitions out of this state. They are evaluated in the order of precedence they appear in this list.
val transitions: List[Transition]
/**
*
* @param event Current session input.
* @return The next state resulting from the input event.
*/
def withEvent(event: SessionInput): State = {
// Find the transition with condition that event holds valid.
val transition = transitions.find(t => t.isConditionValid(event))
transition map(_.transition(event, this)) getOrElse this
}
}
Sessions DSL - Putting it all together
case class RequestRideState(ts: Long,
override val vehicleViewId: VehicleView,
transitionReason: Option[String] = None,
jobUuid: Option[String] = None,
originLocation: Option[GeoLocation] = None,
destinationLocation: Option[GeoLocation] = None) extends State with AssignedVehicleView {
override val name: SessionState.Value = SessionState.RequestRide
override val transitions: List[Transition] = List(Transition.onTripTransition,
Transition.shoppingStateFromRequestTransition,
Transition.requestRideSelfTransition,
Transition.shoppingStateOnRequestExpiration)
}
Sessions - Moving from Spark to Flink
unionedStreams
.assignTimestampsAndWatermarks(new BoundedOutOfOrdernessTimestampExtractor[SessionInput](Time.seconds(30)) {
override def extractTimestamp(event: SessionInput): Long = event.timestamp })
.keyBy(_.riderUuid)
.window(EventTimeSessionWindows.withDynamicGap(Time.minutes(30)))
.evictor(DeltaEvictor.of(30000.0D, FlinkSessionsPipeline.deltaFunction, true))
.process(new ProcessWindowFunction[SessionInput, List[RiderSessionObject], String, TimeWindow]() {
…
}
Spark’s stateFunc abstraction just fit nicely into ProcessWindow
Sessions in Production
“Time is relative… and clocks are hard.” - I. Brodsky
Our state machine models interactions between riders, drivers, and
internal back-end systems each with their own notion of time!
We essentially need to keep track of per-key watermarks.
Checkpointing
Checkpointing to HDFS can be unreliable.
What levels of backpressure can your downstream applications
tolerate?
At times, it’s just easier to store per-key state to Kafka and restart a
new pipeline, letting backfill take care of any gaps.
Backfills
We rely on upserts into Elasticsearch and backfilling can introduce subtle
bugs by being “more correct.”
In our implementation each session is indexed by an anonymized rider
UUID and its start time, i.e. event time of the first event to kick off a
session.
Re-ordering the event consumption in a backfill can easily give you two
nearly identical sessions with slightly different start times
Schema Evolution
Uber’s ride sharing products are constantly evolving and our pipeline
needs to keep in sync.
A new pipeline without a state needs to warm up the state before we
can trust it to reliably write to our production indices.
Production hand off between the old and the new pipelines needs to be
carefully choreographed.
Observability
Keep track of any and every metric you can possibly think of for data
reliability as well as processing metrics such as Flink & JVM stats.
We use M3, our open source metrics platform for Prometheus.
Upstream data can and will change on you.
Imputing State
Uber’s first and foremost responsibility is to ensure a reliable, safe ride
for our users from request/dispatch all the way to a completed trip.
Mobile logging is buffered and the best option, especially when running
on low tech phones and in areas with poor network connectivity.
Our sessionization pipelines need to be resilient to dropped events
Sessions in Numbers
Scale
We ingest tens of billions of events daily.
We generate tens of millions of sessions.
Currently the production pipeline is running in Spark Streaming and
we’re comparing it against a Flink successor.
Thank you.
Learn more: uber.com/marketplace

More Related Content

Similar to Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: Sessionizing the Uber firehose in realtime"

Streaming Processing in Uber Marketplace for Kafka Summit 2016
Streaming Processing in Uber Marketplace for Kafka Summit 2016Streaming Processing in Uber Marketplace for Kafka Summit 2016
Streaming Processing in Uber Marketplace for Kafka Summit 2016Danny Yuan
 
Big Data Pipelines and Machine Learning at Uber
Big Data Pipelines and Machine Learning at UberBig Data Pipelines and Machine Learning at Uber
Big Data Pipelines and Machine Learning at UberSudhir Tonse
 
WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor
WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor
WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor WSO2
 
Complex Event Processor 3.0.0 - An overview of upcoming features
Complex Event Processor 3.0.0 - An overview of upcoming features Complex Event Processor 3.0.0 - An overview of upcoming features
Complex Event Processor 3.0.0 - An overview of upcoming features WSO2
 
Patterns & Practices for Cloud-based Microservices
Patterns & Practices for Cloud-based MicroservicesPatterns & Practices for Cloud-based Microservices
Patterns & Practices for Cloud-based MicroservicesC4Media
 
Goto meetup Stockholm - Let your microservices flow
Goto meetup Stockholm - Let your microservices flowGoto meetup Stockholm - Let your microservices flow
Goto meetup Stockholm - Let your microservices flowBernd Ruecker
 
AWS Cost Opt Meetup 2 - News corp - Spot On deep dive
AWS Cost Opt Meetup 2 - News corp - Spot On deep diveAWS Cost Opt Meetup 2 - News corp - Spot On deep dive
AWS Cost Opt Meetup 2 - News corp - Spot On deep divePeter Shi
 
JavaBin Oslo: Open source workflow and rule management with Camunda
JavaBin Oslo: Open source workflow and rule management with CamundaJavaBin Oslo: Open source workflow and rule management with Camunda
JavaBin Oslo: Open source workflow and rule management with CamundaBernd Ruecker
 
NEW LAUNCH! Building Distributed Applications with AWS Step Functions
NEW LAUNCH! Building Distributed Applications with AWS Step FunctionsNEW LAUNCH! Building Distributed Applications with AWS Step Functions
NEW LAUNCH! Building Distributed Applications with AWS Step FunctionsAmazon Web Services
 
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?João Pedro Martins
 
Programming models for event controlled programs
Programming models for event controlled programsProgramming models for event controlled programs
Programming models for event controlled programsPriya Kaushal
 
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션Amazon Web Services Korea
 
Loadrunner interview questions and answers
Loadrunner interview questions and answersLoadrunner interview questions and answers
Loadrunner interview questions and answersGaruda Trainings
 
An introduction to Spot Instances and AWS Fleet - Webinar
An introduction to Spot Instances and AWS Fleet - WebinarAn introduction to Spot Instances and AWS Fleet - Webinar
An introduction to Spot Instances and AWS Fleet - WebinarCMPUTE
 
How to CQRS in node: Eventually Consistent, Distributed Microservice Systems..
How to CQRS in node: Eventually Consistent, Distributed Microservice Systems..How to CQRS in node: Eventually Consistent, Distributed Microservice Systems..
How to CQRS in node: Eventually Consistent, Distributed Microservice Systems..Matt Walters
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonfNataliya Patsovska
 
Serverless Days 2019 - Lost in transaction
Serverless Days 2019 - Lost in transactionServerless Days 2019 - Lost in transaction
Serverless Days 2019 - Lost in transactionBernd Ruecker
 
Architecting Microservices in .Net
Architecting Microservices in .NetArchitecting Microservices in .Net
Architecting Microservices in .NetRichard Banks
 
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"Andrii Dembitskyi "Events in our applications Event bus and distributed systems"
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"Fwdays
 

Similar to Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: Sessionizing the Uber firehose in realtime" (20)

Streaming Processing in Uber Marketplace for Kafka Summit 2016
Streaming Processing in Uber Marketplace for Kafka Summit 2016Streaming Processing in Uber Marketplace for Kafka Summit 2016
Streaming Processing in Uber Marketplace for Kafka Summit 2016
 
Big Data Pipelines and Machine Learning at Uber
Big Data Pipelines and Machine Learning at UberBig Data Pipelines and Machine Learning at Uber
Big Data Pipelines and Machine Learning at Uber
 
WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor
WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor
WSO2 Product Release Webinar - Introducing the WSO2 Complex Event Processor
 
Complex Event Processor 3.0.0 - An overview of upcoming features
Complex Event Processor 3.0.0 - An overview of upcoming features Complex Event Processor 3.0.0 - An overview of upcoming features
Complex Event Processor 3.0.0 - An overview of upcoming features
 
Patterns & Practices for Cloud-based Microservices
Patterns & Practices for Cloud-based MicroservicesPatterns & Practices for Cloud-based Microservices
Patterns & Practices for Cloud-based Microservices
 
Goto meetup Stockholm - Let your microservices flow
Goto meetup Stockholm - Let your microservices flowGoto meetup Stockholm - Let your microservices flow
Goto meetup Stockholm - Let your microservices flow
 
AWS Cost Opt Meetup 2 - News corp - Spot On deep dive
AWS Cost Opt Meetup 2 - News corp - Spot On deep diveAWS Cost Opt Meetup 2 - News corp - Spot On deep dive
AWS Cost Opt Meetup 2 - News corp - Spot On deep dive
 
JavaBin Oslo: Open source workflow and rule management with Camunda
JavaBin Oslo: Open source workflow and rule management with CamundaJavaBin Oslo: Open source workflow and rule management with Camunda
JavaBin Oslo: Open source workflow and rule management with Camunda
 
NEW LAUNCH! Building Distributed Applications with AWS Step Functions
NEW LAUNCH! Building Distributed Applications with AWS Step FunctionsNEW LAUNCH! Building Distributed Applications with AWS Step Functions
NEW LAUNCH! Building Distributed Applications with AWS Step Functions
 
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
 
Programming models for event controlled programs
Programming models for event controlled programsProgramming models for event controlled programs
Programming models for event controlled programs
 
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
 
Loadrunner interview questions and answers
Loadrunner interview questions and answersLoadrunner interview questions and answers
Loadrunner interview questions and answers
 
An introduction to Spot Instances and AWS Fleet - Webinar
An introduction to Spot Instances and AWS Fleet - WebinarAn introduction to Spot Instances and AWS Fleet - Webinar
An introduction to Spot Instances and AWS Fleet - Webinar
 
How to CQRS in node: Eventually Consistent, Distributed Microservice Systems..
How to CQRS in node: Eventually Consistent, Distributed Microservice Systems..How to CQRS in node: Eventually Consistent, Distributed Microservice Systems..
How to CQRS in node: Eventually Consistent, Distributed Microservice Systems..
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonf
 
Windows Workflow Foundation
Windows Workflow FoundationWindows Workflow Foundation
Windows Workflow Foundation
 
Serverless Days 2019 - Lost in transaction
Serverless Days 2019 - Lost in transactionServerless Days 2019 - Lost in transaction
Serverless Days 2019 - Lost in transaction
 
Architecting Microservices in .Net
Architecting Microservices in .NetArchitecting Microservices in .Net
Architecting Microservices in .Net
 
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"Andrii Dembitskyi "Events in our applications Event bus and distributed systems"
Andrii Dembitskyi "Events in our applications Event bus and distributed systems"
 

More from Flink Forward

Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...Flink Forward
 
Evening out the uneven: dealing with skew in Flink
Evening out the uneven: dealing with skew in FlinkEvening out the uneven: dealing with skew in Flink
Evening out the uneven: dealing with skew in FlinkFlink Forward
 
“Alexa, be quiet!”: End-to-end near-real time model building and evaluation i...
“Alexa, be quiet!”: End-to-end near-real time model building and evaluation i...“Alexa, be quiet!”: End-to-end near-real time model building and evaluation i...
“Alexa, be quiet!”: End-to-end near-real time model building and evaluation i...Flink Forward
 
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...Flink Forward
 
Introducing the Apache Flink Kubernetes Operator
Introducing the Apache Flink Kubernetes OperatorIntroducing the Apache Flink Kubernetes Operator
Introducing the Apache Flink Kubernetes OperatorFlink Forward
 
Autoscaling Flink with Reactive Mode
Autoscaling Flink with Reactive ModeAutoscaling Flink with Reactive Mode
Autoscaling Flink with Reactive ModeFlink Forward
 
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Flink Forward
 
One sink to rule them all: Introducing the new Async Sink
One sink to rule them all: Introducing the new Async SinkOne sink to rule them all: Introducing the new Async Sink
One sink to rule them all: Introducing the new Async SinkFlink Forward
 
Tuning Apache Kafka Connectors for Flink.pptx
Tuning Apache Kafka Connectors for Flink.pptxTuning Apache Kafka Connectors for Flink.pptx
Tuning Apache Kafka Connectors for Flink.pptxFlink Forward
 
Flink powered stream processing platform at Pinterest
Flink powered stream processing platform at PinterestFlink powered stream processing platform at Pinterest
Flink powered stream processing platform at PinterestFlink Forward
 
Apache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native EraApache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native EraFlink Forward
 
Where is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in FlinkWhere is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in FlinkFlink Forward
 
Using the New Apache Flink Kubernetes Operator in a Production Deployment
Using the New Apache Flink Kubernetes Operator in a Production DeploymentUsing the New Apache Flink Kubernetes Operator in a Production Deployment
Using the New Apache Flink Kubernetes Operator in a Production DeploymentFlink Forward
 
The Current State of Table API in 2022
The Current State of Table API in 2022The Current State of Table API in 2022
The Current State of Table API in 2022Flink Forward
 
Flink SQL on Pulsar made easy
Flink SQL on Pulsar made easyFlink SQL on Pulsar made easy
Flink SQL on Pulsar made easyFlink Forward
 
Dynamic Rule-based Real-time Market Data Alerts
Dynamic Rule-based Real-time Market Data AlertsDynamic Rule-based Real-time Market Data Alerts
Dynamic Rule-based Real-time Market Data AlertsFlink Forward
 
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
Exactly-Once Financial Data Processing at Scale with Flink and PinotExactly-Once Financial Data Processing at Scale with Flink and Pinot
Exactly-Once Financial Data Processing at Scale with Flink and PinotFlink Forward
 
Processing Semantically-Ordered Streams in Financial Services
Processing Semantically-Ordered Streams in Financial ServicesProcessing Semantically-Ordered Streams in Financial Services
Processing Semantically-Ordered Streams in Financial ServicesFlink Forward
 
Tame the small files problem and optimize data layout for streaming ingestion...
Tame the small files problem and optimize data layout for streaming ingestion...Tame the small files problem and optimize data layout for streaming ingestion...
Tame the small files problem and optimize data layout for streaming ingestion...Flink Forward
 
Batch Processing at Scale with Flink & Iceberg
Batch Processing at Scale with Flink & IcebergBatch Processing at Scale with Flink & Iceberg
Batch Processing at Scale with Flink & IcebergFlink Forward
 

More from Flink Forward (20)

Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...
 
Evening out the uneven: dealing with skew in Flink
Evening out the uneven: dealing with skew in FlinkEvening out the uneven: dealing with skew in Flink
Evening out the uneven: dealing with skew in Flink
 
“Alexa, be quiet!”: End-to-end near-real time model building and evaluation i...
“Alexa, be quiet!”: End-to-end near-real time model building and evaluation i...“Alexa, be quiet!”: End-to-end near-real time model building and evaluation i...
“Alexa, be quiet!”: End-to-end near-real time model building and evaluation i...
 
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
Introducing BinarySortedMultiMap - A new Flink state primitive to boost your ...
 
Introducing the Apache Flink Kubernetes Operator
Introducing the Apache Flink Kubernetes OperatorIntroducing the Apache Flink Kubernetes Operator
Introducing the Apache Flink Kubernetes Operator
 
Autoscaling Flink with Reactive Mode
Autoscaling Flink with Reactive ModeAutoscaling Flink with Reactive Mode
Autoscaling Flink with Reactive Mode
 
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
Dynamically Scaling Data Streams across Multiple Kafka Clusters with Zero Fli...
 
One sink to rule them all: Introducing the new Async Sink
One sink to rule them all: Introducing the new Async SinkOne sink to rule them all: Introducing the new Async Sink
One sink to rule them all: Introducing the new Async Sink
 
Tuning Apache Kafka Connectors for Flink.pptx
Tuning Apache Kafka Connectors for Flink.pptxTuning Apache Kafka Connectors for Flink.pptx
Tuning Apache Kafka Connectors for Flink.pptx
 
Flink powered stream processing platform at Pinterest
Flink powered stream processing platform at PinterestFlink powered stream processing platform at Pinterest
Flink powered stream processing platform at Pinterest
 
Apache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native EraApache Flink in the Cloud-Native Era
Apache Flink in the Cloud-Native Era
 
Where is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in FlinkWhere is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in Flink
 
Using the New Apache Flink Kubernetes Operator in a Production Deployment
Using the New Apache Flink Kubernetes Operator in a Production DeploymentUsing the New Apache Flink Kubernetes Operator in a Production Deployment
Using the New Apache Flink Kubernetes Operator in a Production Deployment
 
The Current State of Table API in 2022
The Current State of Table API in 2022The Current State of Table API in 2022
The Current State of Table API in 2022
 
Flink SQL on Pulsar made easy
Flink SQL on Pulsar made easyFlink SQL on Pulsar made easy
Flink SQL on Pulsar made easy
 
Dynamic Rule-based Real-time Market Data Alerts
Dynamic Rule-based Real-time Market Data AlertsDynamic Rule-based Real-time Market Data Alerts
Dynamic Rule-based Real-time Market Data Alerts
 
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
Exactly-Once Financial Data Processing at Scale with Flink and PinotExactly-Once Financial Data Processing at Scale with Flink and Pinot
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
 
Processing Semantically-Ordered Streams in Financial Services
Processing Semantically-Ordered Streams in Financial ServicesProcessing Semantically-Ordered Streams in Financial Services
Processing Semantically-Ordered Streams in Financial Services
 
Tame the small files problem and optimize data layout for streaming ingestion...
Tame the small files problem and optimize data layout for streaming ingestion...Tame the small files problem and optimize data layout for streaming ingestion...
Tame the small files problem and optimize data layout for streaming ingestion...
 
Batch Processing at Scale with Flink & Iceberg
Batch Processing at Scale with Flink & IcebergBatch Processing at Scale with Flink & Iceberg
Batch Processing at Scale with Flink & Iceberg
 

Recently uploaded

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Recently uploaded (20)

The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: Sessionizing the Uber firehose in realtime"

  • 1. Threading Needles in a Haystack: Sessionizing Uber Trips in Real Time Amey Chaugule Uber Technologies, Inc.
  • 2. Agenda ● The Marketplace Org @ Uber ● Sessionization use cases at Uber ● Some unique challenges about Sessions @ Uber ● Anatomy of an Uber Session ● Our Sessions DSL ● Sessions in Production ● Scale ● Q & A
  • 4. The Uber Marketplace In our marketplace, there are models that describe the world and the decision engines that act upon them.
  • 5. Marketplace @ Uber Real-time events in the physical world drive marketplace dynamics which then affect the algorithmic engines in the Marketplace which in turn influence the events in the real world in a continuous feedback loop. Some examples of marketplace dynamics: Supply Demand Forecast Trips
  • 6. Need for a sessionized view of the Uber experience Given the scale and complexity of our systems, events are distributed across multiple disparate real-time streams over the twin dimensions of time and space. How do we contextualize these event streams so they can be logically grouped together and quickly surface useful information to downstream decision engines?
  • 7. Real-time Use cases For instance, the some algorithms need to adjust to spikes in demand to balance the supply in near real-time. While some machine learning-models need information about pre-request activities in real-time.
  • 8. To understand rider behaviour we need to understand the full user experience from start to finish. Post-Dispatch Rider Cancel Completed Trip Pre-Dispatch Rider Cancel Unfulfilled Dispatched Exit pre-request screen Exit at request screen RequestSession Start Driver Cancel Get to Request Screen R/S C/R C/S The definition of this experience, a SESSION, is critical to understanding our internal business operations.
  • 9. Some unique challenges Given the ride-sharing marketplace Uber operates, our Sessions state machine needs to model interactions between riders, driver partners and back-end systems
  • 10. The Anatomy of an Uber Session
  • 12. The Sessions State Machine - The shopping state
  • 13. The Sessions State Machine - Requesting a ride
  • 14. The Sessions State Machine - Cancellation (the sad path ☹ )
  • 15. The Sessions State Machine - On Trip (The happy path )
  • 16. The Sessions State Machine - Session End (The happy path )
  • 17. The Sessions State Machine - On trip (the happy path ) Implementation Pickup Experience at Super Bowl 2017
  • 18. Sessions DSL type Condition = SessionInput => Boolean /** * This class defines a single transition. It takes in two functions: * * @param condition Function of type (SessionInput => Boolean) representing conditions that trigger this transition. * @param nextState Function of type (State, SessionInput) => State, which results in the next state. */ class Transition(condition: Condition, nextState: (State, SessionInput) => State) { def isConditionValid(event: SessionInput) = condition(event) def transition(event: SessionInput, fromState: State): State = nextState(fromState, event) } e.g. val requestRideAndRiderLookingTransition = new Transition(isRequestEvent and isRiderLooking, RequestRideState.transitionTo)
  • 19. Sessions DSL sealed trait State { val ts: Long val name: RiderSessionStateName.Value val transitionReason: Option[String] val jobUuid: Option[String] val originLocation: Option[GeoLocation] val destinationLocation: Option[GeoLocation] // List of Transitions out of this state. They are evaluated in the order of precedence they appear in this list. val transitions: List[Transition] /** * * @param event Current session input. * @return The next state resulting from the input event. */ def withEvent(event: SessionInput): State = { // Find the transition with condition that event holds valid. val transition = transitions.find(t => t.isConditionValid(event)) transition map(_.transition(event, this)) getOrElse this } }
  • 20. Sessions DSL - Putting it all together case class RequestRideState(ts: Long, override val vehicleViewId: VehicleView, transitionReason: Option[String] = None, jobUuid: Option[String] = None, originLocation: Option[GeoLocation] = None, destinationLocation: Option[GeoLocation] = None) extends State with AssignedVehicleView { override val name: SessionState.Value = SessionState.RequestRide override val transitions: List[Transition] = List(Transition.onTripTransition, Transition.shoppingStateFromRequestTransition, Transition.requestRideSelfTransition, Transition.shoppingStateOnRequestExpiration) }
  • 21. Sessions - Moving from Spark to Flink unionedStreams .assignTimestampsAndWatermarks(new BoundedOutOfOrdernessTimestampExtractor[SessionInput](Time.seconds(30)) { override def extractTimestamp(event: SessionInput): Long = event.timestamp }) .keyBy(_.riderUuid) .window(EventTimeSessionWindows.withDynamicGap(Time.minutes(30))) .evictor(DeltaEvictor.of(30000.0D, FlinkSessionsPipeline.deltaFunction, true)) .process(new ProcessWindowFunction[SessionInput, List[RiderSessionObject], String, TimeWindow]() { … } Spark’s stateFunc abstraction just fit nicely into ProcessWindow
  • 23. “Time is relative… and clocks are hard.” - I. Brodsky Our state machine models interactions between riders, drivers, and internal back-end systems each with their own notion of time! We essentially need to keep track of per-key watermarks.
  • 24. Checkpointing Checkpointing to HDFS can be unreliable. What levels of backpressure can your downstream applications tolerate? At times, it’s just easier to store per-key state to Kafka and restart a new pipeline, letting backfill take care of any gaps.
  • 25. Backfills We rely on upserts into Elasticsearch and backfilling can introduce subtle bugs by being “more correct.” In our implementation each session is indexed by an anonymized rider UUID and its start time, i.e. event time of the first event to kick off a session. Re-ordering the event consumption in a backfill can easily give you two nearly identical sessions with slightly different start times
  • 26. Schema Evolution Uber’s ride sharing products are constantly evolving and our pipeline needs to keep in sync. A new pipeline without a state needs to warm up the state before we can trust it to reliably write to our production indices. Production hand off between the old and the new pipelines needs to be carefully choreographed.
  • 27. Observability Keep track of any and every metric you can possibly think of for data reliability as well as processing metrics such as Flink & JVM stats. We use M3, our open source metrics platform for Prometheus. Upstream data can and will change on you.
  • 28. Imputing State Uber’s first and foremost responsibility is to ensure a reliable, safe ride for our users from request/dispatch all the way to a completed trip. Mobile logging is buffered and the best option, especially when running on low tech phones and in areas with poor network connectivity. Our sessionization pipelines need to be resilient to dropped events
  • 30. Scale We ingest tens of billions of events daily. We generate tens of millions of sessions. Currently the production pipeline is running in Spark Streaming and we’re comparing it against a Flink successor.
  • 31. Thank you. Learn more: uber.com/marketplace