SlideShare a Scribd company logo
serverless and streams at
Yan Cui
http://theburningmonk.com
@theburningmonk
Principal Engineer @
Independent Consultant
“Netflix for sports”
offices in London, Leeds, Katowice and Amsterdam
available in Austria, Switzerland, Germany,
Japan, Canada, Italy, US, Spain and Brazil
available on 30+ platforms
~1,000,000 concurrent viewers
“Netflix for sports”
offices in London, Leeds, Katowice and Amsterdam
We’re hiring! Visit
engineering.dazn.com to
learn more.
follow @DAZN_ngnrs for
updates about the
engineering team.
Streams and serverless at DAZN
we use a LOT
serverless-first
there are no silver bullets
serverless is not right for
every use case (yet)
Streams and serverless at DAZN
~1,000,000 concurrent viewers
Streams and serverless at DAZN
we use a LOT
API Gateway SQS SNS Step Functions
Kinesis
Kinesis
as a task queue
Kinesis
as a task queue as a transaction log
Kinesis
as a task queue as a transaction log
part of an
analytics pipeline
https://noti.st/chrismunns/uqUWri/slides
https://noti.st/chrismunns/uqUWri/slides
stream
stream
shard
shard
shard
stream
shard
shard
shard
PutRecord: {
PartitionKey: …
Data: …
}
stream
shard
shard
shard
PutRecord: {
PartitionKey: …
Data: …
}
stream
shard
shard
shard
doX
doX
doX
PutRecord: {
PartitionKey: …
Data: …
}
stream
shard
shard
shard
doX
doX
doX
PutRecord: {
PartitionKey: …
Data: …
}
ordering is preserved within
the same partition key
stream
shard
shard
shard
doX
doX
doX
PutRecord: {
PartitionKey: …
Data: …
}
ordering is preserved within
the same partition key
data is retained for up to 7
days, default is 24 hours
doX
oldest newest
shard
doX
oldest newest
shard
stream
shard
shard
shard
doX
doX
doX
stream
doY
doX
shard
doY
doX
doY
doX
shard
shard
stream
doY
doX
shard
doY
doX
doY
doX
shard
shard
every subscriber gets the same
data, in the same order
stream
doY
doX
shard
doY
doX
doY
doX
shard
shard
every subscriber gets the same
data, in the same order
each subscriber process the
stream at their own pace
stream
doY
doX
doY
doX
doY
doX
shard
shard
INGRESS
1MB/s data, 1000 records/s
shard
stream
doY
doX
doY
doX
doY
shard
INGRESS
1MB/s data, 1000 records/s
shard
EGRESS
2MB/s data per subscriber, 5 reads/s
doX
shard
stream
shard
shard
shard
shard
shard
horizontalscalability
stream as a task queue
vs. vs.
Kinesis SQS SNS
ordering
replay events
Kinesis SQS SNS
mode
retry
concurrency
subscribers
ordering
replay events
Kinesis SQS SNS
mode
retry
concurrency
subscribers many one-to-one many
ordering
replay events
Kinesis SQS SNS
by shard
none (standard)
global (FIFO)
none
mode
retry
concurrency
subscribers many one-to-one many
ordering
replay events
Kinesis SQS SNS
by shard
none (standard)
global (FIFO)
none
up to 7 days none none
mode
retry
concurrency
subscribers many one-to-one many
ordering
replay events
Kinesis SQS SNS
by shard
none (standard)
global (FIFO)
none
up to 7 days none none
mode
retry
batched batched (up to 10) singular
concurrency
subscribers many one-to-one many
ordering
replay events
Kinesis SQS SNS
by shard
none (standard)
global (FIFO)
none
up to 7 days none none
mode
retry
batched batched (up to 10) singular
retried until
success
retry + DLQ retry + DLQ
concurrency
subscribers many one-to-one many
ordering
replay events
Kinesis SQS SNS
by shard
none (standard)
global (FIFO)
none
up to 7 days none none
mode
retry
batched batched (up to 10) singular
retried until
success
retry + DLQ retry + DLQ
concurrency 1 per shard auto-scaled fan-out!!!
subscribers many one-to-one many
ordering
replay events
Kinesis SQS SNS
by shard
none (standard)
global (FIFO)
none
up to 7 days none none
mode
retry
batched batched (up to 10) singular
retried until
success
retry + DLQ retry + DLQ
concurrency 1 per shard auto-scaled fan-out!!!
subscribers many one-to-one many
use the concurrency model to amortize spikes in traffic
leveraging the retry-until-success behaviour
cost is scale-sensitive
1 msg/s for a month, 1KB per msg
1 x 60s x 60m x 24hr x 30days
@ $0.014 per mil
+
24hrs x 30days
@ $0.015 per hr
$10.836
1 x 60s x 60m x 24hr x 30days
@ $0.5 per mil
$1.296
1 x 60s x 60m x 24hr x 30days
@ $0.4 per mil (send)
+
1 x 60s x 60m x 24hr x 30days
@ 10 batch
@ 20s long polling
@ $0.4 per mil (receive)
$1.089
1K msg/s for a month, 1KB per msg
1k x 60s x 60m x 24hr x 30days
@ $0.014 per mil
+
24hrs x 30days
@ $0.015 per hr
$47.088
1k x 60s x 60m x 24hr x 30days
@ $0.5 per mil
$1296.00
1k x 60s x 60m x 24hr x 30days
@ $0.4 per mil (send)
+
1k x 60s x 60m x 24hr x 30days
@ 10 batch
@ 20s long polling
@ $0.4 per mil (receive)
$1041.98
stream as a transaction log
http://bit.ly/2Dpidje
events are an enabler for
COMPOSABILITY
AWS LAMBDA
is the...
Kinesis
Kinesis
API Gateway AWS Lambda API GatewayAWS Lambda
service-A service-B
Kinesis
API Gateway AWS Lambda API GatewayAWS Lambda
service-A service-B
Kinesis
API Gateway AWS Lambda API GatewayAWS Lambda
service-A service-B
AWS Lambda
AWS Lambda
AWS Lambda
Kinesis
API Gateway AWS Lambda API GatewayAWS Lambda
service-A service-B
AWS Lambda
AWS Lambda
AWS Lambda DynamoDBIOT
Kinesis
API Gateway AWS Lambda API GatewayAWS Lambda
service-A service-B
AWS Lambda
AWS Lambda
AWS Lambda DynamoDBIOT
Kinesis
API Gateway AWS Lambda API GatewayAWS Lambda
service-A service-B
AWS Lambda
AWS Lambda
AWS Lambda DynamoDBIOT
AWS Lambda AWS Lambda
build loosely-coupled system
through events
service A service B
service C service D
bounded context
bounded context
service A service B
service C service D
bounded context
bounded context
service A service B
service C service D
Streams and serverless at DAZN
service A service B
service C service D
service A service B
service C service D
service A service B
service C service Dbackward-compatible?
Streams and serverless at DAZN
bounded context
DON’T use events to
orchestrate workflows
within the same
bounded context
bounded context
adds unnecessary
complexity to logging,
tracing, and end-to-end
reporting
bounded context
the workflow doesn’t exist
as a standalone concept,
but as the sum of a series
of loosely connected parts
Step Functions
use Step Functions instead
Step Functions
don’t forget to emit events
from the workflow
Step Functions
so others can react to state
changes that happened as
part of the workflow
analytics pipeline
S3 Buckets
S3 BucketsKinesis Streams Kinesis Firehose
S3 BucketsKinesis Streams
AWS Lambda
Kinesis Firehose
S3 BucketsKinesis Streams
AWS Lambda AWS Lambda
Kinesis Firehose
S3 BucketsKinesis Streams
AWS Lambda AWS LambdaAWS Lambda
Kinesis Firehose
S3 BucketsKinesis Streams
AWS Lambda AWS LambdaAWS Lambda
DynamoDB
ElasticSearch
Kinesis Firehose
S3 BucketsKinesis Streams
AWS Lambda AWS Lambda
Athena QuickSight
AWS Lambda
Kinesis Firehose
S3 BucketsKinesis Streams
AWS Lambda AWS Lambda
Athena QuickSight
AWS Lambda
Kinesis Firehose
secure sensitive data both
at rest and in-transit
leverage server-side encryption
http://amzn.to/1N3Twb8
http://amzn.to/1xF41eX
http://amzn.to/2tgvFR2
http://amzn.to/2GCMbAT
principle of Least Privilege
keep functions single-purposed
& apply per function policies
Streams and serverless at DAZN
http://bit.ly/2QIVYvL
https://lumigo.io/blog/lambda-and-kinesis-beware-of-hot-streams/
stream
doY
doX
doY
doX
doY
shard
shard
EGRESS
2MB/s data per subscriber,
doX
shard
5 reads/s
throughput is maintained as you
add more subscribers, but…
Streams and serverless at DAZN
it’s difficult to add more than 15
subscriber functions to a stream
Streams and serverless at DAZN
my microservices
user_events
order_events
promo_events
my microservices
user_events
order_events
promo_events
my microservices
still possible to have too many
subscribers for a stream
user_events
order_events
promo_events
my microservices
implicit coupling between
publisher and subscriber
user_events
order_events
promo_events
my microservices
lose ordering of related
events in different streams
lose ordering of related
events in different streams
Streams and serverless at DAZN
preserve ordering of
related events
extra cost for these
consumer apps
http://bit.ly/2hxZGui
observability
Streams and serverless at DAZN
Streams and serverless at DAZN
{
error: …
message: …
correlation-id: …
}
{
message: …
correlation-id: …
}
https://github.com/getndazn/dazn-lambda-powertools
@theburningmonk
theburningmonk.com
github.com/theburningmonk

