際際滷

際際滷Share a Scribd company logo
Extensions Developer Services Team
@MovingViolation
Karl Patrick
Senior Backend
Software Engineer
Extension Design Patterns for Twitch Scale
TwitchCon 2018 San Jose, California
@XPCagey
15 years of experience prior to Twitch
Single person hobby projects to AAA titles
Build/Tools/Engine/Server/Gameplay
Karl Patrick
Game Developer
TwitchCon 2018 San Jose, California
Extensions
Usually Fail to Scale
-Popular technologies dont work for
high-volume channels
-False starts with high-profile
Extensions inspired this talk
-High concurrent users is only part of
the story
TWITCH SCALE
TwitchCon 2018 San Jose, California
- When a streamer activates
Extensions during a stream
- When a channel is raided by
another audience
- When viewers refresh due to a
technical issue
Traffic Spikes
10,000x traffic in
One Second
WHATS THE BIG DEAL?
~20 viewers / 10 seconds
40,000 viewers / 10 seconds
TwitchCon 2018 San Jose, California
How can Extensions
Scale for Traffic
Bursts?
TwitchCon 2018 San Jose, California
Server
TwitchCon 2018 San Jose, CaliforniaTwitchCon 2018 San Jose, California
Server Twitch
PubSub
Call Twitch PubSub from
your service to push events
instead of polling for
updates.
If you need to whisper
secrets, shout the list of
people who need to ask for
them instead of having
every user ask.
Use a
Megaphone
SCALING READS
TwitchCon 2018 San Jose, California
Be Lazy:
Wait Before You
Ask for Data
- Use a splash screen when you first
load your Extension
- Schedule your requests after a pause
- Cancel the request if it is answered
while youre waiting
SCALING READS
Document
loads
Schedule
request
PubSub sent
before timer
expires?
Cancel
request
Send
request
Yes
No
TwitchCon 2018 San Jose, California
Roll the Dice:
Randomize Your
Wait Time
SCALING READS
- Make each client pick a number
instead of using one delay
- Jitter will spread out traffic if
clients load at the same time
Spread out work with a
random delay
All requests at one time
TwitchCon 2018 San Jose, California
- Tell clients how long they can wait to
respond
- Roll the dice on each client and cancel
if the response comes while waiting
- On each client request, add more wait
time to the next response
- Larger audiences automatically get
longer waits and lower traffic per
viewer
Listen to Yourself:
Send Wait Times
From the Server
SCALING READS
Server
Send time
remaining
Use time to decide
when to send
Add time on
every request
PubSub
TwitchCon 2018 San Jose, California
Green
Purple
Orange
Blue
Whats your favorite color?
What About
Interactive
Extensions?
TwitchCon 2018 San Jose, California
- Authorize requests and use cool
downs to prevent spam
- Popular Extensions have seen
attempts to spam within 20 minutes
of release
- Chrome developer tools make it
simple to repeat service requests
Stop Cheaters
SCALING WRITES
!
TwitchCon 2018 San Jose, California
- Be lazy and roll the dice to spread
write traffic; listen to yourself to
make sure you answer in time
- Predict and apply fake responses
while youre waiting
- Once you have a real response,
replace the fake one
Start Cheating:
Fake Early Responses
SCALING WRITES
User
Clicks
Schedule & Send
Request
Service Calculates
Result
PubSub Message
Arrives
Show
Result
TwitchCon 2018 San Jose, California
Take Command:
Batch Frequent
Requests
SCALING WRITES
How can Extensions Scale for Traffic Bursts?
- Use a Megaphone
- Listen to Yourself
- Be Lazy
- Roll the Dice
- Stop Cheaters
- Start Cheating
- Take Command
Questions?
Ad

Recommended

