Тёмный

How to scale WebSockets to millions of connections 

Ably Realtime
Подписаться 1,9 тыс.
Просмотров 19 тыс.
50% 1

WebSockets are hard to scale, it's true. The stateful connection that makes them so powerful for two-way realtime communication also makes them tricky to load balance efficiently, but that isn't to say it can't be done. In this video, Alex Booker (@bookercodes) from Ably runs you through the technical challenges scaling WebSockets before outlining the patterns used to scale WebSockets to thousands of concurrent connections and beyond. Theoretically, the approach to system design outlined in this video can scale to millions of concurrent WebSocket connections in a production environment.
ABOUT ABLY 👋
Ably is an enterprise-grade pub/sub messaging platform. We make it easy to efficiently design, quickly ship, and seamlessly scale critical realtime functionality delivered directly to end-users. Every day, we deliver billions of realtime messages to millions of users for thousands of companies.
TIMESTAMPS ⏰
00:00 Introduction
00:16 Why WebSockets are hard to scale
01:33 Why WebSocket benchmarks are misleading
03:03 Options for scaling WebSockets
03:32 Introduction to vertical scaling
04:14 Challenges with vertical scaling WebSockets
06:30 Horizontal scaling
07:40 Horizontal scaling continued
09:55 Challenges with horizontal scaling WebSockets
11:38 Conclusion
LINKS MENTIONED 🔗
- The WebSocket hand book (free WebSocket book): hubs.la/Q01ZQm6Z0
- Guide to HTTP long polling: hubs.la/Q01ZQnM20

Опубликовано:

 

