this post was submitted on 15 Jun 2023
189 points (93.5% liked)
Programming
17313 readers
35 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities [email protected]
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Pulling this out of my ass, but I think the problem might be in Lemmy using websockets.
I feel like supporting 1500 simultaneous users making a request every 10-20 seconds is easier than keeping 1500 websockets alive.
Irregardless, Lemmy does feel very snappy compared to other websites I've had the displeasure of using. Main problem is low robustness in the RPC layer.
I maintain and host ntfy.sh, an open source push notification service. I have a constant 9-12k WebSocket and HTTP stream connections going, and I host it on a two core machine with an average load average of less than 1. So I can happily tell you that it's not WebSockets. Hehe.
My money would be on the federation. Having to blast/copy every single comment to every single connected instance seems like a lot.
As far as I know, every server connects to every other server. Allowing for proxying messages through servers would significantly help.
I agree.
Random ideas:
The Kademlia protocol (a DHT) has a thing that associates ownership of data to the 20 closest nodes in a P2P network. If an approach like this were used, the load would be spread across those 20 nodes. I implemented that like 15 years ago or so. It was a ton of fun.
Another, simpler approach is what you suggested, simple caching of and relaying through other nodes, though that does not answer the topology of the network. How would an instance decide where to get it's data from (a star, a tree, at random, ...)? How would it be authenticated (easy to solve)? Lots of fun problems to solve. Not fun problems though if you have a pile of other problems too though...
I thought of it like this:
If an instance misbehaves by not relaying messages despite claiming to be doing so - unfriend it.
Each instance publishes a public key that you can use to verify relayed messages.
I probably should get on to helping out developing Lemmy - it feels like there's RFC's to be written and interesting problems to be solved. Much more interesting than what I'm doing at work.
They're gonna move away from we sockets within a couple of weeks, from what I hear
That's a good move IMHO. Honestly I don't want my UI to randomly shift down when new messages come in from syncing with another instance.
The right move would be to make a page that renders once and then only updates when you refresh the page. And then use web push for message notifications.
Wait — it uses websockets for each and every user??! That’s just completely insane and of course it will fail to scale! There is zero reason for that, have specific live threads with websockets where it makes sense (though that is only mostly a one-way communication so even there it is an overkill), but for mostly static content it is just insanely inefficient.. surely I’m more than fine with that upvote appearing a minute later and not in “real time”!
As I said - I'm pulling this out of my ass. Browser debugging tools don't support websockets well, but looking at the network log, it seems to start a websocket for every tab.