Building Extensions With You
Building Extensions With You
Twitch Developers
Twitch Extension Review Process: The Missing Manual
Twitch Extension Review Process: The Missing Manual
Twitch Developers
Best Practices for Building Extensions - TwitchCon Developer Day 2017
Best Practices for Building Extensions - TwitchCon Developer Day 2017
Twitch Developers
Extensions 101: Building Interactive Experiences - TwitchCon Developer Day 2017
Extensions 101: Building Interactive Experiences - TwitchCon Developer Day 2017
Twitch Developers
OSCON Data 2011 -- NoSQL @ Netflix, Part 2
OSCON Data 2011 -- NoSQL @ Netflix, Part 2
Sid Anand
Twitch Developer Tour
Twitch Developer Tour
Twitch Developers
Addressing the scalability challenge of server sent events presentation
Addressing the scalability challenge of server sent events presentation
cdmalord
Cloud War Stories
Cloud War Stories
Richard Harvey
Embracing the Hobbyist Persona
Embracing the Hobbyist Persona
Twitch Developers
Using Insights to Build Better Products and Grow on Twitch
Using Insights to Build Better Products and Grow on Twitch
Twitch Developers
Twitch for Game Developers
Twitch for Game Developers
Twitch Developers
TwitchCon Developer Day Keynote
TwitchCon Developer Day Keynote
Twitch Developers
Twitch Extensions 101
Twitch Extensions 101
Twitch Developers
Rapid Prototyping Twitch Extensions: Five Lessons Learned
Rapid Prototyping Twitch Extensions: Five Lessons Learned
Twitch Developers
Monetize Your Extension a Bit at a Time
Monetize Your Extension a Bit at a Time
Twitch Developers
Responding to Feedback: What's New in the Twitch API
Responding to Feedback: What's New in the Twitch API
Twitch Developers
Making Your Game a Success With Twitch
Making Your Game a Success With Twitch
Twitch Developers
Get Your Extension Discovered
Get Your Extension Discovered
Twitch Developers
Bots Bots Bots: Building Chatbots
Bots Bots Bots: Building Chatbots
Twitch Developers
How Streaming is Changing the Way We Play
How Streaming is Changing the Way We Play
Twitch Developers
Twitch Insights: Player Research and Interaction
Twitch Insights: Player Research and Interaction
Twitch Developers
Twitch + Games
Twitch + Games
Twitch Developers
Using Twitch Drops to Promote Viewer Engagement
Using Twitch Drops to Promote Viewer Engagement
Twitch Developers
Twitch Extensions: Live Apps for Live Streams
Twitch Extensions: Live Apps for Live Streams
Twitch Developers
Making Twitch Interactive with Twitch Extensions
Making Twitch Interactive with Twitch Extensions
Twitch Developers
Improving Game Performance and Streaming with Twitch Insights
Improving Game Performance and Streaming with Twitch Insights
Twitch Developers
Engaging Your Community with Twitch
Engaging Your Community with Twitch
Twitch Developers
Empowering Extensions with Game APIs
Empowering Extensions with Game APIs
Twitch Developers
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2

More Related Content

More from Twitch Developers (20)

Embracing the Hobbyist Persona
Embracing the Hobbyist Persona
Twitch Developers
Using Insights to Build Better Products and Grow on Twitch
Using Insights to Build Better Products and Grow on Twitch
Twitch Developers
Twitch for Game Developers
Twitch for Game Developers
Twitch Developers
TwitchCon Developer Day Keynote
TwitchCon Developer Day Keynote
Twitch Developers
Twitch Extensions 101
Twitch Extensions 101
Twitch Developers
Rapid Prototyping Twitch Extensions: Five Lessons Learned
Rapid Prototyping Twitch Extensions: Five Lessons Learned
Twitch Developers
Monetize Your Extension a Bit at a Time
Monetize Your Extension a Bit at a Time
Twitch Developers
Responding to Feedback: What's New in the Twitch API
Responding to Feedback: What's New in the Twitch API
Twitch Developers
Making Your Game a Success With Twitch
Making Your Game a Success With Twitch
Twitch Developers
Get Your Extension Discovered
Get Your Extension Discovered
Twitch Developers
Bots Bots Bots: Building Chatbots
Bots Bots Bots: Building Chatbots
Twitch Developers
How Streaming is Changing the Way We Play
How Streaming is Changing the Way We Play
Twitch Developers
Twitch Insights: Player Research and Interaction
Twitch Insights: Player Research and Interaction
Twitch Developers
Twitch + Games
Twitch + Games
Twitch Developers
Using Twitch Drops to Promote Viewer Engagement
Using Twitch Drops to Promote Viewer Engagement
Twitch Developers
Twitch Extensions: Live Apps for Live Streams
Twitch Extensions: Live Apps for Live Streams
Twitch Developers
Making Twitch Interactive with Twitch Extensions
Making Twitch Interactive with Twitch Extensions
Twitch Developers
Improving Game Performance and Streaming with Twitch Insights
Improving Game Performance and Streaming with Twitch Insights
Twitch Developers
Engaging Your Community with Twitch
Engaging Your Community with Twitch
Twitch Developers
Empowering Extensions with Game APIs
Empowering Extensions with Game APIs
Twitch Developers
Embracing the Hobbyist Persona
Embracing the Hobbyist Persona
Twitch Developers
Using Insights to Build Better Products and Grow on Twitch
Using Insights to Build Better Products and Grow on Twitch
Twitch Developers
Twitch for Game Developers
Twitch for Game Developers
Twitch Developers
TwitchCon Developer Day Keynote
TwitchCon Developer Day Keynote
Twitch Developers
Rapid Prototyping Twitch Extensions: Five Lessons Learned
Rapid Prototyping Twitch Extensions: Five Lessons Learned
Twitch Developers
Monetize Your Extension a Bit at a Time
Monetize Your Extension a Bit at a Time
Twitch Developers
Responding to Feedback: What's New in the Twitch API
Responding to Feedback: What's New in the Twitch API
Twitch Developers
Making Your Game a Success With Twitch
Making Your Game a Success With Twitch
Twitch Developers
Get Your Extension Discovered
Get Your Extension Discovered
Twitch Developers
Bots Bots Bots: Building Chatbots
Bots Bots Bots: Building Chatbots
Twitch Developers
How Streaming is Changing the Way We Play
How Streaming is Changing the Way We Play
Twitch Developers
Twitch Insights: Player Research and Interaction
Twitch Insights: Player Research and Interaction
Twitch Developers
Using Twitch Drops to Promote Viewer Engagement
Using Twitch Drops to Promote Viewer Engagement
Twitch Developers
Twitch Extensions: Live Apps for Live Streams
Twitch Extensions: Live Apps for Live Streams
Twitch Developers
Making Twitch Interactive with Twitch Extensions
Making Twitch Interactive with Twitch Extensions
Twitch Developers
Improving Game Performance and Streaming with Twitch Insights
Improving Game Performance and Streaming with Twitch Insights
Twitch Developers
Engaging Your Community with Twitch
Engaging Your Community with Twitch
Twitch Developers
Empowering Extensions with Game APIs
Empowering Extensions with Game APIs
Twitch Developers

