SlideShare ist ein Scribd-Unternehmen logo
1 von 67
How hard can it be?
How hard can it be?
REALTIME
• Authentication
• Slowmode
• Moderator
• Admins
• Subscribers
• Timeout
• Ban
• Limits per user
• Notify messages
• Imagelog
• Unlimited Rooms
Not that easy!
• IP-Ban
• Raffle
• Voting
• Whisper
• Blacklist
• Block user
• Posting Images
• DDOS Protection
• Limits per channel
• Chatlog
• System messages
10 ≠ 100000
Images
100Mb GIFs...
Logfiles!
50k in a channel...
DDOS!
Get Image
Check
Image
Save on
CDN
Get Image
Check
Image
Adult
Check
Save on
CDN
• Click limits
• Spamming
• Load balancing
• Limits for frontend
• Authentication
• Extendable
Not that easy!
• Bots
• Statistics
• Main KPI for streams
• Advertisement
Not that easy!
1st Version
WebSocket Load
balancing
Permission and
security model
(Admin, Mods, ...)
Frontend Server Backend Server
UI
Frontend
Server
data storage
Redis
Cluster
Smashcast
REST-API
Backend
Server
Auto scaling
Auto scaling
Long Polling Fallback
Fallback
Server
• Small, cheap machines
• Frontend handles the connections, no logic
• Backend stateless, can be restarted/upgraded any time
• When a frontend breaks it affects only for a few user
• Socket.io for handling websockets
• Up & Downscale as needed
Servers
Let‘s do this again for
all other services!
2nd Version
• Easy to use
• Good performance
• Easy to cluster
• Great web-interface for monitoring
• Proven stability
RabbitMQ
Server
Structure
Load
balancing
Frontend
Server
Chat
Service
Auto scaling
RabbitMQ
Cluster
Cheering
Service
Feed
Service
Viewcount
Service
Auto scaling
What‘s Happening
JoinChannel
JoinChannel
OK
Send & Receive
Data
Generic Services
• Some services don’t need a login
• There is always the need for schedule things
• Services need to send & get information from and to the
API
• What happen when a frontend server dies?
Examples
Load
balancing
Frontend
Server
Chat
Service
Auto scaling
RabbitMQ
Cluster
Cheering
Service
Feed
Service
Viewcount
Service
Auto scaling
Login
Service
Cron
Service
API
Service
Cleanup
Service
Routed to
cheering
service
Cheering
service
updates
Redis, etc.
Stores msg in
cron service
to get sent
back in the
future
Cron service
sends back to
cheering
service
User clicks
cheering icon
Cheering
service
collects data
and sends it
Routed to
channel
User gets
update
Microservice Library
Demo
Is it Working?
Future
• Split chat into smaller services
• A lot of new services
• Open up infrastructure for 3rd party services
• ???
Future
Thank you!
max@smashcast.tv
We are hiring!
„Self“ DDOS
Communication Flow

Weitere ähnliche Inhalte

Was ist angesagt?

LinkedIn Mobile: How do we do it?
LinkedIn Mobile: How do we do it?LinkedIn Mobile: How do we do it?
LinkedIn Mobile: How do we do it?phegaro
 
«How to start in web application penetration testing» by Maxim Dzhalamaga
«How to start in web application penetration testing» by Maxim Dzhalamaga «How to start in web application penetration testing» by Maxim Dzhalamaga
«How to start in web application penetration testing» by Maxim Dzhalamaga 0xdec0de
 
Dmitry Soshnikov, Ymc universal apps
Dmitry Soshnikov, Ymc universal appsDmitry Soshnikov, Ymc universal apps
Dmitry Soshnikov, Ymc universal appsYandex
 
Buzzr Multi-Site Hosted CMS
Buzzr Multi-Site Hosted CMSBuzzr Multi-Site Hosted CMS
Buzzr Multi-Site Hosted CMSEd Sussman
 

Was ist angesagt? (9)

Kentico CMS
Kentico CMSKentico CMS
Kentico CMS
 
LinkedIn Mobile: How do we do it?
LinkedIn Mobile: How do we do it?LinkedIn Mobile: How do we do it?
LinkedIn Mobile: How do we do it?
 
«How to start in web application penetration testing» by Maxim Dzhalamaga
«How to start in web application penetration testing» by Maxim Dzhalamaga «How to start in web application penetration testing» by Maxim Dzhalamaga
«How to start in web application penetration testing» by Maxim Dzhalamaga
 
Signal rity1
Signal rity1Signal rity1
Signal rity1
 
Express yourself
Express yourselfExpress yourself
Express yourself
 
Dmitry Soshnikov, Ymc universal apps
Dmitry Soshnikov, Ymc universal appsDmitry Soshnikov, Ymc universal apps
Dmitry Soshnikov, Ymc universal apps
 
