Does Lemmy benefit from Rust? Is code execution speed the bottleneck?
programming.dev
programming.dev
There's no way any modern language will be your bottleneck at that scale.
What I mean is, there's nothing fundamental about their tech choices that could explain such low scaling limits. It'll be either poor design/architecture, poor coding standards or both.
They were probably trucking along with various feature requests when suddenly performance became an issue this past week.
Maybe 150,000 is wrong, I saw it posted somewhere but I'm not sure what the methodology is. But between Lemmy.world and Beehaw.org we're already at 43k+ users.
27k is a gross underestimate.
-------------
EDIT:
https://kbin.social/nodeinfo/2.0
https://fedidb.org/software/lemmy
Lemmy-fediverse is claiming 159,000+ users today.
EDIT2: kbin link must have been glitched. kbin.social's specific nodeinfo is "only" claiming 35k users, which is still substantial.
Programming.dev is _NOT_ the lemmy devs. This is a discussion from https://programmers.dev, a totally separate group of people.
This is just an administrator who is sharing their Lemmy experiences while talking about Rust and such.
Lemmy.world is well into 31,500+ users on a single server and still growing strong. But growing pains have begun to creep in in any case. The server's software clearly needs a few optimization passes.
On the technical side, this https://programming.dev thread (itself, a Lemmy instance) asks how Rust may have affected Lemmy. The ongoing discussion covers a wide variety of topics.
The #1 post right now is frome snowe@programming.dev, the owner of this instance. He took disk-measurements of the server and published them, demonstrating that Lemmy's current bottleneck seems to be RAM (proven by the change in Swapping behavior / Disk-io before-and-after he upgraded RAM).
--------
I do think you can see the benefits of federation in this manner. Users from many instances: https://kbin.social, https://lemmy.world, and https://beehaw.org... and more (all different Lemmy instances) have joined in the discussion and have made a high-quality thread.
---------
Note: I am bullish on federation / Fediverse after playing around with it this past week. I'm less bullish on Lemmy itself, which has proven to be a buggy, laggy mess. Still, there's good discussion happening on Lemmy now (albeit slower due to fewer users). Communities are springing up (and will be dying), and I'm sure instances will spin up and die too. But the idea of federation works, especially for bringing together the discussion.
I think work (and play) needs to happen on Lemmy, kbin, Mastodon, and other Fediverse instances to figure out what is the best software, and best experience for users. Its not quite ready for prime-time, but the core feature set / Minimum-viable-product demo here is extremely exciting to me.
I don't wanna go into the drama / discussion here but lets just call it some nerd drama + lack of moderation tools that can solve the issue. (Beehaw.org is very confident that if Mastodon-like tools existed, they'd be able to refederate and get the things they want. The issue is being blamed right now on Lemmy's relatively new codebase that's missing some features that Mastodon users are familiar with)
https://Lemmy.world is continues to host the copies of the "old Beehaw.org" material, allowing Lemmy.world users to talk. But the "federation" has shut down, you can only talk with local users (because Beehaw.org serves as the "True copy". So upvotes / downvotes, and federated messages/comments are coordinated by the Beehaw.org server)
In practice, this means that all the Beehaw.org communities has become kinda-sorta useless on https://Lemmy.world. But, the copies of the conversations (up to the point of defederation) do exist and remain on your local (erm... more-local?) server.
* https://beehaw.org/post/598023
* https://feddit.de/post/881008
Fediverse still has a lot of work to, right now it feels more like a quick hack than something that could significantly improve the Internet in the long run. If an instance goes malicious, you have all the same problems as you'd have with an unfederated server, after all federation is completely optional in the Fediverse.
Rust seems like a sound choice in that regard because it's not garbage collected, so you're not wasting some RAM overhead just to avoid needing to do extra work, and it doesn't have C-style struct packing issues. If you don't specify the layout you need for a user defined type, Rust will assume you are OK with it re-arranging your data structure to be smaller / faster.
If you're willing to put in some work you can often go further with this in Rust than in other "systems programming" languages too. For example C++ Strings have the "Small String optimisation", exactly how this works varies but e.g libc++ (on a modern 64-bit server) String is a 24 byte data structure which can hold up to 22 bytes of textual data inline without yet needing a heap allocation. So if you do a lot of work modifying small amounts of text, Rust's built-in String isn't as efficient as a libc++ String, but the CompactString type from a popular Rust crate is also a 24 byte data structure yet it holds a more impressive 24 bytes of text before needing heap allocation.
> current bottleneck seems to be RAM
RAM exhaustion is often a secondary side effect of the true underlying bottleneck.
It could be that RAM used for temporarily processing an HTTP request, say, would be freed quicker if the database returned sooner. Maybe the database is the actual bottleneck. And the actual root cause is an indexing / partitioning issue.
1. Infrastructure
2. Architecture (not sufficiently decoupled, insufficient cache design, etc.)
3. Database/storage limitations
...
...
99. RustYou will see the request being sent as a websocket. The lemmy author implemented lemmy so as to see how fast you can get the site working. Inferno, Rust, WebSockets. He probably didnt have expect the scaling issues that come with it.
Anyways, I am happy the site exists. Kudos! Looking towards better implementation in the next release
https://www.techempower.com/benchmarks/
Rust is by far, better than anything else out there.
Django is at 3,2%. Spring at 20%. PHP at 20%. Rust at 99%. JavaScript is at 100% but they're cheating.
See "multiple queries" tab.
EDIT: As an example, right now in Mastodon federation traffic is handled by sidekiq queues running Ruby. Someone makes a post -> tasks to send that information to all their followers instances get queued, which then send individual HTTP requests to all those instances. This to me feels like something that could be moved into some smaller and more-efficiently-written component that batches requests, makes sure to reuse connections, ... at least for paths that see a lot of traffic.
The usual solution for this set of problems is connection and/or request aggregation via a proxy layer. Relays (in fediverse-speak) do exist, but seem very lightly used and do little or no caching because ActivityPub relies heavily on POST (which IMO was probably a bad decision). Any caching that's done has to be ActivityPub-specific. I wrote about this a while ago and almost certainly got some stuff wrong, but it might be interesting nonetheless. At least it drew some interesting comments at the time.
https://gist.github.com/jdarcy/60107fe4e653819138396257df302...