Posts tagged #how-it-works
-
How a hash chain shows tampering
A hash chain stores each record's hash inside the next record, so editing an old record breaks every later link and the change shows.
-
How a message queue decouples two services
A message queue holds work between two services. The sender drops a message in and moves on, and a consumer takes it when ready.
-
How rate limiting works
A token bucket refills at a steady rate and every request spends one token. When the bucket is empty, the server answers 429 and can say when to retry.
-
How CORS works
Browsers block a page from reading another origin's response. CORS headers are how a server says who may read it, with a preflight for riskier requests.
-
How a cookie keeps you logged in
HTTP forgets you between requests. A cookie holding a random session ID is how a server recognizes you again after you log in.
-
How JPEG makes images small
JPEG converts colors, cuts the image into 8x8 blocks, applies a DCT, rounds with a quality-scaled table and packs the result with Huffman coding.
-
How computers store negative numbers
A signed integer spends its first bit on the sign and stores a negative number as 128 minus its size in the other seven bits. This is two's complement.
-
Why 0.1 + 0.2 is not 0.3
Computers store 0.1 as the nearest binary fraction, which is a hair off. Add two such values and the sum prints as 0.30000000000000004.
-
How UTF-8 stores text
UTF-8 writes each character as one to four bytes. The first byte tells a reader how many, so any language fits and ASCII stays small.
-
How a file system finds your file
A file's name lives in a directory, not in the file. The system follows the path one name at a time until it reaches the inode.
-
How a deadlock happens
A deadlock is two threads each holding a lock the other one needs. Neither can move, so the program hangs.
-
How a process differs from a thread
A process owns its memory. The threads inside it share that memory, and each thread keeps its own stack and registers.
-
How a compiler turns code into machine code
A compiler turns source code into machine code in stages: a front end, an optimizer and a back end joined by a shared form, then a linker.
-
How the stack and the heap differ
The stack stores fixed-size values in last-in, first-out order. The heap holds data of any size, and you reach it through a pointer.
-
How ARC frees memory in Swift
Swift counts the strong references to each class instance and frees the instance when the count reaches zero. Two instances holding each other never do.
-
How a load balancer spreads requests
A load balancer takes requests sent to one address and hands each one to one of several servers, skipping a server that is failing.
-
How a CDN serves files from a server near you
A CDN keeps copies of files on servers close to visitors. A fresh copy is answered at once, and a missing one is fetched from the origin server first.
-
How WebSockets differ from polling
A WebSocket keeps one connection open so either side can send messages. Polling makes the client ask every time, often for nothing.
-
What a REST request and response look like
A call to a web API is an HTTP request and a response with the same shape: start line, headers, an empty line and a body. The method and status code carry the meaning.
-
How a database index works
An index is a sorted structure next to a table. The database searches it instead of reading every row, but it must keep it in sync on every write.
-
How a JWT works
A JWT is a header, a payload and a signature joined by dots. The signature catches changes to the token, but it does not hide what is inside.
-
How "Sign in with ..." works
An app signs you in without seeing your password: the provider sends back a short-lived code, and the app trades it for tokens.
-
How public-key encryption works
Public-key encryption uses a key pair: anyone can lock a message with the public key, and only the private key unlocks it.
-
How passwords are stored: salt and many rounds
A well-built site stores a value derived from your password, not the password. PBKDF2 mixes in a random salt and repeats the work many times.
-
How an SSD stores data
Flash memory cannot overwrite data in place, so an SSD's controller erases whole blocks, spreads the wear and hides it all from the operating system.
-
How RAM and disk differ
RAM is temporary working space and disk keeps files. A page cache in RAM sits between them, which is why a second read of a file skips the slow disk.
-
How a CPU runs one instruction
A CPU gets the instruction its program counter points at, works out what it asks for, does it, and moves on. The loop is simplified, but it is the core idea.
-
How a cache makes things faster
A cache keeps a copy of an earlier answer close by. In HTTP, a fresh copy is reused as is, and a stale one is checked with a small 304 reply.
-
How a packet finds its way across the internet
Each router looks up the next hop in its own table and picks the longest matching prefix. A time-to-live counter stops packets from looping forever.
-
How TCP makes sure data arrives
TCP numbers every byte, waits for the receiver to confirm, and resends the oldest unconfirmed segment when a timer runs out.
-
How Git stores your commits
Git saves a commit as small objects named by the SHA-1 hash of their contents: blobs for files, trees for folders, and a commit that points at both.
-
How a hash table finds things fast
A hash table turns the key into a number, uses that number as a position in an array, and jumps straight there instead of searching.
-
How HTTPS keeps a connection private
Before a page travels, browser and server agree on a secret key in a short handshake, the server proves who it is, and the rest is encrypted.
-
What happens when you type a URL and press Enter
Pressing Enter starts a short chain: find the server's address, open a connection, ask for the page, then draw it on screen.
-
How DNS turns a name into an address
DNS is the internet's phone book. A resolver follows referrals from the root to the right server and caches the answer.