Node ts1
Node ts1Node ts1
Node ts1
 
Buzzr Multi-Site Hosted CMS
Buzzr Multi-Site Hosted CMSBuzzr Multi-Site Hosted CMS
Buzzr Multi-Site Hosted CMS
 
Javascript for Wep Apps
Javascript for Wep AppsJavascript for Wep Apps
Javascript for Wep Apps
 

Ähnlich wie How hard can it be

Chirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterChirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterJohn Adams
 
BGF 2012 (Browsergames Forum)
BGF 2012 (Browsergames Forum)BGF 2012 (Browsergames Forum)
BGF 2012 (Browsergames Forum)Christof Wegmann
 
Sm west 2010-microsoft-workshop
Sm west 2010-microsoft-workshopSm west 2010-microsoft-workshop
Sm west 2010-microsoft-workshopPrashant Ohal
 
Cloud and Windows Azure
Cloud and Windows AzureCloud and Windows Azure
Cloud and Windows AzureRadu Vunvulea
 
Building Lightning Fast Websites (for Twin Cities .NET User Group)
Building Lightning Fast Websites (for Twin Cities .NET User Group)Building Lightning Fast Websites (for Twin Cities .NET User Group)
Building Lightning Fast Websites (for Twin Cities .NET User Group)strommen
 
Massively Social != Massively Multiplayer
Massively Social != Massively MultiplayerMassively Social != Massively Multiplayer
Massively Social != Massively MultiplayerPaul Furio
 
John adams talk cloudy
John adams   talk cloudyJohn adams   talk cloudy
John adams talk cloudyJohn Adams
 
Introduction to Web Security
Introduction to Web SecurityIntroduction to Web Security
Introduction to Web SecurityKamil Lelonek
 
Show Me the Numbers: Automated Browser
Show Me the Numbers: Automated Browser Show Me the Numbers: Automated Browser
Show Me the Numbers: Automated Browser colleenfry
 
External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) Volkan Özçelik
 
Christian Corsano (Io-Interactive) - Hitman – the first episodic AAA game and...
Christian Corsano (Io-Interactive) - Hitman – the first episodic AAA game and...Christian Corsano (Io-Interactive) - Hitman – the first episodic AAA game and...
Christian Corsano (Io-Interactive) - Hitman – the first episodic AAA game and...DevGAMM Conference
 
The Core of Microservice Architecture(First Approach)
The Core of Microservice Architecture(First Approach)The Core of Microservice Architecture(First Approach)
The Core of Microservice Architecture(First Approach)enyert
 
Architecture evolution
Architecture evolutionArchitecture evolution
Architecture evolutionamit bezalel
 
From Local to Global
From Local to Global From Local to Global
From Local to Global AWS Germany
 
Hacklu2011 tricaud
Hacklu2011 tricaudHacklu2011 tricaud
Hacklu2011 tricaudstricaud
 
Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Volkan Özçelik
 
External JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesExternal JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesVolkan Özçelik
 
Nokta techpresentation
Nokta techpresentationNokta techpresentation
Nokta techpresentationAnkaraCloud
 
브라우저에 날개를 달자
브라우저에 날개를 달자브라우저에 날개를 달자
브라우저에 날개를 달자NAVER SHOPPING
 

Ähnlich wie How hard can it be (20)

Chirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterChirp 2010: Scaling Twitter
Chirp 2010: Scaling Twitter
 
BGF 2012 (Browsergames Forum)
BGF 2012 (Browsergames Forum)BGF 2012 (Browsergames Forum)
BGF 2012 (Browsergames Forum)
 
Sm west 2010-microsoft-workshop
Sm west 2010-microsoft-workshopSm west 2010-microsoft-workshop
Sm west 2010-microsoft-workshop
 
Cloud and Windows Azure
Cloud and Windows AzureCloud and Windows Azure
Cloud and Windows Azure
 
Building Lightning Fast Websites (for Twin Cities .NET User Group)
Building Lightning Fast Websites (for Twin Cities .NET User Group)Building Lightning Fast Websites (for Twin Cities .NET User Group)
Building Lightning Fast Websites (for Twin Cities .NET User Group)
 
Massively Social != Massively Multiplayer
Massively Social != Massively MultiplayerMassively Social != Massively Multiplayer
Massively Social != Massively Multiplayer
 
John adams talk cloudy
John adams   talk cloudyJohn adams   talk cloudy
John adams talk cloudy
 
Introduction to Web Security
Introduction to Web SecurityIntroduction to Web Security
Introduction to Web Security
 
Show Me the Numbers: Automated Browser
Show Me the Numbers: Automated Browser Show Me the Numbers: Automated Browser
Show Me the Numbers: Automated Browser
 