Recently uploaded (20)

" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
Mastering AI Workflows with FME by Mark Doring
Mastering AI Workflows with FME by Mark Doring
Safe Software
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) 際際滷s
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) 際際滷s
Ravi Tamada
The Growing Value and Application of FME & GenAI
The Growing Value and Application of FME & GenAI
Safe Software
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
Mastering AI Workflows with FME by Mark Doring
Mastering AI Workflows with FME by Mark Doring
Safe Software
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) 際際滷s
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) 際際滷s
Ravi Tamada
The Growing Value and Application of FME & GenAI
The Growing Value and Application of FME & GenAI
Safe Software
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
Ad

Extension Design Patterns for Twitch Scale

  • 1. Extensions Developer Services Team @MovingViolation Karl Patrick Senior Backend Software Engineer
  • 2. Extension Design Patterns for Twitch Scale
  • 3. TwitchCon 2018 San Jose, California @XPCagey 15 years of experience prior to Twitch Single person hobby projects to AAA titles Build/Tools/Engine/Server/Gameplay Karl Patrick Game Developer
  • 4. TwitchCon 2018 San Jose, California Extensions Usually Fail to Scale -Popular technologies dont work for high-volume channels -False starts with high-profile Extensions inspired this talk -High concurrent users is only part of the story TWITCH SCALE
  • 5. TwitchCon 2018 San Jose, California - When a streamer activates Extensions during a stream - When a channel is raided by another audience - When viewers refresh due to a technical issue Traffic Spikes 10,000x traffic in One Second WHATS THE BIG DEAL? ~20 viewers / 10 seconds 40,000 viewers / 10 seconds
  • 6. TwitchCon 2018 San Jose, California How can Extensions Scale for Traffic Bursts? TwitchCon 2018 San Jose, California Server
  • 7. TwitchCon 2018 San Jose, CaliforniaTwitchCon 2018 San Jose, California Server Twitch PubSub Call Twitch PubSub from your service to push events instead of polling for updates. If you need to whisper secrets, shout the list of people who need to ask for them instead of having every user ask. Use a Megaphone SCALING READS
  • 8. TwitchCon 2018 San Jose, California Be Lazy: Wait Before You Ask for Data - Use a splash screen when you first load your Extension - Schedule your requests after a pause - Cancel the request if it is answered while youre waiting SCALING READS Document loads Schedule request PubSub sent before timer expires? Cancel request Send request Yes No
  • 9. TwitchCon 2018 San Jose, California Roll the Dice: Randomize Your Wait Time SCALING READS - Make each client pick a number instead of using one delay - Jitter will spread out traffic if clients load at the same time Spread out work with a random delay All requests at one time
  • 10. TwitchCon 2018 San Jose, California - Tell clients how long they can wait to respond - Roll the dice on each client and cancel if the response comes while waiting - On each client request, add more wait time to the next response - Larger audiences automatically get longer waits and lower traffic per viewer Listen to Yourself: Send Wait Times From the Server SCALING READS Server Send time remaining Use time to decide when to send Add time on every request PubSub
  • 11. TwitchCon 2018 San Jose, California Green Purple Orange Blue Whats your favorite color? What About Interactive Extensions?
  • 12. TwitchCon 2018 San Jose, California - Authorize requests and use cool downs to prevent spam - Popular Extensions have seen attempts to spam within 20 minutes of release - Chrome developer tools make it simple to repeat service requests Stop Cheaters SCALING WRITES !
  • 13. TwitchCon 2018 San Jose, California - Be lazy and roll the dice to spread write traffic; listen to yourself to make sure you answer in time - Predict and apply fake responses while youre waiting - Once you have a real response, replace the fake one Start Cheating: Fake Early Responses SCALING WRITES User Clicks Schedule & Send Request Service Calculates Result PubSub Message Arrives Show Result
  • 14. TwitchCon 2018 San Jose, California Take Command: Batch Frequent Requests SCALING WRITES
  • 15. How can Extensions Scale for Traffic Bursts? - Use a Megaphone - Listen to Yourself - Be Lazy - Roll the Dice - Stop Cheaters - Start Cheating - Take Command