SlideShare una empresa de Scribd logo
1 de 25
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS re:INVENT
The Gronk Effect
E f f i c i e n t l y H a n d l i n g H u g e S p i k e s i n T r a f f i c U s i n g P r e d i c t i v e
A n a l y t i c s a t D r a f t K i n g s
W I N 2 0 2
N o v e m b e r 2 7 , 2 0 1 7
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
WHAT’S IN STORE?
In this presentation, you will learn strategies for scaling infrastructure based upon predicted demand as
opposed to current demand
Current Demand
The CPU on your server is currently at 70%
Predicted Demand
Two hours from now, your peak traffic rate will be 1 million requests per minute
These strategies are suitable for use cases where demand changes too rapidly to respond reactively
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
WHAT DOES DRAFTKINGS DO?
A bit of context to help understand our technical problem
DraftKings is a sports media entertainment company and the largest provider of Daily Fantasy Sports
What’s Daily Fantasy Sports?
• Daily Fantasy Sports (DFS) are similar to season long
fantasy sports, with the key exception that the entire
contest starts and ends in a much shorter time frame.
• Contests range from a single day to one week,
depending on the sport
• Users pick a team of players based on a salary cap,
and those players earn points based on their in-game
performance.
• Players test their skills and knowledge playing
privately with friends or with other fans globally.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
WHAT IS DRAFTKINGS’ SCALE?
At our size, efficient scaling of infrastructure translates into significant monetary savings.
1MM
API
Requests/Min
8MM
Registered
Users
22K
Entries/Min
60+
Microservices
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
WHAT IS DRAFTKINGS’ TECH STACK?
DraftKings is a large deployer of Windows machines within the AWS Cloud
Why Windows?
Warning: Highly subjective opinions ahead
• Incredible IDE with Visual Studio
• Flexibility of C#—benefits of a statically typed language with dynamic capabilities
• Founding team had a strong network of C# developers
Other Technologies in Use:
• Amazon Aurora
• Amazon MySql RDS
• ELB
• Swift, Objective C, Java, React
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
THE GRONK EFFECT
Gronk Effect (Noun): The request pattern to an API when users synchronize requests by watching the same
sports event.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
OPTION 1
Always Scale to Previous Max
Peak
OPTION 2
Scale On Demand
OPTION 3
Scale to Predicted Short Term
Peak
OUR SCALING PROBLEM
How do you scale for traffic that spikes 5x minute to minute?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Support 5x increases in
HTTP traffic in 2 minutes
timeframe
Lots of user-specific data
limits caching
effectiveness
Reactive scaling is too
slow to handle traffic
spikes (6 minutes)
CHALLENGES
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
N F L T r a f f i cM L B T r a f f i c
TRAFFIC PATTERN BY SPORT
MLB Peak
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SCALING SOLUTION
Scale to predicted peak
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Manual
• Time consuming
• Error prone
Scheduled
• Managed by centralized process; not
scalable as number of services grows
• Over-provisioning of environment
leading to increased costs
DRAFTKINGS’ PREVIOUS SCALING STRATEGIES
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Prediction Based Scaling
• Time to scale up no longer a
concern
• Reduced costs by lowering the
average number of running
EC2 instances
• Scaling actions are
decentralized, scales as
number of services grow
SOLUTION
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
PREDICTIVE SCALING SYSTEM OVERVIEW
Predict Traffic
Compute
Scaling Needs
Scale Out
Step 1 Step 2 Step 3
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
PREDICT TRAFFIC
Pace UpdaterAurora RDS
Instance
Traffic Predictor
Aerospike cluster
CloudWatch
Event CRON
Load data
from
database
Publish
prediction
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
COMPUTE SCALING NEEDS
Max HTTP Traffic
Prediction
NOAA .NET
Webservice
Amazon CloudWatch
Required Scale
Out metric
Current Production Scale
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
COMPUTE SCALING NEEDS—DETAILS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SCALE OUT
CloudWatch alarm on
service load metric
Stepped scaling policy
increases desired
count
Scale Out
SNS Topic
.NET Lambda function
executes safety checks
Triggers scale
out policy
Instance
launched
lifecycle hook
Invokes
Lambda
function
Function
completes
lifecycle hook
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
A u t o S c a l i n g p o l i c yC l o u d W a t c h a l a r m
SCALE OUT—DETAILS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
{
"LifecycleHookName": "scale_out",
"AccountId": "248797271221",
"RequestId": "d8857c21-8662-45eb-80cc-90f5516950e1",
"LifecycleTransition":
"autoscaling:EC2_INSTANCE_LAUNCHING",
"AutoScalingGroupName": "Titan-Service",
"Service": "AWS Auto Scaling",
"Time": "2017-10-10T22:22:47.808Z",
"EC2InstanceId": "i-0fe90523624cd5d71",
"LifecycleActionToken": "2c5492b6-29b8-4ec6-af46-
57e05c87f77b"
}
SCALE OUT—DETAILS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SCALE OUT—DETAILS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SCALE PREDICTOR—HIGH LEVEL PATTERN
Latest state
available for
consumption
by scaling
service
• AWS Lambda function
recomputes every 2 minutes
• Prediction method: Kalman Filter
used at DraftKings
• Method of prediction should be
customized to your traffic
patterns
Traffic
Predictor
State
Storage
• JSON-formatted object stored in
database or on Amazon S3
• Constantly updated by prediction
engine
• Aerospike used at DraftKings
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
UNDER THE HOOD—TRAFFIC PREDICTOR
Target:
Prediction of
upcoming
traffic
Incoming
Data Stream
Kalman
Filter
Kalman Filter is an intelligent state updater
• Algorithm considers previous states, changes since previous
state, and prior historical traffic pacing to constantly update
traffic projections
• Kalman Filters used a wide range of applications, including
projecting missile trajectories and projecting the positions of
self-driving vehicles
Historical
Benchmarks
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ADAPT MODEL TO FIT YOUR TRAFFIC PATTERNS
Kalman Filter ARIMA Model
Choose the right tool based on your enterprise traffic patterns
• Daily Fantasy Sports traffic pattern will differ greatly from other types of businesses
• Choose prediction methods and model inputs that suit your needs—many possible estimation frameworks
Hidden Markov
Model
Hazard Model Others
ARCH Model
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
{
"PacerVersion": "Tomahawk",
"PredMaxRequestRate1hr": 5894,
"PredMaxRequestRate2hr": 6143,
"PredMaxRequestRate3hr": 7294,
"PredMaxRequestRate4hr": 8483,
"PredMaxRequestRate4hr": 10945,
"PredMaxRequestRate5hr": 15827,
"PredMaxRequestRate6hr": 26113,
"PredMaxRequestRate7hr": 8094,
"PredMaxRequestRate8hr": 9344,
"PredMaxRequestRate9hr": 11995,
"PredMaxRequestRate10hr": 7566,
"PredMaxRequestRate11hr": 8732,
"PredMaxRequestRate12hr": 9585,
"UpdateDate": "2017-10-08 10:23:45"
}
UNDER THE HOOD—MAINTAINING STATE
Kalman filter stores its projections as JSON-formatted
object
• Includes traffic projections for upcoming 12 hours
• Updates every 2 minutes
• Stored in database or S3—available for query by scaling
service
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you!

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

