785 points · by cyndunlop · 1y ago · 304 comments
When you have a celebrity account, instead of fanning out every message to millions of followers' timelines, it would be cheaper to do nothing when the celebrity posts, and later when serving each follower's timeline, fetch the celebrity's posts and merge them into the timeline. When millions of followers do that, it will be cheap read-only fetch from a hot cache.
off-topic: how has been dealing with the influx of new users after X political/legals problems aftermath? Did you see an increase in toxicity around the network? And how has you (Bluesky moderation) dealing with it.
[1] - https://www.themarysue.com/twitter-justin-bieber-servers/
@bluesky devs, don't feel ashamed for doing this. It's exactly how to scale these kinds of extreme cases.
So now we have Slashdot effect, HN hug, and its not Clarkson its... Stephen Fry effect? Maybe can be Cross-Discipline - there's a term for when lots of UK turns their kettles on at the same time.
I should make a blog post to record all the ones I can remember.
Hot shards were definitely an issue, though.
Thanks a lot for sharing this link.
I own DDIA but after a few chapters of how database work behind the scenes, I begin to fall asleep. I have trouble understanding how to apply the knowledge to my work but this seems like a useful thing with a more clear application.
I think then you still have the 'weird user who follows hundreds of thousands of people' problem, just at read time instead of write time. It's unclear that this is _better_, though, yeah, caching might help. But if you follow every celeb on Bluesky (and I guarantee you this user exists) you'd be looking at fetching and merging _thousands_ of timelines (again, I suppose you could just throw up your hands and say "not doing that", and just skip most or all of the celebs for problem users).
Given the nature of the service, making read predictably cheap and writes potentially expensive (which seems to be the way they've gone) seems like a defensible practice.
Random sampling? It's not as though the user needs thousands of posts returned for a single fetch. Scrolling down and seeing some stuff that's not in chronological order seems like an acceptable tradeoff.
Instead, you can drastically speed up performance if you are able to store data for each timeline somewhat contiguously on disk.
(Although I don't understand the "non-celebrity" part of your comment -- the timeline contains (pointers to) posts from whoever someone follows, and doesn't care who those people are.)
In the Blekko search engine back end we built an index that was 'eventually consistent' which allowed updates to the index to be propagated to the user facing index more quickly, at the expense that two users doing the exact same query would get slightly different results. If they kept doing those same queries they would eventually get the exact same results.
Systems like this bring in a lot of control systems theory because they have the potential to oscillate if there is positive feedback (and in search engines that positive feedback comes from the ranker which is looking at which link you clicked and giving it a higher weight) and it is important that they not go crazy. Some of the most interesting, and most subtle, algorithm work was done keeping that system "critically damped" so that it would converge quickly.
Reading this description of how user's timelines are sharded and the same sorts of feedback loops (in this case 'likes' or 'reposts') sounds like a pretty interesting problem space to explore.
Like I click one page, don’t find what I want, and go back thinking “no, I want that other result that was below” and it’s an entirely different page with shuffled results, missing the one that I think might have been good.
On top of that immediate frustration, the YouTube style interface here
https://marvelpresentssalo.com/wp-content/uploads/2015/09/id...
collects terrible data for recommendations because, even though it gives them information that you liked the thumbnail for a video, they can't come to any conclusion about whether or not you liked any of the other videos. TikTok, by focusing on one video at a time, collects much better information.
or add it to the "Watch Later" playlist :) so you can watch it...later.
I've found a workaround, though – click back into the DDG search box at the top of the page and hit enter. This then returns the original search results.
Looking back at my early work with microservices I'm wondering how much time I would have saved by just manually setting a tongue weight.
I like your example it is very interesting. If I get to work on (or even hear someone in my team is working on) such interesting problems and I can hear about it, I get happy.
Interesting problems are rare because like a house you might talk about brick vs. Timber frame once, but you'll talk about cleaning the house every week!
— https://en.wikipedia.org/wiki/Blekko
Perhaps GP has a more interesting answer though.
There are other ways to monetize search (look at Kagi for example) than advertising. Blekko missed that window though. (too early, Google needed to get a crappy as it is today to make the value of a spam free search engine desirable)
Let's imagine something like this: instead of writing to every user's timeline, it is written once for each shard containing at least one follower. This caps the fan-out at write time to hundreds of shards. At read time, getting the content for a given users reads that hot slice and filters actual followers. It definitely has more load but
- the read is still colocated inside the shard, so latency remains low
- for mega-followers the page will not see older entries anyway
There are of course other considerations, but I'm curious about what the load for something like that would look like (and I don't have the data nor infrastructure to test it)
The lossy timeline solution basically means you skip updating the feed for some people who are above the number of reasonable followers. I get that
Seeing them get 96% improvements is insane, does that mean they have a ton of users following an unreasonable number of people or do they just have a very low number for reasonable followers. I doubt it's the latter since that would mean a lot of people would be missing updates.
How is it possible to get such massive improvements when you're only skipping a presumably small % of people per new post?
EDIT: nvm, I rethought about it, the issue is that a single user with millions of follows will constantly be written to which will slow down the fanout service when a celebrity makes a post since you're going through many db pages.
> Seeing them get 96% improvements is insane
TFA is talking about P99 tail latencies. It does not sound too insane to reduce tail latencies by extraordinary margins. Remember, it's just reshaping of latency distribution. In this case pathological cases get dropped.
Look at the accounts of OnlyFans models, crypto influencers, etc. They follow thousands or even tens of thousands of accounts in the hope that we will follow them in return.
Can you think of a use case?
All sorts of bots want this sort of access, but whether there are legitimate reasons to grant it to them on a non-sharded basis is another question since a lot of these queries do not scale resources with O(n) even on a centralized server architecture.
Bluesky doesn't have this problem yet because it's so young, so the outsized follow counts are mostly going to be from doomscrollers and outright malicious users, but even if it was exclusively malicious users, there is no perfect algorithm to identify them, much less do so before they start causing performance problems. Under those constraints, it makes sense to limit the potential blast radius and keep the site more usable for everyone.
> Generally, this can be dealt with via policy and moderation to prevent abusive users from causing outsized load on systems, but these processes take time and can be imperfect.
So it’s a case of the engineers accepting that, however hard they try to moderate, these sorts of cases will crop up and they may as well design their infrastructure to handle them.
They do, there are groups of users on bluesky who follow inordinate numbers of other accounts to try and get follows back.
It's insanely frustrating.
Hopefully you're adjusting the lossy-ness weighting and cut-off by whether a user is active at any particular time? Because, otherwise, applying this rule, if the cap is set too low, is a very bad UX in my experience x_x
> at only 1,200 followed people.
I follow like, 50 people on bluesky. Who is following 1,200 people? What kind of value do you even get out of your feed?
The article is talking about people who have following/follower counts in the millions. Those are dozens of writes per second in one feed and a fannout of potentially millions. Someone with 1200 followers, if everyone actually posts once a day (most people do not) gets... a rate of 0.138 writes per second.
They should be background noise, irrelevant to the discussion. That level of work is within reasonable expectation. What they're pointing out is that Twitter is aggressively anti-perfectionist for no good technical reason - so there must be a business reason for it.
While I'm fine with the solution, the wording of this sentence led me to believe that the solution was going to be imperfect chronology, not dropped posts in your feed.
The "reasonable limit" is likely set based on experimentation, and thus on how much people post on average and the load it generates (so the real number is unlikely to be exactly "2000", IMHO).
If you follow a lot of people, how likely it is that their posting pattern is so different from the average? The more people you follow, the less likely that is.
So while you can end up in such situation in theory, it would need to be a very unusual (and rare) case.
The other workaround is: follow everyone. Write some code to get what you want out of the jetstream event feed. https://docs.bsky.app/blog/jetstream
It seems that what they are trying to measure is "busy timelines" and it seems bag they could probably measure that more directly. For example what is the number of posts in the timeline over theast 24h? It seems that it should be fairly easy to use this as the metric for calculating drop rate.
However, I do love reading about the technical challenge. I think Twitter has a special architecture for celebrities with millions of followers. Given Bluesky is a quasi-clone, I wonder why they did not follow in these footsteps.
There are only six users with over a million followers, and none with two million yet.
I'm sure they'll get there.
the only reason to mass-follow is for spam purposes.
In this case I agree though, they're all spammers and/or "clout farmers", or trying to make an account seem more authentic for future scams. They want to generate follow notifications in the hope that some will follow them back (and if they don't, they unfollow again after some interval).
Geographic search to was the most expensive thing they could have done and no matter what we did we couldn’t get them to use the XML feed.
I even tried returning a link to the feed when we detected a bot. No dice. They just kept working around the bot detection.
- Make it easy to systematically unfollow people (or degrade them to a different tier, see below, or sort them automatically into a different feed; maybe even allow automatic following of certain people, like your cities mayor or local ice cream parlors). Like based on recent activity, last engagement with a post, type of content (pictures, videos, links ...), on a schedule (e.g. follow for 3 yeard, follow until 2028), special status (family, friends, member of congress, member of city council, mayor...), number/ratio of common followers, regex expressions, recommendations by certain accounts, letter-to-word ratio, season, planetary alignment, weather, age, train departure time, side-chaing based on other accounts, force accounts to play russian unfollow roulette, urgency to pee, healthcare CEO life expectancy derivative, ... or any combination of these.
- Allow different tiers of following someone. Like friends (never unfollow, always fetch updates), family (never unfollow, rate limit high-energy uncles), news (filter based on urgency or current topics of interest), politicians (highlight as untrustworthy, attach link to donation and board membership disclosure, attach term-limit and next election countdown), local businesses (hard rate limit, attach opening hours), bookmark (never unfollow, no updates), ... maybe multiple tiers in each category and allow those being followed to either temporarily boost their tier (or tiers of certain posts) or e.g. once per year.
- Allow people from exempting some of their posts from not being shown to some of their followers. E.g. two per week and an additional 5 per month.
- Allow people to choose which followers should be given a higher priority when writing posts to their feeds.
Lossy indeed.
Various clients (I’m writing one) interpret the timeline differently, as a feed that shows literally everything includes could things that most people would find undesirable or irrelevant. (replies to strangers, replies to replies to replies, etc)
https://aws.amazon.com/builders-library/workload-isolation-u...
The basic idea is to assign each user to multiple shards, decreasing the changes of another user sharing all their shards with the badly behaving user.
Fixing this issue as described in the article makes sense, but if they did shuffle sharding in the first place it would cover any new issues without effecting many other users.
"In the case of timelines, each “page” of followers is 10,000 users large and each “page” must be fanned out before we fetch the next page. This means that our slowest writes will hold up the fetching and Fanout of the next page."
Basically means that they block on each page, process all the items on the page, and then move on to the next page. Why wouldn't you rather decouple page fetcher and the processing of the pages?
A page fetching activity should be able to continuously keep fetching further set of followers one after another and should not wait for each of the items in the page to be updated to continue.
Something that comes to mind would be to have a fetcher component that fetches pages, stores each page in S3 and publishes the metadata (content) and the S3 location to a queue (SQS) that can be consumed by timeline publishers which can scale independently based on load. You can control the concurrency in this system much better, and you could also partition based on the shards with another system like Kafka by utilizing the shards as keys in the queue to even "slow down" the work without having to effectively drop tweets from timelines (timelines are eventually consistent regardless).
I feel like I'm missing something and there's a valid reason to do it this way.
There's a tradeoff here between batch size and concurrency, but perhaps they've already benchmarked it and "single-threaded" batches of 10k writes performed best.
The current solution is for everyone to use the same few relays, which is basically a polite nod to Bluesky's architecture. The long-term solution is—well it involves a lot of relay hint dropping and a reliance on Japanese levels of acuity when it comes to picking up on hints (among clinets). But (a) it's proving extreme slow going and (b) it only aims to mitigate the "global as relates to me" problem.
I must admit, I had some trouble following the author's transition from "celebrity" with many followers to "bot" with many follows. While I assume the work done for a celebrity to scatter a bunch of posts would be symmetric to the work done for a commensurate bot to gather a bunch of posts, I had the impression that the author was introducing an entirely different concept in "Lossy Timelines."
The „reasonable limit“ is likely set to account for such an effect, but I am wondering if a per-user limit based on the activity of the accounts one follows will be an improvement on this approach.
Long ago, I worked for a dating site. Our CTO at the time was a "guest of honor" who was brought in by a family friend who was working in the marketing at the time. The CTO was a university professor who took on a job as a courtesy (he didn't need the money nor fame, he had enough of both, and actually liked teaching).
But he instituted a lot of experimental practices in the company. S.a. switching roles every now and then (anyone in the company could apply for a different role except administration and try themselves wearing a different hat), or having company-wide discussions of problems where employees would have to prepare a presentation on their current work (that was very unusual at the time, but the practice became more institutional in larger companies afterwards).
Once he announced a contest for the problem he was trying to solve. Since we were building a dating site, the obvious problem was matching. The problem was that the more properties there were to match on, the longer it would take (beside other problems that is). So, the program was punishing site users who took time to fill out the questionnaires as well as they could and favored the "slackers".
I didn't have any bright ideas on how to optimize the matching / search for matches. So, ironically, I asked "what if we just threw away properties beyond certain threshold randomly?" I was surprised that my idea received any traction at all. And the answer was along the lines of "that would definitely work, but I wouldn't know how to explain this behavior to the users". Which, at the time, I took to be yet another eccentricity of the old man... but hey, the idea stuck with me for a long time!
Sounds like Bluesky Pro.
Indeed:
> This means each user gets their own Timeline partition, randomly distributed among shards of our horizontally scalable database (ScyllaDB), replicated across multiple shards for high availability
The interesting next stage for the postgres implementation is to create a sync engine for partial syncs of the network, so that an appview can run affordably. We ran some benches on the current state of the postgres implementation and found we could index 300k users on a $100/mo vps. I think with a couple of weeks of optimization that could reach 1mm users.
Federated PDS-s (which is probably the closest to what people mean when they say they want to federate on bluesky) would not need to reconstruct timelines if their users use the bsky.app appview.
Another notable component that is closed source is the discovery feed generator, where at least there is some reason.
> We did a backend rewrite from postgres to scylla and it has a bunch of deployment specific stuff, but is functionally identical to the open source postgres version. Its not really a "v2" in terms of new features, we just made it make use of our hardware really well[1]
I wasn't aware that AppView v1 was open source, and the most recent info I'm aware of on the topic is https://alice.bsky.sh/post/3laega7icmi2q, https://github.com/bluesky-social/atproto/discussions/2961 and https://docs.bsky.app/docs/advanced-guides/federation-archit..., and everything I've heard about Bluesky was that open source appview is "still coming".
Much of the backend is open source as well: https://github.com/bluesky-social/atproto/tree/main/packages
What is not are the extra services they run to provide a better and faster UX. Even if it was open source, it likely costs 10s of thousands to run per month (they have moved largely to "onprem" hardware instead of the cloud aiui)
Another interesting way to view ATProto is that it could be a collection of headless features and network browsers that leverage those feature providers.
if they gave it away (which used to be unfeasible until the digital era) they feel they’re loosing their valuable effort which they’re wont on concentrating, not diluting.
Seriously? Isn't this the nut of your problem right here?
There are obviously other ways of doing it (doing the timeline propagation in a batch job, fanning out the reads rather than the writes), but they've got their own problems. Probably worse ones.
Periodically classify users as hot/cold based on their activity, build hot-follower timelines on write, and build cold-follower timelines on read.
(And the same for the inverse hybrid strategy of quarantining the writes of highly followed users and handling their fan-out at read time. A neat optimization, and maybe even absolutely once you have accounts with 100M followers. But the vast majority of posts would still be handled via the original strategy.)
A social media system doesn't need to be perfect at all. It was clear to me from the beginning that Bluesky's feeds aren't very fast, not like they are crazy slow, but if it saves money or effort it's no problem if notifications are delayed 30s.
I (unwisely) tried to purchase an Icelandair ticket via the Chase travel portal. I would get a reservation number, go buy seats on Icelandair's website, and a few days later the entire reservation would vanish into the ether. Rinse and repeat 3x.
I can't remember the exact verbiage, but basically tickets can be "reserved" and "booked". One means the ticket is allocated, and one means the ticket is actually paid for. I eventually sat on the phone with an executive support person as they booked the ticket and got it all the way through. It turns out Chase reserves a ticket on an airline but as an SLA of ~3 days to actually pay for the ticket. Icelandair's requires a ticket to be paid with in 24 hours, so it was timing out.
Airlines are far from perfect. They overbook flights and sometimes have to ask people leave and pay them for the inconvenience. My wife and I once got $1000 a piece and a hotel and food voucher to volunteer to take a flight the next day on a layover in Atlanta.
As far as your particular situation, the number one rule of using a third party portal to book flights or hotels is - don’t.
I understand that Iceland Air is not a transfer partner of Chase. But even in that case, I would just wait to use my points until I could use a transfer partner.
On the earning side if paying cash, the difference between 2x/3x points when booking directly and 5x when going through the portal just isn’t worth the risk.
Think about other ad-supported sites. If you're an engineer working on an ad-supported product, the perfect consistency you strive for in your code is not the product. The product is the sum of all of the content the user sees. And the costs of the tradeoffs you make are paid for by ads.
Am I willing to see 10x more ads for perfect consistency? Definitely not.
The slack just gets moved. Airlines oversell by about 8 percent. All systems need some slack in them. Isn't that kinda Bob's Law or something?
Msg 1: I hate ___insert_controversal_person_category_here___
Msg 2: Is the kind of statement that really sets me off
Msg 1 has a very different meaning if you don't see Msg 2.
I hope Bluesky is able to find a model that works for them AND for consumers. (I do know it's an open protocol, so it'll live on without Bluesky itself! However, as this post shows, it's a lot of work to build on the prototype... so if not them, who? And if someone else, how will they become sustainable?)
A) Sustainable revenue is a requirement for any company, yes, but the unlimited (above-inflation) growth demanded by most large corporations is absolutely not. Lots and lots of companies operate for a long time without expecting massive growth, raises n' all. MBAs pejoratively call such companies "lifestyle businesses"--as in "just pays for people to live"--but I'd call them "normal, healthy companies".
B) More fundamentally: the idea that a social media network can only be built by a single corporation owned by investors is an omnipresent, yet extremely toxic, assumption. Mastodon represents another extreme end of the capital<->labor spectrum where anyone can contribute to the network at any time with their own instance, but I think Bluesky is a hint of a less-pure--and therefor more feasible--future.
To use the language of my favorite dream, Chomskian Anarcho-Syndicalism: imagine a social media network organized by a democratic non-profit entity akin to the Python or Linux Foundations, that then contracts out work to a hierarchy of smaller, purpose-built teams ("syndicates"), each of which may in turn contract w/ other teams. Each team would have to attract talent and negotiate enough income to pay them sufficiently still, of course, but there would be no team leader to make a surplus profit from the system -- any "surplus" would stay at the non-profit level, and thus necessarily be reinvested back into the product.
In the current system, the reason Bluesky didn't do this off the bat is obvious: no one would loan them startup funds, as ownership investment is the de facto universal way to start up an unproven venture. But we can dream bigger and better, IMHO; both on a smaller scale by building upon already-proven open protocols like AT Proto, and on a larger scale by structuring the state & economy to support this kind of model equally, if not primarily.
I wholeheartledly disagree. People build things all the time for things other than profit. In fact, most of the greatest things ever built were a loss for those who built them.
Dignity is the best motivator. Profit only supercedes dignity when dignity is not on offer.
Initially, it can be funded by selling tools that do analytics or by donations (like Wikipedia).
Lichess, is it bad? It basically solves the whole problem. If well-designed distributed social media site could be something like that. Donations are enough to support one guy at least.
https://www.piratewires.com/p/interview-with-jack-dorsey-mik...
> That was the second moment I thought, uh, nope. This is literally repeating all the mistakes we made as a company. This is not a protocol that’s truly decentralized. It’s another app. It’s another app that’s just kind of following in Twitter’s footsteps, but for a different part of the population.
> Everything we wanted around decentralization, everything we wanted in terms of an open source protocol, suddenly became a company with VCs and a board. That’s not what I wanted, that’s not what I intended to help create.
At the very least, they do have hindsight to learn from.
Bluesky accepted VC money. For a social platform that means its death certificate has already been signed.
What you're ignoring with that framing is that we can use social media that operates outside the VC startup pipeline and doesn't have enshittification baked in from the start.
ATProto is designed around accounts that are independent of data host, application, and moderation, all in the name of giving users individual control over these things. It's like if every Mastodon user ran their own server, but without the overhead
Frankly, if I get 16 years out of Bluesky before having to move onto the next one, I can live with that. Social networks _die_; it has always been so. USENET, livejournal, Tumblr, twitter... nothing lasts forever.
You can try using other algo feeds from here: https://bsky.app/feeds and remove the discover feed, or of course you could just use the chronological one.
Posts/sec are just off record levels.
I’ll just stay with X, that’s where everybody is, contrary to the bluesky cheerleaders here.