External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1) External JavaScript Widget Development Best Practices (updated) (v.1.1)
External JavaScript Widget Development Best Practices (updated) (v.1.1)
 
Distributed "Web Scale" Systems
Distributed "Web Scale" SystemsDistributed "Web Scale" Systems
Distributed "Web Scale" Systems
 
Christian Corsano (Io-Interactive) - Hitman – the first episodic AAA game and...
Christian Corsano (Io-Interactive) - Hitman – the first episodic AAA game and...Christian Corsano (Io-Interactive) - Hitman – the first episodic AAA game and...
Christian Corsano (Io-Interactive) - Hitman – the first episodic AAA game and...
 
The Core of Microservice Architecture(First Approach)
The Core of Microservice Architecture(First Approach)The Core of Microservice Architecture(First Approach)
The Core of Microservice Architecture(First Approach)
 
Architecture evolution
Architecture evolutionArchitecture evolution
Architecture evolution
 
From Local to Global
From Local to Global From Local to Global
From Local to Global
 
Hacklu2011 tricaud
Hacklu2011 tricaudHacklu2011 tricaud
Hacklu2011 tricaud
 
Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012Java scriptwidgetdevelopmentjstanbul2012
Java scriptwidgetdevelopmentjstanbul2012
 
External JavaScript Widget Development Best Practices
External JavaScript Widget Development Best PracticesExternal JavaScript Widget Development Best Practices
External JavaScript Widget Development Best Practices
 
Nokta techpresentation
Nokta techpresentationNokta techpresentation
Nokta techpresentation
 
브라우저에 날개를 달자
브라우저에 날개를 달자브라우저에 날개를 달자
브라우저에 날개를 달자
 

Kürzlich hochgeladen

Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 

Kürzlich hochgeladen (20)

Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 

How hard can it be