DAT332_How Verizon is Adopting Amazon Aurora PostgreSQL for Enterprise Workloads
DAT332_How Verizon is Adopting Amazon Aurora PostgreSQL for Enterprise WorkloadsDAT332_How Verizon is Adopting Amazon Aurora PostgreSQL for Enterprise Workloads
DAT332_How Verizon is Adopting Amazon Aurora PostgreSQL for Enterprise Workloads
 
ABD217_From Batch to Streaming
ABD217_From Batch to StreamingABD217_From Batch to Streaming
ABD217_From Batch to Streaming
 
SRV211_Building Smart Applications Leveraging AWS to Drive Customer and Worke...
SRV211_Building Smart Applications Leveraging AWS to Drive Customer and Worke...SRV211_Building Smart Applications Leveraging AWS to Drive Customer and Worke...
SRV211_Building Smart Applications Leveraging AWS to Drive Customer and Worke...
 
From Batch to Streaming - How Amazon Flex Uses Real-time Analytics
From Batch to Streaming - How Amazon Flex Uses Real-time AnalyticsFrom Batch to Streaming - How Amazon Flex Uses Real-time Analytics
From Batch to Streaming - How Amazon Flex Uses Real-time Analytics
 
ARC207_Monitoring Performance of Enterprise Applications on AWS
ARC207_Monitoring Performance of Enterprise Applications on AWSARC207_Monitoring Performance of Enterprise Applications on AWS
ARC207_Monitoring Performance of Enterprise Applications on AWS
 
