Quick recap: In software engineering, a lossy system is what I call any system designed to return only incomplete answers.
All sufficiently important systems are lossy.
Any social media with an algorithmic feed (YouTube, Twitter, …), any search engine that touches a sufficiently large corpus (Google, Wikipedia, GitHub), …
I already wrote an article outlining examples of lossy systems, which you can find here.
Lossy systems are the tool of necessity you1 reach for once other scaling options get too expensive.
Vertical scaling (i.e. upgrading your existing server, faster car) runs into limits (sooner or later you have the best available hardware). Horizontal scaling (i.e. adding more servers, ‘microservices’, more cars) requires rewriting your existing architecture, forces you to deal with distributed systems, and also runs into limits.
Notes
In a lot of ways I am just reinventing the theory of distributed systems from first principles.
Feedback Loops
You open TikTok2. TikTok shows you a random video with AI-generated fruits. Three observations:
- TikTok’s algorithm ranked the videos, and decided that this specific one is the most engaging one. That’s why it showed it to you.
- TikTok will tightly monitor your interactions with the video (watchtime, swiping, likes, shares, etc.) to train and fine-tune its algorithm.
- TikTok’s algorithm will not rank all videos on the platform just for you, rather, it will pull candidate videos from a smaller pool of candidates.
If you’re reading closely, you can see a problem here.
TikTok is training its algorithm based on your engagement metrics, but your engagement is filtered through a primitive simplifying video pooling process that determines which videos are “candidates” to be shown at the top.
(Here, think of “the algorithm” as a complex neural network and of the pool as a much more primitive tool that’s completely separate from the main algorithm.)
This is necessary due to TikTok’s scale. It’s too large to “just” rank all videos on the platform for every single user.
If you ever wondered why your amazing tweet doesn’t go viral, or why YouTube’s front page is nothing but the same 5 videos over and over, this might be why. It’s a two-step process.
Why is any of this interesting?
First, to outsiders of the system, it is not obvious that “the algorithm” is a multi-stage process with individual “gates”3 that need to be passed.
Second, the candidate pool introduces a new bias to the training process.
The training and personalization data of your algorithm is coming from the user. Any new stage in your pipeline is new bias, new complexity that you have to account for, and a decision to favor some data you could be collecting over other data.
One-Way Doors
Some data you can only gather at one exact moment in time, but you may want to keep it for months.
Once you decide to stop gathering it, there’s no way to ever “recover” it, or re-obtain it. It was completely transient, and the database table that could have existed just isn’t there. One-way door.
The shift to a lossy system is (in practice) irreversible. There’s no real reason to perform this shift other than to allow scaling, reduce costs, or lower latency.
You could (in principle) try to flip the switch and start sampling at level 100%, but your whole infrastructure is already struggling to keep up at the current level. If you did that, half of the system would just instantly fall over, and you would hit new scaling limits that most likely cannot be solved by simple horizontal or vertical scaling.
Often this one-way door is “forced”. If you have to scale up, you have to make concessions at some point. You either make the jump, or your whole system starts slowing down or breaking.
Observability
Observability is the practice of building infrastructure which allows you to monitor how well your own service is working.
It’s a broad scope. It includes aggregate metrics (i.e. how many requests do I receive? How many users do I have?), but also highly precise events (i.e. at which point in time did X happen? What does the ’trace’ of a real request through my entire system look like?), and everything in between.
First, observability is a prime candidate for lossy data aggregation.
Do you need exact data, or just a good estimate? Most of the time estimates are fine. Do you need every single incoming request to be logged? No, most of the time just sampling some of the requests is fine. They are “similar enough” that everything else would be duplicate data.
Second, lossy systems demand better observability. You pay a complexity tax.
You add a cache? Well, you may have to start tracking cache misses and staleness.
You allow dropping workers that require too long in favor of returning incomplete responses to end users? Well, you better figure out a way to track how often this happens, or issues may sneak in. The system is better at operating with lossy data, so it’s harder to notice when it’s happening, even when the quality is dropping.
Quantitative vs. Qualitative Changes
Here’s a simple example, commonly used in statistics to explain basic null hypothesis testing.
You are planning to buy 2,000 widgets. You’d like to ensure that only a small number of widgets are defective. To ensure this, you randomly grab some of the widgets, and test them. Each widget either passes or fails.
You don’t want to accept the contract if more than 2% of the widgets are defective.
How many widgets do you need to check to obtain a >95% certainty that no more than 2% of the widgets are defective?
Right.
This is the most simple example, but since we’re sampling, we have to reason in terms of statistics.
You could instead imagine a different process: If we had a highly efficient widget-checking machine, we would not have to worry about any of this. We could always check 100% of the widgets. In return, we’d never have to employ statistics, or (perhaps more importantly) worry about the bad widgets that will end up in our products.
Essentially, the shift to a lossy system often comes with qualitative changes that need to be accounted for. You lose more than “just” some certainty.
This is another example of a complexity tax.
“We test all of the widgets before we use them.” is easy to understand, and increases a base-certainty in the product.
“We test exactly X% of widgets, where X is chosen according to our total widget order, to minimize costs while giving us some amount of certainty that we are risking at most Y% defective products this quarter.” requires a bit more thought.
Takeaway
Imagine the following: You are a highly enthusiastic dynamic young software engineer. You land a job at Google. On the first day of work, you walk up to a few people on your team and ask them something like “Where can I look up how many YouTube videos there are?”.
Obvious question, no? Just pure interest, the sort of thing you’d ask for fun, or as part of getting oriented at your new job.
In response, all you get are exasperated sighs. Or worse, looks of confusion, as if the question doesn’t even make sense.
This is what big tech rot feels like. Deceptively simple questions turn out to be complex or impossible to answer4.
Sometimes this is just raw complexity. The system has so many layers that no one could possibly understand the whole.
Other times it’s downstream of optimizations. The system became lossier, costs were cut by 17% somewhere, and everyone was happy since the precise number of videos doesn’t matter anyway, right?
If you've made it this far, consider signing up for e-mail notifications, following along on Substack, or adding this blog to your RSS reader.
-
Not you personally. Big Tech. Whatever you are cooking up in your garage, the odds of you having to think about engineering a lossy system are low. Standard tools (compression, deadlines) that everyone already reaches for as best-practice defaults are all you need. ↩︎
-
Or any similar algorithmic feedscrolling app. In this regard they should all be the same. ↩︎
-
To borrow a Claude-ism. ↩︎
-
“Does YouTube really not know how many videos there are?” I have no idea, I never touched YouTube’s backend, this whole story is purely illustrative of a pattern I’ve seen multiple times. ↩︎