More Related Content

PDF
How to build a social network on serverless
PDF
How to build observability into a serverless application
PDF
Serverless security: defence against the dark arts
PDF
Security in serverless world
PDF
How to build a social network on serverless
PDF
Running serverless at scale
PDF
Troubleshooting serverless applications
PDF
Serverless Architectural Patterns
How to build a social network on serverless
How to build observability into a serverless application
Serverless security: defence against the dark arts
Security in serverless world
How to build a social network on serverless
Running serverless at scale
Troubleshooting serverless applications
Serverless Architectural Patterns

What's hot (20)

PDF
Serveless Design Patterns (Serverless Computing London)
PDF
How to improve lambda cold starts
PDF
Serverless is a win for businesses, not just developers
PDF
You wouldn't build a toast, would you?
PDF
How did we get here and where are we going
PDF
How to build observability into Serverless (O'Reilly Velocity 2018)
PPTX
A. De Biase/C. Quatrini/M. Barsocchi - API Release Process: how to make peopl...
PDF
Serverless in production, an experience report (CoDe-Conf)
PDF
The future of paas is serverless
PDF
What makes me to migrate entire VPC JAWS PANKRATION 2021
PDF
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
PDF
Security in serverless world (get.net)
PDF
Serverless in production, an experience report (IWOMM)
PDF
Adopting Java for the Serverless world at JUG Hamburg
PDF
Why your next serverless project should use AWS AppSync
PDF
Adapting Java for the Serverless World at JUG Barcelona
PDF
Adopting Java for the Serverless world at IT Tage
PDF
Adopting Java for the Serverless world at Serverless Meetup Italy
PDF
AWS Lambda from the trenches
PDF
Aws Lambda in Swift - NSLondon - 3rd December 2020
Serveless Design Patterns (Serverless Computing London)
How to improve lambda cold starts
Serverless is a win for businesses, not just developers
You wouldn't build a toast, would you?
How did we get here and where are we going
How to build observability into Serverless (O'Reilly Velocity 2018)
A. De Biase/C. Quatrini/M. Barsocchi - API Release Process: how to make peopl...
Serverless in production, an experience report (CoDe-Conf)
The future of paas is serverless
What makes me to migrate entire VPC JAWS PANKRATION 2021
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Security in serverless world (get.net)
Serverless in production, an experience report (IWOMM)
Adopting Java for the Serverless world at JUG Hamburg
Why your next serverless project should use AWS AppSync
Adapting Java for the Serverless World at JUG Barcelona
Adopting Java for the Serverless world at IT Tage
Adopting Java for the Serverless world at Serverless Meetup Italy
AWS Lambda from the trenches
Aws Lambda in Swift - NSLondon - 3rd December 2020

Similar to Streams and serverless at DAZN (20)

PDF
How to build a social network on serverless
PDF
How to build a social network on serverless | Yan Cui
PDF
How to build a social network on Serverless (AWS Community Summit)
PDF
Serverless in production, an experience report
PDF
What can you do with lambda in 2020
PDF
Serverless in Production, an experience report (AWS UG South Wales)
PDF
Serverless in production, an experience report (FullStack 2018)
PDF
Architectural changes with serverless
PDF
Apply best parts of microservices to serverless
PDF
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...
PDF
Serverless Design Patterns (London Dev Community)
PDF
The Hitchhiker's Guide to Serverless JavaScript
PDF
Netflix keystone streaming data pipeline @scale in the cloud-dbtb-2016
PDF
Microservices Antipatterns
PDF
Serveless design patterns
PDF
The Netflix Way to deal with Big Data Problems
PDF
Serverless Design Patterns
PPTX
Micro Services Architecture
PDF
How to Build Streaming Apps with Confluent II
PDF
What’s new in serverless - re:Invent 2020
How to build a social network on serverless
How to build a social network on serverless | Yan Cui
How to build a social network on Serverless (AWS Community Summit)
Serverless in production, an experience report
What can you do with lambda in 2020
Serverless in Production, an experience report (AWS UG South Wales)
Serverless in production, an experience report (FullStack 2018)
Architectural changes with serverless
Apply best parts of microservices to serverless
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...
Serverless Design Patterns (London Dev Community)
The Hitchhiker's Guide to Serverless JavaScript
Netflix keystone streaming data pipeline @scale in the cloud-dbtb-2016
Microservices Antipatterns
Serveless design patterns
The Netflix Way to deal with Big Data Problems
Serverless Design Patterns
Micro Services Architecture
How to Build Streaming Apps with Confluent II
What’s new in serverless - re:Invent 2020

More from Yan Cui (20)

PDF
How to win the game of trade-offs
PDF
How to choose the right messaging service
PDF
How to choose the right messaging service for your workload
PDF
Patterns and practices for building resilient serverless applications.pdf
PDF
Lambda and DynamoDB best practices
PDF
Lessons from running AppSync in prod
PDF
Serverless observability - a hero's perspective
PDF
How to ship customer value faster with step functions
PDF
How serverless changes the cost paradigm
PDF
Build social network in 4 weeks
PDF
Patterns and practices for building resilient serverless applications
PDF
How to bring chaos engineering to serverless
PDF
Migrating existing monolith to serverless in 8 steps
PDF
Building a social network in under 4 weeks with Serverless and GraphQL
PDF
FinDev as a business advantage in the post covid19 economy
PDF
A chaos experiment a day, keeping the outage away
PDF
How to debug slow lambda response times
PDF
What can you do with lambda in 2020
PDF
How to ship customer value faster with step functions
PDF
Debugging Lambda timeouts
How to win the game of trade-offs
How to choose the right messaging service
How to choose the right messaging service for your workload
Patterns and practices for building resilient serverless applications.pdf
Lambda and DynamoDB best practices
Lessons from running AppSync in prod
Serverless observability - a hero's perspective
How to ship customer value faster with step functions
How serverless changes the cost paradigm
Build social network in 4 weeks
Patterns and practices for building resilient serverless applications
How to bring chaos engineering to serverless
Migrating existing monolith to serverless in 8 steps
Building a social network in under 4 weeks with Serverless and GraphQL
FinDev as a business advantage in the post covid19 economy
A chaos experiment a day, keeping the outage away
How to debug slow lambda response times
What can you do with lambda in 2020
How to ship customer value faster with step functions
Debugging Lambda timeouts

Recently uploaded (20)

PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation theory and applications.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
A Presentation on Artificial Intelligence
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
KodekX | Application Modernization Development
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Big Data Technologies - Introduction.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
The Rise and Fall of 3GPP – Time for a Sabbatical?
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation theory and applications.pdf
The AUB Centre for AI in Media Proposal.docx
Diabetes mellitus diagnosis method based random forest with bat algorithm
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Chapter 3 Spatial Domain Image Processing.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Machine learning based COVID-19 study performance prediction
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
A Presentation on Artificial Intelligence
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
“AI and Expert System Decision Support & Business Intelligence Systems”
KodekX | Application Modernization Development
Encapsulation_ Review paper, used for researhc scholars
Big Data Technologies - Introduction.pptx

Streams and serverless at DAZN