How the #Google File System turned a cheap piece of hardware into a web giant
Google is a huge company. It manages search, email and cloud storage. But here’s the twist. It turns out it can’t be done on a supercomputer. You might think that an operation of this size would require sophisticated and expensive server racks with all kinds of bells and whistles. This is not true.
Google relies on off-the-shelf hardware. cheap machine. Linux based server. This type of equipment is likely to be found in standard data centers rather than high-tech laboratories. How can one of the most powerful technology companies in the world survive on cheap hardware? The answer can be found in the Google File System (GFS).
This unique architecture is our secret sauce. Equipment defects are compensated by design, not by purchasing better equipment. This allows Google to treat low-cost servers not as single points of failure, but as disposable components in a larger and more efficient network.
Why do common filesystems have major failures?
Traditional file systems are built on a single machine. They are not built for thousands of them. Google handles large files (often gigabytes). If you try to manage these with standard tools, everything falls apart. Network congestion. Bandwidth saturation.
Here, scalability is the most important metric. The system is scalable if the capacity can be increased without reducing the performance. Google needs to increase capacity constantly. The GFS is specifically designed for this purpose.
The team also used autonomic computing. This means that the system itself is monitored. Diagnose the problem. it solves them. All without human intervention. Imagine a server farm that can heal itself in real time. That’s the goal. Challenge? Run automation on a network of “thousands” of machines.
Google keeps the exact number of machines a secret. They said, “Thousands.” That’s all we get. But its structure is revealed enough to understand the logic.
Design philosophy: Keep it simple
Complexity leads to failure. The more complex a system is, the more likely it is to break down. The GFS team opted for simplicity. They removed unnecessary features. Users get basic commands.
Open
Create
* Read
write
Close
They also added two special commands based on real-world usage.
- Append : Append the data to the end of the file. Existing data will not be overwritten.
- Snapshot : Creates a snapshot of the system state.
Google’s workloads are typing-intensive. Paste the information instead of retyping it. Overwriting with GFS is ineffective. Appends are fast. This optimization alone can make a huge difference in performance.
The Chunking Strategy
GFS files are large. Multi-gigabyte files are normal. Transferring such large blocks consumes a lot of bandwidth. What is the solution? Break them up.
GFS divides files into fixed size blocks. Each block is 64 megabytes. Each block has a unique 64-bit identifier called a block handle.
Why fixed size? Resource management is simplified. You can immediately see which servers are full. Which one is idle? You can move blocks to balance the load. If a server fails, the system knows exactly which 64 MB blocks are on that server. You can quickly copy it elsewhere.
The system doesn’t optimize for them. Built for big data.
Distributed Computing: The Power of Many
Distributed Computing may sound technical, but the concept is simple. Connect multiple computers. Combine resources. memory. Processing capacity. Storage.
The network becomes a giant virtual computer. Each node acts as both a processor and a storage space. This redundancy is important. If one machine goes down, the other machines take over. The system does not crash. I adapt.
Google uses this model to provide an infrastructure for accessing, creating, and modifying data. The GFS is the backbone. It’s unique to Google. It is not for sale. However, it serves as a powerful case study for organizations dealing with large data sets.
It’s not just about the best hardware. It’s about the best possible architecture.
Analyze Google’s file system architecture
Google doesn’t just put a server in a room and hope for the best. They built the Google File System (GFS) around specific clusters, networks of hundreds or even thousands of different machines. To understand how this beast works, we need to look at the three main players: the client, the master server, and the chunk server.
Treat clients as end users. It does not matter whether the request is made by the user of the application or by another server. When you ask GFS to read, write or create a file, you are the client.
Heavy lifting on the master server
The Master Server is the brains of the operation. It does not affect the actual file data. Instead, it manages metadata, which are navigation paths that describe the chunks that make up a given file and their locations.
It keeps an operation log. This is important. If the master server goes down, the backup can step in, check the logs, and restore control without losing cluster state. At startup, the master server asks each chunk server for inventory. Learn where everything is and stay informed.
Only one master node per cluster is active at a time. Other copies exist only as backups in case of hardware failure. This one adjustment point looks like the bottleneck of the future. How does Google avoid congestion with a single coordinator? Messages sent and received by keeping them tiny. We deal with logistics, not data. Chunk servers handle the heavy lifting.
Chunk Server: A true workhorse
Here we have a 64-MB file chunks. Chunk servers are the storage engines. It does not communicate with the master server to transfer data. Send the requested piece directly to the client.
Built-in redundancy. GFS replicates each chunk. By default, three replicas of each chunk are created and distributed among different chunk servers. This setting can be adjusted, but the default value is 3. This ensures that no data is lost even if one server goes down.
Select the correct copy
When a client requests data, not all copies are the same. GFS splits these Primary Replica and Secondary Replica.
The primary copy is the copy that clients actually read or write to. Everything else is backup. The master server decides which chunk server takes the primary role. When new data is written to a block, the master tells the secondary replicas to take the updated version from the primary replica. The system synchronizes everything.
The master does not transfer data. Just tell the chunk servers where to put it and who should read it.
This is a simple hierarchical structure. brain. many hands. small signal. Large storage space. Will this design work even with network lag? This is another question.
Reading the information is easy. The client asks the main server for the location of the file. The server returns the address of the primary replica. This copy owns the lease. The client then connects directly to the chunkserver. The replica sends data.
If no replica has a lease, the master steps in. The master server selects the primary server by comparing IP addresses. The goal is to get closer. The chunkserver closest to the client gets the job. This chunk becomes the primary. Therefore, the client bypasses the master.
Writing is more complicated. The client asks the master for the location. The master server returns a primary and secondary replica address. The client caches it. This will prevent hitting the master again in the future. Unless the primary disappears. Then the client has to ask the master again.
The client sends write data to all replicas. Starting with the closest. It ends at the farthest point. The order of primary or secondary status is irrelevant. Google calls this a pipeline.
When the replica receives the data, the primary replica takes over. Each change is assigned a sequential sequence number. These changes are mutations. These numbers tell copies how to order updates. Primary applies mutations in order. Send the request to the secondary replica. They follow the same process.
If all goes well, all replicas in the cluster will merge the new data. Secondary replicas report to the primary replica. After that, the primary reports to the client. success? The process ends. Failure? The primary explains.
Assume that the secondary replica is unable to update mutations. The primary notifies the client. Try the modified application again. Many times. If the secondary node continues to fail, the primary node orders the entire write process to restart. If this also fails, the master marks the affected replicas as garbage.
What happens next? The master recognizes the garbage. It cleans it.
Large file management
Large files violate the small file rule. If a write request affects multiple blocks of a large file, GFS splits the request. A separate request is made for each piece. The rest of the process remains the same. Each block goes through its own pipeline.
Deal with hardware reality
GFS is not built for data centers that cost $50,000 per server and last 10 years. Built for commodity hardware. Developers know that when scaling to thousands of cheap machines, failures are a feature of the environment, not a bug. The component dies. Network delay.
That’s why we code flexibility right into our architecture. The system must solve its own problems.
Shadow Masters and Failover
集群中有一台主要主服务器。 但如果单点故障消失,集群就不会崩溃。 这就是shadow masters 发挥作用的地方。
这些不是完整备份。 它们是在其他计算机上运行的只读副本。 当主要主控处理写入、模式更改和繁重工作时,影子主控则坐在幕后。 他们受到了打击,仅仅落后了几分之一秒。 但对于简单的读取请求,它们已经准备就绪。
他们监视操作日志。 他们轮询块服务器。 他们对系统保持脉搏。 如果主主机崩溃并且无法重新启动,影子主机就会自我提升。 转换是自动的。 集群继续呼吸。
Replication between racks
Data redundancy is more than copying files. It’s about geography on a rack. GFS replicates blocks on different physical machines. Ideally, these machines are in separate racks.
Why? This is because a power surge or cooling failure can bring the entire rack to a standstill in an instant. If all copies of a block are on that rack, the data will be lost. By spreading copies, GFS ensures that data is preserved on servers in adjacent aisles even if the entire rack loses power.
The master server uses unique block identifiers to verify integrity. If the handle of the replica does not match the master record, the system considers the replica to be corrupted. Create a new replica from the healthy source and assign it to the free chunkserver.
Garbage Collection and Staleness
块服务器运行得很热。 它们总是接近容量。 主服务器像鹰一样监视着他们。 它检查副本是否是最新的。
如果副本的标识号与活动块不匹配,则副本将变得“陈旧”。 陈旧的数据本质上是垃圾。 但它不会立即消失。
系统会将陈旧的块保留三天。 这不是疏忽。 这是一个安全网。 它为管理员提供了一个在永久删除之前查看和恢复数据的窗口。 窗户关闭后,垃圾将被清除以释放空间。
Checksum: Digital fingerprint
Hardware lie. Bits flip around. Data can be corrupted without warning. GFS does not trust this disk. It believes in mathematics.
The system uses checksums to prevent silent data corruption. Each 64 MB block is divided into smaller 64 KB blocks. Each block has a 32-bit checksum. Think of this as a fingerprint for specific information.
The master server maintains an official list of these checksums. When we check the copy, we compare the stored fingerprint with the actual data. If they do not match, the copy is considered corrupted. The master removes the bad replica and restores the good replica. No user action is required.
Heartbeat and handshake
How can the master know this in real time?
Through continuous communication. These components don’t just sit there. They send electronic messages called heartbeats and handshakes.
These are updated briefly and often. A heartbeat says, “I’m alive.” A handshake confirms that it is “connected and ready.”
Without these signals, the main server would be blind. It wouldn’t know which chunkservers are down, which servers are slow, or which ones are lying about their data. These messages provide the system with a millisecond accurate picture of reality.
What hardware does Google use with GFS? Find out in the next section.
Google keeps the hardware secret of its products a secret. We know that Google File System (GFS) runs on a large number of off-the-shelf, low-cost Linux servers. We’re not talking custom supercomputers here. Standard stackable rack boxes.
However, the company has released some specifications for older benchmarks. These do not fully match today’s infrastructure. However, we can clearly point to common devices that use one of the world’s largest data storage systems.
Technical data of the test bench
Testing a cluster is easy. main server. There are two copies of the master. There are 16 clients. 16 chunk servers.
All machines in the series have exactly the same hardware profile. Two 1.4 GHz Pentium III processors. 2GB of RAM. Each has two 80GB hard drives. Everyone uses Linux.
Tired of looking at that technical information? You shouldn’t. This is ancient history from the days of processors. Modern consumer computers of the last decade have eliminated these numbers. Google has proven an important point: you don’t need the most advanced chips to run GFS. Even things that most people think of as junk work effectively.
Network topology
The plumbing of these machines is equally simple. The entire cluster is on a 100 Mbps full-duplex Ethernet network.
Uses two Hewlett Packard 2524 switches. The layout is special:
*One switch can handle 16 client computers.
* The second switch uses a master server and 16 chunk servers.
The switches communicate with each other via a 1 Gbps link. Backbone connections avoid bottlenecks that block the entire system.
Why cheap hardware works
Why go this way? Because being slightly behind in hardware development can be a strategic advantage. Buy components at a discounted price. You can save even more when you buy in bulk.
GFS is designed to scale horizontally. This structure allows Google to connect cheaper boxes when the cluster is full. Add more nodes if the system becomes heavy. They balance the workload. It is elastic.
Vertical scaling is also an option if needed. If the main server runs out of memory, that box will have more RAM. This system can be adapted without a complete overhaul.
Human factors
Did Google stumble upon this architecture? Or computationally?
Part of it is talent. Google hires computer science graduates straight out of school. It gives them space. resource. Freedom to build a system like GFS from scratch.
This is also a state of mind. The philosophy of “doing more with less” often defines the engineers who build these things.
After all, the use of this type of hardware corresponds to Google’s core mission of organizing the world’s data. The system is designed to handle large unstructured data processes. The hardware is just a container.
Bandwidth and Latency
When building for scale, metrics matter. Two terms come up constantly: bandwidth and latency.
Bandwidth is capacity. How much data can travel from point A to point B in a given timeframe? Think of it as the width of a highway.
Latency is the delay. The time between sending a command and receiving a response. Think of it as traffic lights or congestion.
Most system administrators want high bandwidth and low latency. The holy grail.
谷歌的开发人员优先考虑带宽。 他们的应用程序操作巨大的文件。 他们需要快速移动数 TB 的数据。 延迟是次要的。 如果管道足够宽,延迟就不会造成太大影响。