Complex Engineering Topics. Simplified.


Monis Yousuf

CAG Theorem - Consistency, Availability or GTA6.
P.S: An interesting video is about to drop soon ;)

2 weeks ago | [YT] | 0

Monis Yousuf

We're in the age of LLMs, and computers are still failing at math.
Try adding 0.1 + 0.2 in your favourite programming language. You won't get 0.3. You will get
.
.
.
0.30000000000000004. But... if you try 0.2 + 0.2, you get 0.4. Why is that?

The reason is non-terminating binary fractions. Just like when we divide 10 by 3 and we get 3.333333... repeating endlessly, in binary - the fractions 0.1, 0.2 and 0.3 repeat endlessly with a pattern of "0011".

But, the computer has only 64 bits to store each of these numbers (more precisely, 52 bits to store the repeating fractions). So, you need to drop some bits. When you drop them, you round each one of them.

0.1 rounds to 0.1000000000000000055511151231257827021181583404541015625
0.2 rounds to 0.200000000000000011102230246251565404236316680908203125
and 0.3 rounds down to 0.299999999999999988897769753748434595763683319091796875

So, when we add 0.1 and 0.2 - both are already rounded up and their sum 0.3000000000000000166533453693773481063544750213623046875 is also rounded up, to 0.30000000000000004. 4 rounding decisions, 3 up and 1 down. The sum and 0.3 land on two different numbers, and 0.1 + 0.2 == 0.3 comes out false.

But why does 0.2 + 0.2 work? And how do banks handle our money with these precision problems? Tell me in the comments :)

2 weeks ago | [YT] | 7

Monis Yousuf

Have you ever wondered how a vector database actually finds meaning?
How a single query brings back entire sentences and paragraphs that "mean" what we asked, even when they don't share a single word with our query?

If we ran a simple keyword search for "vacation days per year" across the text chunks of multiple documents, it might work, as long as those exact words are in the text. But what if the documentation only says "annual leave"?

This is precisely where we need semantic search. A synonym dictionary can't keep up with every way people phrase the same thing. So how does a vector database perform this semantic search?

The answer is basic linear algebra: cosine similarity, the dot product of two vectors divided by their lengths. But that's not the whole story. The heavy lifting is done by an embedding model, which turns each piece of text into a point in an n-dimensional space (384 dimensions for a small model like all-MiniLM-L6-v2). The coordinates of that point are its embedding, and cosine similarity compares those embeddings.

The image shows the same idea on a toy graph: three axes instead of 384, and each animal's coordinates are its embedding.

But with a million pieces of text, that's a million embeddings and, consequently, a million cosine calculations for every single query. For a production system, that's far too slow. This is where indexes come in. A common one is HNSW, which searches greedily through a layered graph and cuts ~1M comparisons down to a few hundred: roughly logarithmic instead of linear. It's approximate (it can occasionally miss the true closest match), but it does the job.

Where are you using semantic search in your apps: RAG, support tickets, internal docs?

The full video, from this graph all the way to the HNSW index: https://www.youtube.com/watch?v=m6Ubz...

#VectorDatabase #RAG #Embeddings #SystemDesign

1 month ago | [YT] | 22

Monis Yousuf

πŸ€“ Every Distributed Database is bound to face a choice between two things.
.
.
.
Consistency: Where all nodes return the same data at the same time, OR
Availability: All nodes respond, even if data is stale.

When a network partition breaks the connection between your primary and read replicas (and it will!) - you can only guarantee one. But, the question is which one?

Eventually, you have to make this choice and this moment will determine your seniority in system design interviews and customer impact in your organisation!

Check out my latest video on CAP Theorem where I walk you through a real production scenario and help you understand how you can actually apply these principles in a System Design Interview and more importantly, in real life!

5 months ago | [YT] | 2

Monis Yousuf

πŸ₯˜ What’s the secret sauce behind how Cassandra, DynamoDB, and Redis scale so smoothly?

Every distributed datastore, at some point - faces the same existential crisis:
"A new node joined us, shall we reshuffle?" - Nightmare.

That is where consistent hashing shows up and quietly saves the day.

Instead of reshuffling the entire cluster every time a node joins or leaves, consistent hashing keeps data movement to a minimum. Fewer tantrums. Less chaos. More on-call money (without waking up in the night).

See Full Deep Dive in This Consistent Hashing Video!

5 months ago | [YT] | 3

Monis Yousuf

Did You Know that Servers can tell the Browsers to Cache Responses? See How They Do It! πŸ‘‡

6 months ago | [YT] | 1

Monis Yousuf

There are MILLIONS of Comments written Every Hour on Social Media Websites. Have you ever wondered how they do that?

A single write instance is clearly not enough to handle that amount of write load, not only from the perspective of storage, but also performance. For this reason, the data is divided into different chunks and split across multiple instances.

Like everything, the devil is in the detail - things start to get really complicated when we start to think about:
- How should we split the data?
- How to ensure that the data is split evenly?
- What should we do in case a celebrity posts a picture which goes insanely viral?

In this youtube video, we deep dive into precisely those things via two foundational concepts, Data Partitioning and Sharding.

7 months ago | [YT] | 7

Monis Yousuf

2 Years. 17 Videos. 10k Subs. 300k views & Priceless Comments.

In 2023 - I started a youtube channel with a sole goal, to simplify complex engineering topics and clarify concepts which a lot of engineers think, "Its probably too late to ask".

The channel slowly grew, view-by-view, subscriber by subscriber, comment by comment, one at a time for one sole reason - your comments.

Comments, which contained a whirlwind of emotions - the simple happiness of the fact that you understood it, your curiosity of the next video, your anticipation for the next video, your interest of asking questions and most importantly, your words of encouragement and positivity. All of these comments and the emotions behind them helped me pivot the channel in the right direction.

There is still a long path to walk, so I will continue this journey so that I can help you in yours!

Here I am, in this photo - reading your comments πŸ˜‰
Thank you all!

1 year ago | [YT] | 22

Monis Yousuf

Did you know, that without Idempotence - you could possibly be charged twice for your purchase?
Idempotence resides at the very core of Payment Systems - but what is this concept really about?
Let's find out :)

1 year ago | [YT] | 6

Monis Yousuf

Do you PANIC when the interviewer asks you to calculate the Time Complexity of your solution?
You're not alone !

The concepts of Time Complexity and How to Efficiently Calculate it, makes a lot of engineers shiver.
In this video, I break down the fundaments of what Time Complexity is and how you can calculate it quickly and efficiently in the interviews.
At the end of the video, we will also discuss some sample questions to solidify your learning.

Time to nip it in the bud, once and for all!

1 year ago | [YT] | 8