EUT302_Data Ingestion at Seismic Scale Best Practices for Processing Petabyte...
EUT302_Data Ingestion at Seismic Scale Best Practices for Processing Petabyte...EUT302_Data Ingestion at Seismic Scale Best Practices for Processing Petabyte...
EUT302_Data Ingestion at Seismic Scale Best Practices for Processing Petabyte...
 
Tooling Up for Efficiency: DIY Solutions @ Netflix - ABD319 - re:Invent 2017
Tooling Up for Efficiency: DIY Solutions @ Netflix - ABD319 - re:Invent 2017Tooling Up for Efficiency: DIY Solutions @ Netflix - ABD319 - re:Invent 2017
Tooling Up for Efficiency: DIY Solutions @ Netflix - ABD319 - re:Invent 2017
 
Run Your CI/CD and Test Workloads for 90% Less with Amazon EC2 Spot - CMP317 ...
Run Your CI/CD and Test Workloads for 90% Less with Amazon EC2 Spot - CMP317 ...Run Your CI/CD and Test Workloads for 90% Less with Amazon EC2 Spot - CMP317 ...
Run Your CI/CD and Test Workloads for 90% Less with Amazon EC2 Spot - CMP317 ...
 
Scaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersScaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million Users
 
GPSTEC313_GPS Real-Time Data Processing with AWS Lambda Quickly, at Scale, an...
GPSTEC313_GPS Real-Time Data Processing with AWS Lambda Quickly, at Scale, an...GPSTEC313_GPS Real-Time Data Processing with AWS Lambda Quickly, at Scale, an...
GPSTEC313_GPS Real-Time Data Processing with AWS Lambda Quickly, at Scale, an...
 
ABD207 building a banking utility leveraging aws to fight financial crime and...
ABD207 building a banking utility leveraging aws to fight financial crime and...ABD207 building a banking utility leveraging aws to fight financial crime and...
ABD207 building a banking utility leveraging aws to fight financial crime and...
 
ARC329_Optimizing Performance and Efficiency for Amazon EC2 and More with Tur...
ARC329_Optimizing Performance and Efficiency for Amazon EC2 and More with Tur...ARC329_Optimizing Performance and Efficiency for Amazon EC2 and More with Tur...
ARC329_Optimizing Performance and Efficiency for Amazon EC2 and More with Tur...
 
Analyzing Streaming Data in Real-time with Amazon Kinesis
Analyzing Streaming Data in Real-time with Amazon KinesisAnalyzing Streaming Data in Real-time with Amazon Kinesis
Analyzing Streaming Data in Real-time with Amazon Kinesis
 
ATC303-Cache Me If You Can Minimizing Latency While Optimizing Cost Through A...
ATC303-Cache Me If You Can Minimizing Latency While Optimizing Cost Through A...ATC303-Cache Me If You Can Minimizing Latency While Optimizing Cost Through A...
ATC303-Cache Me If You Can Minimizing Latency While Optimizing Cost Through A...
 
Migrating Microsoft Workloads to AWS
Migrating Microsoft Workloads to AWSMigrating Microsoft Workloads to AWS
Migrating Microsoft Workloads to AWS
 
GPSBUS223-Starting Out with the AWS Partner Network
GPSBUS223-Starting Out with the AWS Partner NetworkGPSBUS223-Starting Out with the AWS Partner Network
GPSBUS223-Starting Out with the AWS Partner Network
 
GPSTEC305-Machine Learning in Capital Markets
GPSTEC305-Machine Learning in Capital MarketsGPSTEC305-Machine Learning in Capital Markets
GPSTEC305-Machine Learning in Capital Markets
 
What's New in Serverless
What's New in ServerlessWhat's New in Serverless
What's New in Serverless
 
Mapmaking and Location-Based Systems in the Cloud - ENT339 - re:Invent 2017
Mapmaking and Location-Based Systems in the Cloud - ENT339 - re:Invent 2017Mapmaking and Location-Based Systems in the Cloud - ENT339 - re:Invent 2017
Mapmaking and Location-Based Systems in the Cloud - ENT339 - re:Invent 2017
 
