Ask anything about this post!
One Team, One Brain: Why We Need a Database. 🧠🗄️
So far in our journey, we’ve made huge progress.
We moved from "One User, One Computer" to "Millions of Users." We handled the traffic crowd using a Load Balancer and multiple servers. We are feeling good. The servers are humming. The site isn't crashing. But... we have a new problem. A memory problem. 🧠
Imagine our restaurant analogy again. We now have 5 waiters (Servers) instead of one.
Waiter A takes your order for a Pizza. He writes it down on his personal notepad.
You wait for 20 minutes. Waiter B comes to your table to check on you. You ask: "How is my pizza?" Waiter B looks confused. "I didn't take your order. I don't know what you're talking about."
Frustrating, right? 😤 This is exactly what happens in tech if we aren't careful. When you log into Instagram, your first request might go to Server A. Server A remembers: "Ah, this is Abhinay. He is logged in." But a second later, you click a photo. The Load Balancer sends you to Server B. Server B looks at you like a stranger: "Who are you? Please log in again." We can't have every server keeping its own separate memory. We need a Shared Memory. A Single Source of Truth.
Enter... The Database. 💾
The Database is a separate computer (or cluster of computers) dedicated entirely to storing data.
It doesn't process the logic like the servers do. It just remembers. Now, the flow changes:
Any waiter (Server) can take your order.
They immediately write it down on the Central Kitchen Board (The Database). If you ask any waiter for an update, they look at the same board and give you the right answer.
System Design Lesson #2: Servers come and go (they scale up and down), but the Database remains the permanent memory of your system. So, we have Load Balancers handling the traffic, and Databases handling the memory.
But wait... 🤔
If millions of users are hitting that one database constantly... won't that crash too?
We have a new bottleneck. And we will solve that next.
Quick Question: Do you think the "waiter" (Server) should have a small notepad of its own (Cache) for super common things, like the menu? Or should it always run to the Kitchen Board (Database)? 🍕
Let me know your thoughts!
Thank you for reading our blog!
We have a Discord community where you can ask questions and get help from the community.
No comments yet. Be the first to share your thoughts!