getbetterat.work
TECHNICAL REPORT

Why Saving Data Makes Systems Slow

Making a software app huge (like Netflix) is hard because of one thing: memory. In tech, we call remembering things "state". This report explains why state breaks apps, and how top engineers fix it.

The Physics of Computers: The CAP Theorem

When computers talk to each other over the internet, connections sometimes break. When a connection breaks, engineers are forced to make a hard choice. You cannot have everything. You must pick between two things:

  • Consistency: Make sure every user sees the exact same data. If they can't, shut the app down until it's fixed.
  • Availability: Keep the app running for everyone, even if some people see old or wrong data for a little while.

The PACELC Rule

Even when the internet is working perfectly, saving data slows things down. If you want all computers to agree on a piece of data, they have to wait for the slowest computer to reply. More computers = more waiting.

Not All Data is the Same

To build big apps, engineers sort data by how long it needs to live. The longer you save it, the harder it is to grow your app.

Data Type
How Long It Lives
If It Breaks...
Growth Difficulty
Stateless
Zero memory
Start over instantly
Extremely Easy
Soft-State
Erases on a timer
Fetch it again later
Easy
Session
While you use the app
User must log in again
Medium
Hard State
Saved forever
Total disaster
Extremely Hard

Smart Ways to Build Big Systems

The REST Method

Don't make the server remember anything.

Instead of the server keeping track of who you are, your phone or browser carries an ID card (like a cookie). You show this ID card with every single click. Because the server remembers nothing, you can add 1,000 new servers instantly.

Functional Code

Never change data, only make copies.

If two parts of a program try to change the same word at the same time, it crashes. Functional programming solves this by making a rule: you can never erase or change data. You just make a brand new copy with the changes. This lets computers run safely at super speeds.

The Actor Model

Give everyone their own mailbox.

Instead of all parts of a program sharing a giant memory pool, we break the program into tiny "actors". Each actor works totally alone and only talks to others by sending text messages. If one actor crashes, the others keep working perfectly.

The Diary Method

Write down history, don't erase it.

Instead of having a bank account that says "$50", the computer writes a diary: "Added $100. Spent $50." To know your total, it reads the diary from the start. This is incredibly fast to write down. To read fast, we create a totally separate "fast lane" just for viewing the totals.

Modern Frontiers: Cloud & AI

Serverless

Today, some code only lives for one second to answer a click, then dies. Because it dies instantly, it cannot remember anything. Builders must use ultra-fast external memory banks to save data before the code disappears.

Artificial Intelligence

Teaching an AI is slow because its "brain" (state) is constantly changing and updating across thousands of computers. But asking an AI a question is fast. Why? Because when you ask a question, its brain stops changing. It becomes a frozen copy that can be placed on a million servers at once.

The Traffic Cop (Load Balancing)

Random Routing

If servers don't remember you, the traffic cop sends you to any free server. This is fast and never clogs up.

Sticky Sessions

If one specific server remembers you, the cop must send you to that exact server every time. If that server breaks, you lose your data.

The Fast Desk (Caching)

Going to the main database to find data is like walking to the basement library. It takes too long. Engineers put a "cache" (a temporary fast memory) right on the desk.

User Asks
Fast Cache (1ms)
SUCCESS
Slow DB (Skipped)

Splitting the Notebook (Sharding)

When a database gets too big to search quickly, engineers chop it into smaller pieces. This is called "Sharding".

Users A - H
Users I - P
Users Q - Z

Spreading Rumors (Eventual Consistency)

Don't wait for everyone.

Instead of forcing 100 servers to agree instantly (which stops the app), one server accepts your data and says "Got it!"

Then, it whispers the update to the other servers in the background. For a few seconds, some users might see old data, but the app stays super fast.

The "Safe to Click Twice" Rule

Because internet connections drop, users often click "Buy" twice. The system's memory must be smart enough to know it's the exact same request, so it doesn't charge the user twice.

Tech Name: Idempotency

BUY NOW

Clicked 5 times, charged only once.

Many Small Factories (Microservices)

Instead of building one giant app that remembers everything, engineers build 100 tiny apps that only remember their specific job. If the "Photo App" crashes, the "Billing App" still works perfectly.

Billing
Photos
Log In
Search
Emails

The Bouncer at the Door (Rate Limiting)

Protecting the Database

If 10,000 people ask for a file at the exact same second, the database will crash. To save the memory, the system acts like a strict bouncer at a club.

User Request #1ALLOWED
User Request #2ALLOWED
User Request #3DENIED (Too Fast)

Beating the Speed of Light (CDNs)

Data cannot travel faster than light. If the server is in New York and the user is in Tokyo, it will always be slow. The fix? Copy the memory to a mini-server right inside Tokyo.

Content Delivery Networks (CDN)

"Are We There Yet?" (Fetching Data)

POLLING

The Annoying Way

The phone asks the server every 1 second: "Any new messages?" This annoys the server and wastes massive amounts of memory and power.

WEBSOCKETS

The Smart Way

The phone connects once and stays quiet. The server remembers the connection and taps the phone only when a message actually arrives.

Breaking Things on Purpose

CHAOS ENGINEERING

How do you know if your memory is safe?

Top companies use "Chaos Bots". These are automatic programs that randomly turn off servers, delete wires, and crash databases in real life. If the app stops working, the engineers know they built it wrong. A perfect app doesn't care if a server dies.

The Builder's Checklist

  • Make Logic Dumb The main code of your app should be completely forgetful. It should only process the data given to it at that exact moment.
  • Keep Junk Out of the Main Database Temporary stuff (like items in a shopping cart that isn't bought yet) should stay in fast, temporary memory. Never put it in your permanent, hard-to-grow database.
  • Split Reading and Writing If your app has a million people reading it but only ten people writing to it, put the readers on a different server system than the writers.