Hinweis der Redaktion

  1. So, how hard can it be?
  2. Thats me, 1980/81 with my first computer, anyone know the computer? I have studed arts, lived in new york & berlin, have made startups and have crashed startups
  3. Smashcast, was until April Hitbox, but Hitbox got bought by Azubu, a competitor and now we are Smashcast
  4. What is Smashcast? This is the frontpage
  5. And thats a stream page, you see the live stream, chat, etc.
  6. Real time is important. When something happens on the stream viewers wants to react as fast as possible. Thats why we have build a real time infrastructure based on websockets. Now a few explanations of the elelemts on the site that use this infrastructure.
  7. The chat, ca do everything a chat needs to do, including posting images, gifs, selfies, etc.
  8. Sounds easy, but isnt when you want to scale it!
  9. And there is a big difference between a small whatsapp group and a huge real time chat!!!
  10. Take for example images in chat, sounds easy! Look at the person in the top left corner 
  11. Just link to the source and you are done! We had this for two years…. Until we realized: there is a problem!
  12. For example: someone posts a 100+mb gif, then alle viewers will start to download it and, when there internet is slow, dont forget, there is a 3Mbit stream running next to the chat, the stream will lag, giving a bad user experience! But there are bigger problems with this images in the chat!
  13. Imagine you hate one of the smaller streamer (like 5-20 viewers) on smashcast. You set up a small server with a nice gif on it and you post this gif, when the streamer is live, in his chat. And now you have the IP-address of all his viewers and the IP of the streamer in your log files! So next step is
  14. Googling DDOS and bring down this streamer you hate! So easy! But there is even a third problem!
  15. Imagine a stream has 50k viewers and someone posts a gif. The server where the gif is hosted must be strong, because he will get now 50k hits at the same time!
  16. Ist like a DDOS…
  17. So we need to get the image, check it and save it in the CDN
  18. And we are testing AWS machine learning for porn detection
  19. Back to the realtime features. Cheering is another on on the site. It allows people to cheer for a team or a stream.
  20. Lot of things to do! And thats just the beginning! Again, here you run quite fast into problems with too many messages you send to the users, etc.
  21. Another feature on the site is the feed below the stream. All viewers get updates via the websocket
  22. Last but not least the viewcounter.
  23. Thats this number here. Maybe the most important thing on the site
  24. So this number is the main KPI for all streams, the bigger the better so a lot of people try to influence this number. Updates are send out in realtime or every 10 seconds (depending on how big the stream is) to all viewers.
  25. So, lets explain how we started it the realtime system a few years ago, the famous first version.
  26. We went with nodejs & redis, redis because it is a great product for storing data that you need fast. When we have a lot of users the redis servers make thousends of requests/seconds without any problems and AWS offers a very good managed version of redis. Nodejs because of its fast io for this, nowadays i would maybe move to go.
  27. So we went with a typical frontend/backend setup, the frontend handles the websocket connection and is quite dump, the backend all the chat logic. Fallback server is for the less than 1% that don’t support websockets, some providers block them and some older android versions too
  28. We use AWS Single core machines This 1st version worked fine, but the problem is:
  29. So we had a similar infrastructure for the viewcounter and when we worked on cheering & the feed we would have to build a similar infrastructure for this too. So we need a different approach
  30. Sounds easy, or? Exists since 30 years.
  31. Thats when we decided to use rabbitmq. We could have used Kafka too but i have quite some experience with rabbitmq and it fits perfect. Anyone using it too?
  32. As i said, it is easy to use, easy to mantain, and the best thing is the web interface, i will show it to you later.
  33. So, how does the new server structure looks like? This is Mike Pence, Vice President of the USA while visiting NASA….
  34. We still have the frontend server (with fallback, of course) and in between the rabbitmq cluster, which distribute the messages to the services and then back to the frontend.
  35. So how does this work now? How is a command from the frontend send to the backend, processed and back to the frontend?
  36. First, you need to login into every service. Ok, this flow is not that complicated, but wait for it! 
  37. This is a login message the userinterface sends to the frontend server he is connected to. In this case he wants to login (joinchannel) to the chat service for the channel „karlus“. The frontend server is then sending this message to the rabbitmq-cluster
  38. In rabbitmq there are two exchanges defined: fromFrontend & toFrontend. The frontendserver are connected to both, on one they are listening and on the other they are sending messages. So this message is send to the fromfrontend exchange because it is from the frontend server.
  39. Here you can see this. The frontend server sets the routing and the routing key is chat.joinchannel.karlus because it is a joinchannel command for the chat service for the channel karlus
  40. The fromFrontend exchange routes now all messages where the routing key starts with chat. To the chat queue.
  41. The chat backend servers (in this case two servers) are connected to this chat queue and rabbitmq is distributing the messages via round robin to the chat backend servers. This is how the backend servers than get their messages. They have no clue that the message is coming from a frontend server, could come from other services, etc.
  42. The chat backend servers then process the message, in this case do the login, etc. and then send back a message to rabbitmq to the „toFrontend“ exchange.
  43. Each frontend server has his own queue that is connected directly to the „tofrontend“ exchange. With this setup it is possible for the backend to send a message directly to one frontend server (for example, the loginmsg, because this is only for one user) or to all frontend servers (for example, a chat msg).
  44. After processing the message the backend server sends ther message back to rabbitmq. For a normal chat message this would be like this, again, the routin gkey is the service, command & channel.
  45. The loginmsg is a bit different because it is send directly to the frontend server that send the message because the other frontend servers dont need to see it, so there is no routing key, only the queue is specified where it is send to.
  46. And this is how this looks in the user interface? Green are the messages from the user interface, white the messages from the frontend server.
  47. Here you see the login msg we just saw
  48. And here the message coming back from the chat backend server.
  49. When we build this system we realized that we need some generic services that can be used by other services.
  50. For example some services dont need a login A cronjob is needed for example for the cheering service to send status updates back to the viewers or for the viewcount server. The connection to & from the API is based on a service, so other services can send a message to a service and this will then interact with the REST API. The cleanup service is there to log out viewers from other services when a frontend server goes down.
  51. So we added this needed services to the same rabbitmq cluster
  52. Some services are really simple, this is the main function for the login service for example.
  53. This can lead to quite complicated flows.
  54. To handle this we have our own library that we use to connect & use with rabbitmq
  55. https://ec2-52-3-222-66.compute-1.amazonaws.com/#/ https://rabbitmq/#/
  56. Well, and at the end, is the chat system working? Does it scale?
  57. Well, i dont have a screenshot about our latest record that was close to 200k, but this one shows you a channel with 100k people. All 154k connections where handled by 16 frontend servers and 8 backend servers, costing us around $20 for the evening.
  58. Well, and at the end, is the chat system working? Does it scale?
  59. As i said, it is easy to use, easy to mantain, and the best thing is the web interface, i will show it to you later.
  60. Just one mor think:
  61. Just one mor think:
  62. Just one mor think:
  63. It was during at that time biggest event ever, 60k people on one stream and suddenly all of them saw this.
  64. And we did this!
  65. I know, this sound s stupid, but i will give you two examples: Imagine you have a stream with 100k viewers. Every time a new viewer comes to this stream he/she gets the info about how to get the stream from our server. Now imagine the streamer has a problem, lets say his computer crashes and the stream drops, mean is getting black or stucked. What does 100k people do?
  66. This. And lets hope that your api can handle this! And they wont stop until trhe have a stream again!
  67. Sounds easy, or? Exists since 30 years.