Last updated on
Computer Architecture
💾 Computer Components and Storage
This section focuses on the main storage components of a computer: disk and RAM.
Disk (Storage / Hard Drive / HDD / SSD)
- Function: Stores all data persistently. Data remains even if the computer restarts or crashes.
- Capacity: Typically measured in hundreds of gigabytes (GB) or, more commonly, terabytes (TB) ($10^{12}$ bytes).
- Quick Review: A byte is 8 bits. A bit is a 0 or a 1, used to represent information.
- Speed (Latency): Reading and writing from disk is typically measured in milliseconds (ms) ($10^{-3}$ seconds).
- HDD (Hard Disk Drive) vs. SSD (Solid State Drive): SSDs are generally faster than HDDs.
Memory (RAM - Random Access Memory)
- Function: Also stores information, but it is not persistent (volatile). Data is lost upon crash or restart.
- Capacity: Typically much smaller than disk, measured in gigabytes (GB) (e.g., 2 GB to 32 GB or more).
- Cost: RAM is typically more expensive than disk storage per unit of capacity.
- Speed (Latency): Reading and writing from RAM is much faster than disk, measured in microseconds ($\mu$s) ($10^{-6}$ seconds).
- RAM is often 10 to 1,000 times faster than disk.
- Contents: Stores both the executable code and the data (like variables/arrays) the CPU is currently working with.
🧠 Central Processing Unit (CPU) and Cache
This section describes the computer’s “brain” and its fastest storage component.
CPU (Central Processing Unit)
- Function: The “brain” of the computer. Its main capabilities are:
- Reading and Writing: Communicates with and transfers data to/from RAM and Disk. The timing of these operations is measured by how long it takes the CPU to perform them.
- Executing Code: Reads compiled instructions (represented by zeros and ones) from memory and executes them.
- Computation: Performs all computations and arithmetic operations (add, subtract, etc.).
- Operation: Reads code instructions and manipulates data stored in RAM.
Cache
- Function: A very fast, small component that belongs to the CPU itself, used to speed up read and write operations from RAM.
- Capacity: Typically much smaller than RAM, measured in megabytes (MB).
- Speed (Latency): Reading and writing from the cache is the fastest, measured in nanoseconds (ns) ($10^{-9}$ seconds).
- This is even faster than RAM (microseconds).
- Operation: The CPU intelligently stores a frequently accessed subset of RAM into the cache. The CPU checks the cache first for data; if the data is found (cache hit), it’s read much faster than reading from RAM. If not found (cache miss), the CPU reads from RAM and may then copy the data into the cache for future use.
- Persistence: Like RAM, the cache is not persistent (volatile).
📈 Limitations and the Move to Distributed Systems
This section discusses the constraints of a single computer, which necessitate the use of distributed systems.
Hardware Limitations
- While you can add more disk storage, more RAM, or a bigger cache, an individual computer has inherent hardware limitations, especially concerning the CPU’s speed in executing code.
- Moore’s Law: An observation by Gordon Moore (Intel co-founder) stating that the number of transistors (a proxy for CPU speed) inside a CPU doubles approximately every two years, and the cost is cut in half.
- This suggests an exponential growth in CPU speed.
- Current Trend: In recent years (roughly the last 10), CPU speed increases have begun to plateau, or slow down, indicating that we cannot infinitely scale a single CPU.
Distributed Systems as a Solution
- Because a single computer has performance limitations (especially the CPU speed plateau), combining multiple computers becomes necessary to solve very big problems.
- An individual computer’s architecture (CPU, RAM, Disk) serves as the building block for designing a distributed system. The principles of balancing speed, capacity, and persistence (like the CPU/Cache/RAM/Disk hierarchy) have parallels in distributed system design.
- Further Benefits: Distributed systems offer other advantages beyond overcoming single-machine limitations, which will be discussed later.