DAT307_Modern Cloud Data Warehousing
DAT307_Modern Cloud Data WarehousingDAT307_Modern Cloud Data Warehousing
DAT307_Modern Cloud Data Warehousing
 

Similar a The Gronk Effect: Efficiently Handling Huge Spikes in Traffic Using Predictive Analytics at DraftKings - WIN202 - re:Invent 2017

Similar a The Gronk Effect: Efficiently Handling Huge Spikes in Traffic Using Predictive Analytics at DraftKings - WIN202 - re:Invent 2017 (20)

ATC301-Big Data & Analytics for Manufacturing Operations
ATC301-Big Data & Analytics for Manufacturing OperationsATC301-Big Data & Analytics for Manufacturing Operations
ATC301-Big Data & Analytics for Manufacturing Operations
 
Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...
Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...
Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...
 
HLC308_Refactoring to the Cloud
HLC308_Refactoring to the CloudHLC308_Refactoring to the Cloud
HLC308_Refactoring to the Cloud
 
Healthcare Payers and Serverless Batch Processing Engines - HLC308 - re:Inven...
Healthcare Payers and Serverless Batch Processing Engines - HLC308 - re:Inven...Healthcare Payers and Serverless Batch Processing Engines - HLC308 - re:Inven...
Healthcare Payers and Serverless Batch Processing Engines - HLC308 - re:Inven...
 
Navigating Microservice Architecture with AWS - AWS Public Sector Summit Sing...
Navigating Microservice Architecture with AWS - AWS Public Sector Summit Sing...Navigating Microservice Architecture with AWS - AWS Public Sector Summit Sing...
Navigating Microservice Architecture with AWS - AWS Public Sector Summit Sing...
 
ARC303_Running Lean Architectures How to Optimize for Cost Efficiency
ARC303_Running Lean Architectures How to Optimize for Cost EfficiencyARC303_Running Lean Architectures How to Optimize for Cost Efficiency
ARC303_Running Lean Architectures How to Optimize for Cost Efficiency
 
ARC303_Running Lean Architectures How to Optimize for Cost Efficiency
ARC303_Running Lean Architectures How to Optimize for Cost EfficiencyARC303_Running Lean Architectures How to Optimize for Cost Efficiency
ARC303_Running Lean Architectures How to Optimize for Cost Efficiency
 
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech TalksAWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
 
How Nextdoor Built a Scalable, Serverless Data Pipeline for Billions of Event...
How Nextdoor Built a Scalable, Serverless Data Pipeline for Billions of Event...How Nextdoor Built a Scalable, Serverless Data Pipeline for Billions of Event...
How Nextdoor Built a Scalable, Serverless Data Pipeline for Billions of Event...
 
ABD307_Deep Analytics for Global AWS Marketing Organization
ABD307_Deep Analytics for Global AWS Marketing OrganizationABD307_Deep Analytics for Global AWS Marketing Organization
ABD307_Deep Analytics for Global AWS Marketing Organization
 
DynamoDB - What's new - DAT304 - re:Invent 2017
DynamoDB - What's new - DAT304 - re:Invent 2017DynamoDB - What's new - DAT304 - re:Invent 2017
DynamoDB - What's new - DAT304 - re:Invent 2017
 
What's New in Serverless - SRV305 - re:Invent 2017
What's New in Serverless - SRV305 - re:Invent 2017What's New in Serverless - SRV305 - re:Invent 2017
What's New in Serverless - SRV305 - re:Invent 2017
 
Citrix Moves Data to Amazon Redshift Fast with Matillion ETL
 Citrix Moves Data to Amazon Redshift Fast with Matillion ETL Citrix Moves Data to Amazon Redshift Fast with Matillion ETL
Citrix Moves Data to Amazon Redshift Fast with Matillion ETL
 
FINRA's Managed Data Lake: Next-Gen Analytics in the Cloud - ENT328 - re:Inve...
FINRA's Managed Data Lake: Next-Gen Analytics in the Cloud - ENT328 - re:Inve...FINRA's Managed Data Lake: Next-Gen Analytics in the Cloud - ENT328 - re:Inve...
FINRA's Managed Data Lake: Next-Gen Analytics in the Cloud - ENT328 - re:Inve...
 