9 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 45   
@haritpatel5001
@haritpatel5001 3 дня назад
Very insightful video indeed, great work.
@SumitGouthaman
@SumitGouthaman 3 месяца назад
Surprisingly this is one of the only videos I found that actually goes into specifics of this topic. 👍 All other videos and docs are kind handy-wavy.
@bunkerdm6303
@bunkerdm6303 8 месяцев назад
Thanks to you, I have a broader understanding of websockets. I really want to see a video about horizontal scaling. Thank you.
@AblyRealtime
@AblyRealtime 8 месяцев назад
Glad to hear you liked the video, thanks for taking the time to comment and we'll keep that in mind :D
@reyariass
@reyariass Месяц назад
I had this exact question and I KNEW (felt it in my bones) that the answer wouldn’t be so simple as having just saying “yeah Only like 100”, thanks for the insight!
@dylanoh3425
@dylanoh3425 8 месяцев назад
Super high quality content 🎉
@AmmariMedAziz
@AmmariMedAziz 4 месяца назад
High quality content! Looking for a real-life tutorial on horizontally scaling web sockets
@oleksandrsova4803
@oleksandrsova4803 7 месяцев назад
Probably, when people ask how many WS connections can a server have - they actually mean "What is the limit of WS/other connections on LB, and what does it depend on? Is it the number of opened file descriptors? Amount of RAM? Anything else?"
@AblyRealtime
@AblyRealtime 7 месяцев назад
All very good questions, thanks for sharing! Perhaps for a future video👍🏻
@JackLerouge76
@JackLerouge76 10 месяцев назад
Nice one. Thanks
@AblyRealtime
@AblyRealtime 10 месяцев назад
We're glad you enjoyed it
@latavish
@latavish 2 месяца назад
I'm currently developing an app that highly uses websockets and you have really given me a few insights to think about. Thank you so much for this valuable info 😊
@AblyRealtime
@AblyRealtime 2 месяца назад
Great to hear that and thanks for commenting. Are you going to build your own horizontally scaling WebSocket feature?
@ovna
@ovna 3 дня назад
Ty
@tzuriteshuba2704
@tzuriteshuba2704 3 месяца назад
If all your servers use a shared redis instance to communicate with each other, don't we just reintroduce the original problem of a single server handling all the load (defeating the purpose of the load balancer)? I see that it still helps, since non-websocket work is still distributed, but at scale, I dont see how anything is solved. Especially for apps like chat apps where the websockets carry a lot of the work. Great video though!
@bookercodes
@bookercodes Месяц назад
You’re spot-on, except Redis is well-suited for clustering compared to your own WebSocket server.
@nomadrider7200
@nomadrider7200 9 месяцев назад
I guess using kafka or rabbit MQ to distribute the load coming from the business logic along with horizontal scaling can further help you achieve more scalability. Great content really enjoyed it
@AblyRealtime
@AblyRealtime 9 месяцев назад
Thanks for the kind words, glad you liked it! Let us know if there's any other topics you'd like to see next.
@nomadrider7200
@nomadrider7200 9 месяцев назад
@@AblyRealtime Load testing using artillery will be a great topic where you not only emit events to server in a loop but also listen to the server sent events at the client side i.e, artillery
@user-ss6yc2kg4y
@user-ss6yc2kg4y 7 месяцев назад
Could you please explain how you would do that ? I guess we could have a chat service that create websocket connections, and subscribe/ push to redis. New messages would be pushed to kafka. We would have another service subscribing to kafka queues dedicated to handling messages, saving them to DB and then publishing to redis Then the chat service receives this message and sends it via ws. What do you think ?
@SiLintDeath
@SiLintDeath 4 месяца назад
Hmm our system process was: ws => Kafka message => consumer to write message to redis and db for recovery. Another Kafka listener that would also send message to ws by looking at redis to find where client was to send back to client.
@anuragbisht1200
@anuragbisht1200 21 день назад
redis can do pub-sub and can be a DB too.
@verified_tinker1818
@verified_tinker1818 6 месяцев назад
The Elixir web framework, Phoenix, solves pretty much all of these problems. The BEAM VM was basically built for this.
@R0hanThakur
@R0hanThakur 2 месяца назад
Amazing video....thanks But you still did not answer the question. How many active websocket connections can a an avg ec2 server hold... or please give a rough ball park estimate range .... This info can be used to decide how many servers we need right ?
@user-mn5vp3cr8n
@user-mn5vp3cr8n 6 месяцев назад
I have 3 instances with LB and kafka, when i send the request to kafka server return 200, but on front-end we need to send the response probably via web-socket and this event can be processed on another server. So how front-end can know to which server need to subscribe to socket if we are using LB?
@AblyRealtime
@AblyRealtime 6 месяцев назад
In a typical setup with a load balancer, you wouldn’t communicate directly with individual server instances from the frontend. Rather, you would communicate with the LB, which would handle redirecting your requests to the appropriate instances - Alex
@anuragbisht1200
@anuragbisht1200 21 день назад
thanks for the nice video. Could you share your thoughts of choosing redis over other Dbs and would you like to persist the state data to disk ?
@AblyRealtime
@AblyRealtime 10 дней назад
Hey there! Redis is used in this situation more as a cache, optimised brokering the messages with ultra low latency. The classic design to persist messages longterm is to have an additional relational DB as a layer after Redis (to the right in the diagram)
@taki9789
@taki9789 24 дня назад
Thank you for helpful video! I have a question regarding horizontal scaling websicket implementation. Is it possible to create a lookup table that maps roomId, which is often used in chat applications, and server id so that users having the same roomId are navigated to connect to the same server when load balancing?
@AblyRealtime
@AblyRealtime 10 дней назад
Yes, this would be a recommended design pattern, and has increased security benefits over navigating rooms and servers using naming patterns. Thanks for your question!
@taki9789
@taki9789 10 дней назад
@@AblyRealtime I appreciate your reply!
@aymanimtyaz8529
@aymanimtyaz8529 Месяц назад
Could you elaborate a bit on how the Redis based approach works when scaling out?
@AblyRealtime
@AblyRealtime 25 дней назад
You have to set-up a way to provision and shed Redis instances to match scaling demands. Some use-cases will demand a Kubernetes type service to manage the instances, and others a more homegrown solution.
@zhonglin5985
@zhonglin5985 3 месяца назад
I think this video would be much more valuable if you could talk more details about how the horizontally scaled system works for a chat app. Everybody knows horizontal scaling is the way to go.
@AblyRealtime
@AblyRealtime 3 месяца назад
Thanks for your feedback! If you're interested, this is certainly the kind of content we'll consider delving deeper into in the future.
@GuildOfCalamity
@GuildOfCalamity 5 месяцев назад
I think you should run a test with a single mid-tier server and see where the average limit of WS connections would be.
@AblyRealtime
@AblyRealtime 5 месяцев назад
Thanks for the suggestion! We'll keep this in mind for future videos.
@namjitharavind
@namjitharavind 2 месяца назад
Why cant we use redis instead of websocket?
@AblyRealtime
@AblyRealtime 2 месяца назад
Alex from the video here 👋🏻 That is a good question. WebSockets are a realtime communication protocol that provides a full-duplex communication channel between client and server over a long-lived connection, meanwhile Redis is an in-memory data structure store. Sometimes confusion can arise because Redis does support pub/sub, but that mechanism is primarily designed to handle communication between your app/services and Redis. It's not suitable for realtime interaction between your server and clients (end-users). For example, you'd be hard-pressed to connect to Redis from a browser in a a sensible way but that's exactly what Websockets are designed for.
@namjitharavind
@namjitharavind 2 месяца назад
@@AblyRealtime Thank you for the reply. Websocket for the realtime experience.
@emaayan
@emaayan 13 дней назад
what if your users are actually devices which need always be connected.
@AblyRealtime
@AblyRealtime 10 дней назад
This is often not possible with phones or tablets due to constraints from Apple and Android with apps not allowing background WebSocket connections. It is not even possible to send REST https requests to apps running in the background. The only way around is to send a push notification. If the app is running in the foreground indefinitely, the socket connection can stay open.
Далее
How to use WebSockets with React and Node
1:11:51
Просмотров 19 тыс.
Китайка и Шашлычок😂😆
00:19
Просмотров 236 тыс.
МОЯ НОВАЯ МАШИНА🤍КАК ВАМ?😍
01:01
What does larger scale software development look like?
24:15
Why WebSockets Are NOT Scalable | WebSockets Explained
12:07
Webhook vs Websocket
2:56
Просмотров 3 тыс.
Scaling your Node.js app using the "cluster" module
13:44
System Design: Why is Kafka fast?
5:02
Просмотров 1 млн