Friday 29 May 2020

Fastest socket.io alternative? - or ways to boost performance

Hey all,First I wanna say this is kind of a re-post, but it's been 4 years since the last post and my problem is more performance centered. So, I want to get the communities opinion on the state of things. Here is the original post in case anyone was curious.​I'm working on a project that is currently running on Socket.IO, and it has worked beautifully for my needs until now. I'm at the point where I'm running some stress tests and the framework seems to be the component failing me.​My server has a loop that handles data and calculations to push to the clients and it significantly slows down after around 50 connections with around 20 emit/second each. I recognize this is a lot to push to each client, and since I've been struggling with performance I'm rewriting some things to try and keep up with 20 emits/second but to multiple clients at once but with more data in each emit. This is nice and worth the effort regardless of performance concerns but as more clients connect and their data overlaps less performance returns to 20 emits/second per client.​I've read this kind of performance can be expected since Socket.io can be needlessly slow in my use case (it isn't a necessarily lightweight library and because of fallbacks in particular), also note: I'm running this on a pretty tiny server currently, but I'd like it to be able to run on something this lightweight even if I'll be upgrading in production.​Is there anyway I can optimize socket.io to drop some of its baggage to increase emits/second? This is also my first time really using anything ws, would some sort of stream based library be better for my case? I'm also almost exclusively publishing to rooms and namespaces as opposed to directly emitting to clients, I understand this can be wasteful and slower, but would direct emitting really be a significant performance boost? (This would be hard for me to switch to test.)​For something to be a good alternative I'll need scalibility (load balancer support, I guess) and an event emitter or namespace/room support (but both is a major plus). Also worth noting I'm pushing data from server --> client, but also a little (albeit much much less) from client --> server.What I don't need is support for is older technology and outdated browsers, they can be kept out, as well as people with strict firewalls. I also don't particularly care for reliability (my IO/s is high enough that it's okay to lose some packets from time to time). If I didn't mention it or it doesn't seem important to my use case, I probably don't need it.​My goal is to achieve at least 100 socket connections sending 20 updates per second each. With the ideal number being 500 socket connections sending 20 updates per second each.Question: Which WS (or other framework if they exist) engine can produce the largest IO/s from server-->client?TL;DR: I want to send all connected clients data 20 times a second EACH (or batches of clients). Which library has the best support for this?Thanks!

Submitted May 29, 2020 at 08:06AM by DivineActions

No comments:

Post a Comment