Migrating database to cloud
Migrating database to cloudMigrating database to cloud
Migrating database to cloud
 
Building a Real-Time Data Platform on AWS
Building a Real-Time Data Platform on AWSBuilding a Real-Time Data Platform on AWS
Building a Real-Time Data Platform on AWS
 
Dive deep into technical enhancements - re:Invent Come to London 2.0
Dive deep into technical enhancements - re:Invent Come to London 2.0Dive deep into technical enhancements - re:Invent Come to London 2.0
Dive deep into technical enhancements - re:Invent Come to London 2.0
 
Auto Scaling: The Fleet Management Solution for Planet Earth - CMP201 - re:In...
Auto Scaling: The Fleet Management Solution for Planet Earth - CMP201 - re:In...Auto Scaling: The Fleet Management Solution for Planet Earth - CMP201 - re:In...
Auto Scaling: The Fleet Management Solution for Planet Earth - CMP201 - re:In...
 
ENT315_Landing Zones
ENT315_Landing ZonesENT315_Landing Zones
ENT315_Landing Zones
 
Building Modern Applications on AWS.pptx
Building Modern Applications on AWS.pptxBuilding Modern Applications on AWS.pptx
Building Modern Applications on AWS.pptx
 

Más de Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

Más de Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

The Gronk Effect: Efficiently Handling Huge Spikes in Traffic Using Predictive Analytics at DraftKings - WIN202 - re:Invent 2017

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS re:INVENT The Gronk Effect E f f i c i e n t l y H a n d l i n g H u g e S p i k e s i n T r a f f i c U s i n g P r e d i c t i v e A n a l y t i c s a t D r a f t K i n g s W I N 2 0 2 N o v e m b e r 2 7 , 2 0 1 7
  • 2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. WHAT’S IN STORE? In this presentation, you will learn strategies for scaling infrastructure based upon predicted demand as opposed to current demand Current Demand The CPU on your server is currently at 70% Predicted Demand Two hours from now, your peak traffic rate will be 1 million requests per minute These strategies are suitable for use cases where demand changes too rapidly to respond reactively
  • 3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. WHAT DOES DRAFTKINGS DO? A bit of context to help understand our technical problem DraftKings is a sports media entertainment company and the largest provider of Daily Fantasy Sports What’s Daily Fantasy Sports? • Daily Fantasy Sports (DFS) are similar to season long fantasy sports, with the key exception that the entire contest starts and ends in a much shorter time frame. • Contests range from a single day to one week, depending on the sport • Users pick a team of players based on a salary cap, and those players earn points based on their in-game performance. • Players test their skills and knowledge playing privately with friends or with other fans globally.
  • 4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. WHAT IS DRAFTKINGS’ SCALE? At our size, efficient scaling of infrastructure translates into significant monetary savings. 1MM API Requests/Min 8MM Registered Users 22K Entries/Min 60+ Microservices
  • 5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. WHAT IS DRAFTKINGS’ TECH STACK? DraftKings is a large deployer of Windows machines within the AWS Cloud Why Windows? Warning: Highly subjective opinions ahead • Incredible IDE with Visual Studio • Flexibility of C#—benefits of a statically typed language with dynamic capabilities • Founding team had a strong network of C# developers Other Technologies in Use: • Amazon Aurora • Amazon MySql RDS • ELB • Swift, Objective C, Java, React
  • 6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. THE GRONK EFFECT Gronk Effect (Noun): The request pattern to an API when users synchronize requests by watching the same sports event.
  • 7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. OPTION 1 Always Scale to Previous Max Peak OPTION 2 Scale On Demand OPTION 3 Scale to Predicted Short Term Peak OUR SCALING PROBLEM How do you scale for traffic that spikes 5x minute to minute?
  • 8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Support 5x increases in HTTP traffic in 2 minutes timeframe Lots of user-specific data limits caching effectiveness Reactive scaling is too slow to handle traffic spikes (6 minutes) CHALLENGES
  • 9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. N F L T r a f f i cM L B T r a f f i c TRAFFIC PATTERN BY SPORT MLB Peak
  • 10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SCALING SOLUTION Scale to predicted peak
  • 11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Manual • Time consuming • Error prone Scheduled • Managed by centralized process; not scalable as number of services grows • Over-provisioning of environment leading to increased costs DRAFTKINGS’ PREVIOUS SCALING STRATEGIES
  • 12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Prediction Based Scaling • Time to scale up no longer a concern • Reduced costs by lowering the average number of running EC2 instances • Scaling actions are decentralized, scales as number of services grow SOLUTION
  • 13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. PREDICTIVE SCALING SYSTEM OVERVIEW Predict Traffic Compute Scaling Needs Scale Out Step 1 Step 2 Step 3
  • 14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. PREDICT TRAFFIC Pace UpdaterAurora RDS Instance Traffic Predictor Aerospike cluster CloudWatch Event CRON Load data from database Publish prediction
  • 15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. COMPUTE SCALING NEEDS Max HTTP Traffic Prediction NOAA .NET Webservice Amazon CloudWatch Required Scale Out metric Current Production Scale
  • 16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. COMPUTE SCALING NEEDS—DETAILS
  • 17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SCALE OUT CloudWatch alarm on service load metric Stepped scaling policy increases desired count Scale Out SNS Topic .NET Lambda function executes safety checks Triggers scale out policy Instance launched lifecycle hook Invokes Lambda function Function completes lifecycle hook
  • 18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A u t o S c a l i n g p o l i c yC l o u d W a t c h a l a r m SCALE OUT—DETAILS
  • 19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. { "LifecycleHookName": "scale_out", "AccountId": "248797271221", "RequestId": "d8857c21-8662-45eb-80cc-90f5516950e1", "LifecycleTransition": "autoscaling:EC2_INSTANCE_LAUNCHING", "AutoScalingGroupName": "Titan-Service", "Service": "AWS Auto Scaling", "Time": "2017-10-10T22:22:47.808Z", "EC2InstanceId": "i-0fe90523624cd5d71", "LifecycleActionToken": "2c5492b6-29b8-4ec6-af46- 57e05c87f77b" } SCALE OUT—DETAILS
  • 20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SCALE OUT—DETAILS
  • 21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SCALE PREDICTOR—HIGH LEVEL PATTERN Latest state available for consumption by scaling service • AWS Lambda function recomputes every 2 minutes • Prediction method: Kalman Filter used at DraftKings • Method of prediction should be customized to your traffic patterns Traffic Predictor State Storage • JSON-formatted object stored in database or on Amazon S3 • Constantly updated by prediction engine • Aerospike used at DraftKings
  • 22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. UNDER THE HOOD—TRAFFIC PREDICTOR Target: Prediction of upcoming traffic Incoming Data Stream Kalman Filter Kalman Filter is an intelligent state updater • Algorithm considers previous states, changes since previous state, and prior historical traffic pacing to constantly update traffic projections • Kalman Filters used a wide range of applications, including projecting missile trajectories and projecting the positions of self-driving vehicles Historical Benchmarks
  • 23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ADAPT MODEL TO FIT YOUR TRAFFIC PATTERNS Kalman Filter ARIMA Model Choose the right tool based on your enterprise traffic patterns • Daily Fantasy Sports traffic pattern will differ greatly from other types of businesses • Choose prediction methods and model inputs that suit your needs—many possible estimation frameworks Hidden Markov Model Hazard Model Others ARCH Model
  • 24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. { "PacerVersion": "Tomahawk", "PredMaxRequestRate1hr": 5894, "PredMaxRequestRate2hr": 6143, "PredMaxRequestRate3hr": 7294, "PredMaxRequestRate4hr": 8483, "PredMaxRequestRate4hr": 10945, "PredMaxRequestRate5hr": 15827, "PredMaxRequestRate6hr": 26113, "PredMaxRequestRate7hr": 8094, "PredMaxRequestRate8hr": 9344, "PredMaxRequestRate9hr": 11995, "PredMaxRequestRate10hr": 7566, "PredMaxRequestRate11hr": 8732, "PredMaxRequestRate12hr": 9585, "UpdateDate": "2017-10-08 10:23:45" } UNDER THE HOOD—MAINTAINING STATE Kalman filter stores its projections as JSON-formatted object • Includes traffic projections for upcoming 12 hours • Updates every 2 minutes • Stored in database or S3—available for query by scaling service
  • 25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you!