Take a Break
5:00
Inhale…
Give your mind a break — no phone, no music, just idle time or a quick walk.
Hadoop, In-Memory Computing, Cloud, and Fault Tolerance
Big data analytics is not a volume game — velocity and variety matter as much as volume — and big data system technologies do not make relational databases (RDBMS) and data warehousing obsolete; they coexist with them. This unit covers the popular technologies used to build big data systems: Hadoop for storage and batch processing, in-memory computing (Spark) for speed, and the cloud for flexible infrastructure. It then moves to the hard part of running many machines at once: living with failures. That means reliability and availability metrics, fault-tolerant configurations, recovery strategies, and finally the CAP theorem, which states the fundamental trade-offs every distributed system must make.
1.1 Hadoop — Storage and Processing for Big Data
Correction — big data is not a volume game. It is tempting to think that "big data" simply means a lot of data, and that more bytes is always the point. The reality taught at the start of this module is different: velocity (how fast data arrives) and variety (how many different shapes data takes) matter just as much as volume (how much data there is). A stock exchange streaming millions of trades per second is hard because of velocity; a pile of free-form emails, sensor logs, and videos is hard because of variety. When you design a big data system, all three of these — volume, velocity, variety — are part of the problem.
Correction — big data does not replace the RDBMS. Another common assumption is that Hadoop and its relatives make relational databases (RDBMS) and data warehousing obsolete. They do not. The two worlds coexist: RDBMS systems stay as the backbone for operational, day-to-day business transactions (OLTP), and big data systems handle the huge, messy, analytics-oriented workloads. Each technology is good at what it was built for, and real enterprises run both side by side.
This unit covers the popular technologies used to build big data systems: Hadoop for storage and batch processing, in-memory computing (Spark) for speed, and the cloud for flexible infrastructure. It then moves to the hard part of running many machines at once: living with failures. That means reliability and availability metrics, fault-tolerant configurations, recovery strategies, and finally the CAP theorem, which states the fundamental trade-offs every distributed system must make.
1.1.1 The Problem Hadoop Solves
Organizations across the globe now realize there is a huge amount of untapped information locked in semi-structured and unstructured data. Three kinds of data show up in the wild:
- Structured data fits neatly into rows and columns — think of a bank ledger or an order table. Traditional RDBMS solutions already handled this well.
- Semi-structured data has some structure, but not a fixed one — JSON documents, XML files, and emails each have tags and fields, but no two records need the same fields.
- Unstructured data has no organization at all — free-form text, images, audio, and video.
The scale is hard to picture. A single stock exchange generates on the order of terabytes of trade data per day; large online platforms store hundreds of billions of photos; sensor networks, bank transactions, and retail logs add more every second. When terabytes pile up to petabytes, organizations see an opportunity: reveal something hidden inside that semi-structured and unstructured data. The sources are everywhere — stock exchanges, online retail stores such as Amazon and Facebook, banking transactions, sensor data, and many more.
The challenge with all this data is twofold: store this huge volume and variety, and process it. RDBMS systems are not built for every purpose; at the scale data is growing, there are performance challenges. This is where Hadoop comes in. Hadoop solves two problems:
Hadoop answers two questions.
- Storage: it stores huge amounts of data of any type — structured, semi-structured, and unstructured; it can store images and videos too.
- Processing: it processes that data through a distributed processing model — multiple nodes, each doing part of the task at the same time, exploiting parallel processing to achieve performance.
Storage without processing is a dead archive; processing without storage is impossible at this scale. Hadoop gives you both, and the two answers are designed to work together.
Why not just buy one enormous machine? Because a single computer has a single disk arm and a single processor. Reading a whole large dataset from one disk takes hours, and running one huge job through one processor — including all its I/O — becomes a bottleneck at some point. The distributed trick is to cut the work into pieces and spread it over many ordinary machines at once.
1.1.2 Hadoop's Answers to the Multi-Node Challenges
Spreading data over many machines creates three new problems, and Hadoop answers each of them directly:
| Problem of running many nodes | Hadoop's answer |
|---|---|
| Failures. The more components a system has, the more chances of failure, because each individual component can fail. | Replication. Data is stored in multiple copies, with a replication factor of three, to safeguard against system failures. Lose one machine and the copies on the others still serve the data. |
| Cost. Multiple nodes can make the system expensive if each node is a high-end server. | Commodity hardware. Adding nodes using relatively inexpensive commodity machines cuts cost down. Buy many cheap machines instead of one expensive one. |
| Arbitrary data. The data may be binary, structured, or unstructured — no single format fits all. | Multiple file formats. Hadoop supports different file formats that suit storing different kinds of data. |
Think of it like a fleet of delivery vans. One giant truck (a single high-end server) is expensive, and if it breaks, everything stops. A fleet of ordinary vans (commodity machines) is cheaper, and if one van breaks, the others carry on because each package is copied three times across the fleet (replication factor of three). The analogy breaks in one place: more vans also mean more vans that can break — which is exactly why replication is non-negotiable rather than a nice-to-have.
Processing is where the classic single-processor bottleneck appears: if you give a huge job to one processor, including all its I/O, that processor becomes a bottleneck at some point. The MapReduce framework that Hadoop provides works around this: you divide your data into multiple chunks, give each chunk to a map task to run on, and finally gather the results from each processing node and produce the final result with a reduce task. So both problems — storage and processing — are efficiently solved by Hadoop.
A concrete sense of the speedup: reading one full disk takes hours; reading the same data spread across many disks, all read in parallel, takes minutes. The entire design of Hadoop — replicate for safety, spread for speed — rests on that simple observation.
1.1.3 Hadoop versus Distributed Relational Databases: The Data Model
A distributed database built from RDBMS technology stores data in a relational model: data lives in tables (called relations in relational-model terminology), and tables are linked by primary keys and foreign keys, creating related data across tables. Distributed databases also support partitioning — fragmenting a table. There are two kinds:
- Horizontal fragmentation divides a table's records: records satisfying a particular fragmentation condition go in one part, and records that do not satisfy it go in another. You are dividing the set of records into two subsets. For example, a students table could be split by branch: records for Computer Science students in one fragment, records for Mechanical students in another.
- Vertical fragmentation takes a subset of attributes (columns) into one part and another subset of attributes into another. With vertical fragmentation you need a common attribute shared between the fragments, because joining on that common attribute reconstructs your original relation. For example, split a student table into name-and-ID in one fragment and ID-and-grades in another — the ID column is the shared key that lets you rejoin.
Relational systems also build indexes — B+ tree indexes are typical on RDBMS systems — to make fast search and optimized performance possible. All of this happens at the schema level: before you store anything, you decide the structure, the keys, the indexes, and the constraints.
Hadoop's data model is the opposite:
Schema-on-read versus schema-on-write. The relational model is schema-on-write: you define the structure before data is stored, and every record must fit it. Hadoop is schema-free: there are no tables and no notion of a predefined schema. The input is flat files, and you divide your data into multiple partitions, which are termed file blocks or HDFS blocks, and give a portion of the data to each node for computation. The whole file can be very large — Hadoop exists to deal with large data sets.
Because there is no predefined schema, a flexible schema has to work: a rigid schema where every record must follow the same set of attributes will not work here, because each record may have a different set of attributes. That is what makes Hadoop comfortable with semi-structured and unstructured data. You can decide what the structure means only when you read the data — so it is called "schema-on-read."
A side-by-side comparison on the dimensions that differ:
| Dimension | Distributed RDBMS | Hadoop |
|---|---|---|
| Data model | Tables (relations), primary/foreign keys | Flat files split into HDFS blocks |
| Schema | Fixed in advance (schema-on-write) | Flexible, decided at read time (schema-on-read) |
| Structure of records | Every record has the same attributes | Records can differ freely |
| Indexes | B+ tree indexes for fast search | None at the storage layer; scans are the norm |
| Fragmentation | Horizontal and vertical, with shared keys to rejoin | Blocks distributed arbitrarily across nodes |
| Comfort zone | Structured, operational data | Semi-structured and unstructured data at huge scale |
When to pick which: if your data is clean, fixed-shape, and transactional, an RDBMS with indexes wins. If your data is huge and messy, Hadoop wins. This is why the two coexist instead of one replacing the other.
1.1.4 The Compute Model of Relational Databases: Transactions and ACID
On the relational side, processing works on the notion of transactions. A transaction is the smallest unit that should be processed in its entirety or not at all. A transaction may consist of multiple operations — five or six, or more. Debiting my account and crediting somebody else's account is one form of transaction: those two operations cannot be divided so that one is done and the other undone. That is the atomicity property of a transaction: either you perform all operations or you do not perform even one.
Relational systems follow ACID semantics — atomicity, consistency, isolation, durability:
The four ACID properties, in plain words:
- Atomicity — a transaction must be done in its entirety, or not at all; half-done transactions are not acceptable. Think of money transfer: debit without the matching credit would destroy the account.
- Consistency — executing an operation takes the database from one consistent state to another consistent state, meaning the result satisfies all the constraints on the database (keys, foreign keys, check constraints, balances that must not go negative).
- Isolation — multiple transactions may run at the same time, but each transaction is given the feeling that it is the only transaction running in the system; its execution must not interfere with other transactions. It is like two people editing a shared document where each sees a clean copy and the merge happens safely.
- Durability — once a transaction is complete and its changes are applied to the database, there is no way to undo those changes; the changes made by the transaction are persistent, even across a crash.
When relational databases are hosted on distributed systems, they also allow distributed transactions — there is coordination among the different systems, and they can globally commit a particular transaction when a single transaction is running across multiple nodes: every participating node agrees to commit together, or the whole transaction is abandoned. This model is quite suitable for OLTP workloads (online transaction processing), the workloads used to carry out day-to-day business transactions. A transaction may consist of insert, delete, update operations; once it is complete it has to commit. Committing means all operations have been performed and the changes are now permanent — the transaction cannot be rolled back at any stage. If anything happens partway through, a half-done transaction must be undone: a recovery subsystem performs the undo of that half-done transaction.
Pitfall — assuming the transaction model carries over. A student new to big data systems often expects Hadoop to support transactions and rollback the way an RDBMS does. It does not, and that is by design: enforcing ACID across thousands of nodes is expensive and slows processing. The two worlds use different compute models because they serve different workloads. When you move to Hadoop, you stop thinking in transactions and start thinking in jobs, tasks, and key–value pairs.
1.1.5 Hadoop's Compute Model: Jobs, Tasks, and MapReduce
Hadoop has no notion of a transaction; it has the notion of a job. A job is further divided into tasks, and each task runs at a different node. The compute model is the MapReduce model: every task is either a map task or a reduce task.
The data is given to the nodes, map tasks perform certain computations, and after computing, each map task passes results to the reduce task. The reduce task can live on the same node as a map task or on a separate node, but since map tasks run first, all map tasks complete their jobs before the reducer gathers the results. The reducer performs its own computations to produce the final result, whatever is required.
The two-step division of labor:
- Map tasks take their chunk of the input, apply a user-written map function to every piece of it, and emit intermediate key–value pairs. Maps run in parallel, one per chunk, across all nodes.
- Reduce tasks gather all intermediate pairs, group them by key, and apply a user-written reduce function to each group, producing the final results.
The map side spreads the work; the reduce side merges the results. Between the two lies the hand-off where all output from all maps is collected for the reducers.
The name is a memory aid: "map" transforms each input item into output items, and "reduce" condenses many items with the same key into fewer items.
1.1.6 High-Level Hadoop Architecture
At a high level, a Hadoop cluster consists of a master node and slave nodes. The master node has a compute part and a management part.
- The compute part is the job tracker, which keeps track of a job submitted to the Hadoop cluster.
- Each node also has a task tracker, because each node does something — it holds certain data and performs map and reduce operations. Each task tracker communicates with the job tracker for coordination and for the status of the job.
- On the storage side, data is partitioned into files on data nodes, and the name node is the filesystem management node — a special node under the master that takes care of dividing the data into HDFS blocks.
So the architecture has two layers: the HDFS layer (storage, where data nodes keep the data) and the MapReduce layer (computation). One more important property is locality of reference: the data a node operates on sits in its local vicinity, so compute is close to the data, which helps achieve performance. Moving computation to the data is far cheaper than moving petabytes of data to the computation.
Visualizing the cluster: picture one master node at the top with two halves — the job tracker (scheduling and tracking jobs) and the name node (managing the file namespace and block placement). Beneath it sit the slave nodes, each with three things: a task tracker (executing map and reduce tasks), a data node (storing a share of the HDFS blocks), and its own local disk. A job flows top-down: it enters through the job tracker, which divides it into tasks and schedules them onto task trackers — preferably onto the node whose disk already holds the relevant data block (that is locality of reference in action). The name node simply answers "which node holds which blocks," so the scheduler can match tasks to data. Takeaway: two independent layers, one for storage and one for computation, coordinated by two master-side managers.
1.1.7 Worked Example: Word Count with MapReduce
The classic word count problem shows how a MapReduce program runs. First, state the objective: given input data of sentences, count the occurrence of each unique word.
The input. The input data here has two sentences: "hello world by world" and "hello hadoop goodbye hadoop". (Note on the source text: the first sentence is the version that matches the final counts — "world" must appear twice in the first sentence to reach the total of two, so the sentence is "hello world by world", not a different reading.)
Worked example — word count on two sentences.
Step 1 — Divide the data. Give each sentence to one map task.
Step 2 — Map phase. A map task does not produce the whole result — it iterates over its chunk and emits key–value pairs, one per word occurrence:
- Map task 1 on "hello world by world" emits (hello, 1), (world, 1), (by, 1), (world, 1).
- Map task 2 on "hello hadoop goodbye hadoop" emits (hello, 1), (hadoop, 1), (goodbye, 1), (hadoop, 1).
Step 3 — Shuffle and sort. The output of the map tasks is given to the reduce task, which groups and orders it. Shuffling groups all values for the same key; sorting puts the keys in order:
by → [1] | goodbye → [1] | hadoop → [1, 1] | hello → [1, 1] | world → [1, 1]
Step 4 — Reduce phase. The reducer sums the counts for each key. Because hello appeared once in each sentence, its count increments to two; hadoop also appears twice; world appears twice; by and goodbye appear once each.
Final output (bolded): by → 1, goodbye → 1, hadoop → 2, hello → 2, world → 2.
Sense-check: five unique words, eight total occurrences, and the two repeated words each get count 2 — the totals add up, so the answer is consistent with the input.
Notice one detail that trips many beginners: even though a word appears twice within one sentence, the map task does not aggregate — it generates a separate key–value pair for each occurrence. Aggregation is not the map task's job; the reducer owns aggregation. This separation is what lets maps run in complete isolation and still produce correct combined answers.
The code shown for this has two pieces. The map function tokenizes the input string — it splits on spaces and, while tokens remain, emits (word, 1) key–value pairs. The reduce function sums the values for each key. This is not a full-fledged program, just the map and reduce functions:
def map(sentence): # one call per sentence
for word in sentence.split(" "): # split on spaces
emit(word, 1) # one pair per occurrence
def reduce(key, values): # one call per word
emit(key, sum(values)) # sum the counts
For any problem, the skill being tested is: understand how the data is divided, what the map task should do, and what the reduce task should do. Parallelization, data division, and orchestration are provided by the platform — you only write the map code and the reduce code. The implementation can be in Java or Python; Python is preferred for the labs, since lab exercises run in Python.
Q: How is the data shared among the map and reduce tasks, and where does the shuffling happen? A: These questions were held for the MapReduce lab session, where the framework internals — data sharing between map and reduce tasks, and the shuffle stage — will be shown hands-on. The plan for the lab: run a real word count job and watch where each key's values meet.
Exam note: MapReduce is practiced in a lab session, and the labs run in Python. Be able to look at any problem and decide what code belongs in the map task and what belongs in the reduce task: the map decides how to split and emit, the reduce decides how to merge per key.
1.1.8 Advantages of Hadoop
- Low cost. The technologies are open source, and Hadoop runs on low-cost commodity hardware, which is relatively cheaper than buying high-end servers.
- Computing power. Hadoop is based on a distributed computing model that can process very large amounts of data fairly quickly, because it is a cluster of nodes, not a single machine — the more nodes, the more processing power at hand.
- Scalability. Hadoop follows horizontal scalability. To increase computing power, add a node; to increase storage, add storage. There is no need to upgrade to high-end servers — just add commodity hardware. Vertical scaling (buying a bigger machine) hits a ceiling; horizontal scaling (adding more machines) does not.
- Storage flexibility. It helps store structured, semi-structured, and unstructured data, not only structured data like a traditional RDBMS.
- Inherent data protection. With replication, data is replicated on multiple nodes. If a node fails, the task is given to the node where the replica exists, or to any other node with enough capacity to do the job. The system does not go down with one or two failures — as long as replication is taken care of.
1.1.9 The Hadoop Ecosystem
An ecosystem here means the comprehensive set of technologies you can combine, effectively and cost-effectively, to provide big data solutions. The two core components are HDFS — the storage layer, which helps store different kinds of data and large data sets — and MapReduce — parallel processing. These two are good to start with, but sometimes they are not enough for very large-scale data sets, or for application requirements such as real-time processing. More tools fill those gaps.
To do anything with data, you first bring it into HDFS; only then can you compute on it. The ecosystem is best read as layers of jobs:
| Layer / job | Tools |
|---|---|
| Data ingestion (into HDFS) | Sqoop for structured data (e.g., from a database), Flume for unstructured and semi-structured data (e.g., log streams) |
| Resource management | YARN — the resource management layer that allocates resources across the cluster |
| Compute (on top of YARN) | MapReduce programs, Apache Spark (in-memory computing), Hive (SQL-like analytics), Pig (SQL-like commands for non-programmers) |
| Machine learning | Spark MLlib and Mahout |
| Specialized stores | NoSQL databases (HBase, Cassandra, MongoDB) for different purposes |
| Operations | Oozie for scheduling jobs; ZooKeeper and Apache Ambari to coordinate among the different technologies used to build the big data system |
Two tools deserve a closer look because they target very different users. Hive lets you do analytics through an SQL-like interface — you write Hive queries and do analytics, so database-minded users feel at home. Pig serves people from non-programming backgrounds: it gives SQL-like commands for writing jobs, so you can write ten lines of Pig (in its language, Pig Latin) that do the work of roughly a hundred lines of a MapReduce program. MapReduce itself remains available for writing programs in different languages when you need full control.
Pitfall — treating the ecosystem as optional. Some beginners stop at HDFS plus MapReduce and assume that is "Hadoop." In practice, real deployments use the wider stack: ingestion tools to get data in, YARN to share resources, Hive or Pig to write analytics quickly, Oozie to schedule, and ZooKeeper to keep the pieces coordinated. The core two are the heart, but the surrounding tools are what make the system usable in industry.
Recap and bridge. Hadoop gives you two things: a storage layer (HDFS) that tolerates failure through replication and accepts any data shape, and a compute layer (MapReduce) that splits every job into map tasks and reduce tasks across many commodity machines. That model is perfect for batch work — but as the next section shows, it stumbles exactly where modern workloads need speed: low-latency and iterative processing. That gap is why Spark exists.
1.2 In-Memory Computing with Spark
1.2.1 Where MapReduce Falls Short
MapReduce gave a big boost to big data processing: it lets you store and process huge amounts of data at very low cost, using commodity hardware, interconnected processing nodes, and distributed systems. It is an ideal platform for certain complex batch applications — going through system logs to identify patterns, running ETL tasks (extraction, transformation, loading), computing web indexes, and building recommendation systems. These are cases of standalone data that needs certain processing: the job is well defined, the data is scanned once or twice, and nobody is waiting at a terminal for the answer.
What makes MapReduce unsuitable for other applications is its reliance on persistent storage for fault tolerance and its one-pass computation model — together these make it a poor fit for low-latency applications. MapReduce reads files from the hard drive and stores results back to the hard drive; reading and writing persistent storage is time-consuming, and with the very large data sets that big data systems deal with, disk reads and writes increase latency. Every intermediate result is flushed to disk, every map output is written before the reducer can read it — safe, but slow. So MapReduce is not the right fit for real-time analysis, nor for iterative computations — something done and then repeated. Many machine learning algorithms run many iterations to train a model, so MapReduce is typically not suited for those iterative applications either.
Where the batch model breaks:
- Real-time analysis — a dashboard or a fraud check that must answer in seconds cannot wait for a batch cycle that reads and writes disk at every step.
- Iterative algorithms — each training iteration of a machine learning algorithm reads the same data again; with MapReduce, every iteration pays the full disk round trip. Ten iterations, ten full re-reads of a large dataset.
1.2.2 The In-Memory Idea: Memory Instead of Disk
In-memory computing stores the data in RAM rather than on the hard drive: you read the data from RAM and write the data back to RAM. Hadoop's pattern is a loop of permanent storage round trips — input taken from HDFS, processed, stored back to permanent storage, read again, and so on. In-memory computing speeds up processing by using memory instead of disk: you first read the file, and once it is processed you keep it in a distributed RAM rather than storing it away.
Why memory wins. Accessing RAM is fast compared with accessing a spinning disk — roughly almost 5000 times faster. For a working data set that is touched many times, keeping it in RAM turns each later access from a disk read (milliseconds) into a memory read (microseconds). What in-memory computing does is replace the intermediate hard-drive storage with memory.
That is not trivial: you need middleware software to manage it. Spark is exactly that middleware — it allows data to be stored in RAM across the cluster of computers and processed in parallel.
Think of it like a chef's mise en place. A batch kitchen (MapReduce) fetches every ingredient from the cold store for every dish: correct, but each trip takes time. A restaurant with a prep station (Spark) pulls the ingredients once, keeps them on the counter (RAM), and every dish after that touches the counter, not the store. The analogy breaks in one place: the counter is expensive and limited — if you keep everything in RAM, you may run out of space, which is why in-memory computing can need more memory.
1.2.3 Spark's Programming Model
Hadoop typically provides map tasks and reduce tasks, and each task is either a map task or a reduce task. Spark instead provides a programming model that lets developers write applications by composing many operators — mappers, reducers, joins, groupBys, filters, and more. The operator set is not limited to mappers and reducers.
Composition instead of a fixed two-step shape. In MapReduce you express everything as map followed by reduce. In Spark you chain operators: filter, map, groupBy, join, reduceByKey, and more, in any order, as many as the problem needs. This composition makes it easy to express a wide array of computations, including iterative machine learning, streaming, complex queries, and batch processing of the kind you would do with the Hadoop MapReduce model.
Spark keeps track of the data that each operator produces and enables the application to reliably store this data; this is the key to Spark's performance, because it lets the application avoid costly disk accesses. An intermediary layer takes care of all of this — as an end user you do not manage it — but it may need more memory.
1.2.4 Worked Example: Word Count in Spark
The same word count problem looks very different in Spark: a small piece of code.
Worked example — word count in Spark.
Step 1 — Read. You read the data from multiple sources, including HDFS.
Step 2 — Split into lines. A map step converts the input into lines (one line per record).
Step 3 — Emit pairs. Another map generates the key–value pairs (word, 1) for every word.
Step 4 — Sum per key. A reduceByKey sums the values for each word — this is a single operator that does what the whole reduce side of MapReduce did, and it can combine partial sums early to cut network traffic.
Step 5 — Export. Once the computation in memory is done, you can export the result to permanent storage, HDFS again.
The whole computation looks like a short pipeline:
lines = read("hdfs://...") # read input
words = lines.flatMap(split) # one line -> many words
pairs = words.map(w -> (w, 1)) # each word -> (word, 1)
counts = pairs.reduceByKey(sum) # sum counts per word
counts.save("hdfs://.../result") # write back to permanent storage
Sense-check: the same answer as the MapReduce version — each word's count — produced with a few composed operators instead of hand-written map and reduce functions.
The point of the example is that rather than writing complex map and reduce functions, these simple lines do a lot of work. Spark provides a rich set of primitives on top of the MapReduce model to make programming easier — otherwise you write long lines of code in Java. In-memory computing may involve a higher cost, but it makes Spark suitable for low-latency computations and efficient iterative algorithms.
1.2.5 Low Latency and Iterative Algorithms
With a working data set cached in memory, low-latency applications run computations at memory speeds: input is read and processed once, stored on the distributed memory, and every subsequent computation touches the memory instead of the disk. For iterative applications, the data is read from the hard drive once, an iteration is done and the result stored in distributed memory, then another iteration runs against memory, then another — and only after everything is computed is the result stored back to permanent storage.
Trace — three iterations of a training loop.
- Iteration 1: read the data from disk once, compute, write the result to distributed memory.
- Iterations 2 and 3: read from memory, compute, write back to memory — no disk at all.
- Done: write the final model once to permanent storage.
The first read pays the disk cost; every later step runs at memory speed. In MapReduce, by contrast, each iteration would re-read the full data from disk. This is how Spark runs the two kinds of applications where Hadoop clusters were not suitable. In-memory computing gets its own detailed module later in the course.
1.2.6 Student Questions and Answers
Q: Spark needs a big memory — won't it be commodity hardware? A: Spark sits on top of distributed computing, so multiple nodes are involved and each node has its own RAM. Syncing the RAMs and the data flow between them is handled by the intermediary layer. The combination of those RAMs gives you a larger total RAM size. You are not buying one enormous machine; you are pooling many ordinary machines' RAM into one logical memory.
Q: If an in-memory process crashes, does everything have to be done again from the beginning? A: There are ways to deal with failures — the system consists of multiple nodes, so one node may fail and others continue. You cannot say all nodes will fail at the same time; many nodes may fail, but not all of them. Losing one node's memory does not mean redoing the whole job. Reliability and availability are exactly the topics coming next.
Recap and bridge. MapReduce is safe and cheap but slow for repeated work, because every step touches disk. Spark keeps working data in distributed RAM across commodity nodes, exposes a rich operator set, and so serves low-latency and iterative workloads that MapReduce cannot. One question from the crash discussion remains open: how do we measure and build systems that keep working when nodes fail? That is the reliability-and-availability topic that comes next.
1.3 Cloud Computing for Big Data
1.3.1 Why the Cloud
Organizations dealing with big data face the problem of storage and management, and owning the needed technologies and infrastructure is expensive: high-end servers and software have to be purchased. Then resources are hard to size. As the application scales, you may need more resources than you bought, so resources become over-utilized and application performance bottlenecks. Or you overbuy, and resources sit under-utilized.
The sizing trap. Buying infrastructure forces you to guess the future. Guess too low, and your application slows at the moment of peak demand; guess too high, and you paid for machines that sit idle. Either way, money and performance are lost. The cloud's core idea is to stop guessing: take resources when you need them and release them when you do not.
The cloud answers both problems: a flexible way of allocating infrastructure, paying for services as you use them. The cloud lowers infrastructure cost, runs infrastructure more efficiently, and lets your business scale — upscale and downscale as needed. Managing infrastructure in-house is a complex overhead; nowadays everything is on the cloud.
1.3.2 The NIST Definition
The formal definition (from NIST, the U.S. standards body) is: a model for enabling convenient, on-demand network access to a shared pool of configurable computing resources — networks, servers, storage, applications, and services — that can be rapidly provisioned and released with minimal management effort or service provider interaction.
The definition unpacked. Four ideas hide in that sentence:
- On-demand — you ask for resources yourself, without waiting for a salesperson or a help desk.
- Shared pool — many customers draw from the same set of hardware, which is why costs stay low.
- Configurable — you choose sizes, types, and amounts of resources.
- Rapidly provisioned and released — you can add resources quickly and give them back quickly, with minimal management effort or service provider interaction.
In simpler terms: it is a delivery of computing services — network, servers, storage, applications, and services — over the internet, offering flexible resource use and economies of scale. You scale up by adding resources and pay for what you use.
1.3.3 The 3-4-5 Rule
Cloud computing is organized by the 3-4-5 rule: three cloud service models, four deployment models, and five essential characteristics. All three parts are covered below. Keep the rule as a mental index: the five characteristics say what makes something cloud-like, the four deployment models say who owns and who may use it, and the three service models say how much of the stack is given to you.
1.3.4 The Five Essential Characteristics
- On-demand self-service. Users can consume resources or computing capabilities for applications as and when needed, without much interaction with the service provider. Providers in this market include AWS, GCP (Google Cloud Platform), Azure, Rackspace, and others.
- Broad network access. Resources are available over standard network connections, from all commonly used machines such as laptops and PCs.
- Resource pooling. All consumers share resources from a common pool, assigned to them depending on demand, consumption, and usage. The pool may be scattered across different geographical locations.
- Rapid elasticity. Scaling must be elastic both upward and downward, seamless, and proportional — need more, add; need less, remove. Pay per use.
- Measured service. A pay-per-use model with transparency between provider and user: services are controlled, optimized, monitored, and reported frequently.
Pitfall — confusing elasticity with unlimited resources. Rapid elasticity means the resource level responds to demand; it does not mean resources are free or infinite. You still pay per use, and the meter runs on what you actually consume — that is the measured-service characteristic. An elastic cloud without metering would be a budget surprise.
1.3.5 The Four Deployment Models
- Public cloud. Cloud service vendors manage a public cloud; each customer can take computing resources from it. It is a mega-scale cloud infrastructure made available to the general public or a large industry group, owned by the organization selling the cloud services. Examples include AWS.
- Private cloud. Set up for one particular organization only. It may sit inside the organization or outside it; it may be managed by the organization itself or by a third party with cloud expertise. Resources are not shared among different organizations; users of the same organization access it. Scaling still happens — you add resources to your private cloud as the application grows, and those resources are not shared with others; with a vendor managing it, you can include resources on the fly by paying, so scalability is not as tough as with infrastructure you own. For the private cloud, you are charged for the resources you occupy.
- Hybrid cloud. A combination of two or more clouds, such as private and public, as unique entities bound together. Standardized technologies are needed, because applications must be portable between them. A typical scenario: an organization's private cloud reaches capacity and cannot serve more requests, so part of the application moves to a public cloud rather than buying further infrastructure or setting up another private cloud.
- Community cloud. Built for a set of organizations that share common concerns — security requirements, policy, compliance. Government organizations, for example, may share a community cloud. It may be managed by the organizations themselves or by a third party, and may exist on-premise or off-premise.
1.3.6 The Three Service Models
- Infrastructure as a Service (IaaS). You take storage, network capacity, and computing resources. AWS provides a whole lot of infrastructure of this kind. You manage the operating system and everything above it; the provider manages the hardware.
- Platform as a Service (PaaS). An operating system and certain resources come with the infrastructure, and you can execute your code and deploy your applications on it; middleware services may be included. It supports software development as well as deployment — a platform you can use directly from the cloud. You bring your code; the provider manages the platform underneath.
- Software as a Service (SaaS). A software package is hosted in the cloud and can be accessed from anywhere; customers do not purchase the software or install it on their devices — they use it directly from the cloud. Salesforce CRM (customer relationship management) is a practical example of the SaaS model.
The three service models as layers of a stack. IaaS gives you hardware, PaaS gives you hardware plus a platform, SaaS gives you a finished product. Moving up the stack, you manage less but control less: from raw machines (IaaS), to a ready platform for your code (PaaS), to a ready application for your users (SaaS).
1.3.7 Cloud Services for Big Data
Each service model maps onto big data needs. As infrastructure, the cloud provides ample storage and computing power: AWS offers S3 — S3 buckets used to store large amounts of data — and EC2 instances for compute. As a platform, vendors offer platforms ready with Hadoop and MapReduce installed: you just write your mappers and reducers, bring the data into the cluster, and do your processing. AWS Elastic MapReduce provides exactly that, saving you the hassle of installing and managing these environments (installing Hadoop is not easy on a Windows machine). As software, SaaS is a great help for organizations that need specialized software for big data — social media analytics, feedback monitoring: the vendor provides an out-of-the-box solution for such common use cases.
| Service model | Big data example |
|---|---|
| IaaS | S3 buckets for raw data storage, EC2 instances for compute |
| PaaS | Elastic MapReduce — a Hadoop + MapReduce cluster ready to run your jobs |
| SaaS | Out-of-the-box social media analytics and feedback monitoring tools |
1.3.8 Cloud Market Leaders
Amazon is the most popular cloud vendor for big data: Amazon Web Services offers EC2 instances, MapReduce, DynamoDB (quite popular), S3 buckets, high-performance computing, and Redshift, software used to boost data warehouses. Google Cloud Platform offers Compute Engine, BigQuery, and the Prediction API. Microsoft gives Windows Azure — a cloud based on Windows — with SQL Azure and HDInsight. AWS is the most popular, and Azure and GCP are also growing; these are the three market leaders.
1.3.9 Student Questions and Answers
Q: In a private cloud, resources are not shared, so why do we call it a cloud? And how does scaling happen in a private cloud? A: The definition says a shared pool of resources, but the sharing is among the users of one organization, not among different organizations. A public cloud is itself a shared pool of resources among different organizations; a private cloud is not shared that way — the same set of different users from the same organization have access to it. Scaling works like this: cloud vendors help set up the private cloud, and when the application grows you figure out how much computation is being done and add certain resources to your private cloud. Those added resources are not shared by other organizations. You can include them on the fly by paying, so the scalability effort is not as tough as building your own infrastructure. For whatever resources you have occupied, you are likely to be billed.
A follow-up asked about the charging basis and payment policy for a private cloud — since it is private rather than public, there may not be a common payment policy; the answer was noted for verification and is to be reverted to on the discussion forum or in the next class.
Recap and bridge. The cloud removes the sizing guess by offering elastic, pay-per-use resources through the 3-4-5 rule: five characteristics (on-demand, broad network access, resource pooling, rapid elasticity, measured service), four deployment models (public, private, hybrid, community), and three service models (IaaS, PaaS, SaaS). For big data, the cloud delivers infrastructure (S3, EC2), platforms (Elastic MapReduce), and software alike. Infrastructure, however, is only half the story of reliability — the next section turns to what happens when the machines themselves fail.
1.4 Reliability and Availability
1.4.1 Living with Failures
Every system is prone to failures. A distributed system is composed of multiple nodes connected through an interconnection network, so, like any other system, its nodes may fail and the interconnections may also fail. Failure of nodes and links is a very common concern in distributed systems, so fault tolerance must be a core part of the design. Fault tolerance is a measure of how a distributed system functions in the presence of failures. A distributed system consists of multiple components; if one component fails, the system may fail. How the system reacts to failures is measured by two parameters: reliability and availability.
Hook — the question every distributed system must answer. If you run a thousand machines, machines will fail — not "might," but will. The design question is not "how do we prevent failures?" but "how well does the system keep working while failures happen?" Reliability and availability are the two numbers that answer that question, and the rest of this section builds the formulas behind them.
1.4.2 Reliability and Availability
Reliability is the inverse indicator of the failure rate: how soon a system will fail. If the failure rate is high, reliability is low; if the failure rate is low, reliability is high. Availability is the percentage or fraction of the time the system is available for use: the system is not available during failures.
The two numbers measure different things.
- Reliability asks how long until it breaks — it is about time to failure.
- Availability asks how much of the time is it usable — it is about uptime as a fraction of total time.
In simpler terms, when the system is running we call that uptime. Availability is the uptime divided by the total time, where total time consists of uptime and downtime. To increase availability, minimize downtime. High availability is what we want — and the metrics below show how to measure and achieve it.
1.4.3 Mean Time to Failure (MTTF)
MTTF, mean time to failure, is the amount of time on average that a component can run before it breaks. It is an averaged value: you observe a component over several failure instances, note the times at which it fails, and average them. MTTF relates to the failure rate \(\lambda\) (lambda, how often failures occur per unit time) by:
\[ MTTF = \frac{1}{\lambda} \]
Equivalently, the failure rate is the inverse: \(\lambda = \frac{1}{MTTF}\). MTTF can also be computed as the total operating time across all units divided by the total number of units — the same average, seen from the other side.
The age caveat — failure rate is not constant in real life. The formula \(MTTF = \frac{1}{\lambda}\) assumes the failure rate \(\lambda\) stays the same. In reality, the failure rate may change over time because it depends on the age of the component. A new vehicle gives no problems for two or three years; after that, frequent problems appear — sometimes the braking mechanism is not working, sometimes the wheel alignment gives trouble. As age increases, the chances of failure increase and MTTF decreases. So MTTF is best treated as a planning number, not a law of nature.
1.4.4 Worked Example: MTTF of Five CFLs
Worked example — mean time to failure of five CFL bulbs.
Take five CFL bulbs, named CF1 through CF5, and measure how long each lasts. Say the lifetimes are 120 days, 160 days, 130 days, 140 days, and 145 days. The mean time to failure is the average of these five observations:
\[ MTTF = \frac{120 + 160 + 130 + 140 + 145}{5} = \frac{695}{5} = \textbf{139 days} \]
So on average, one of these bulbs runs 139 days before it fails.
Sense-check: 139 sits comfortably between the smallest observation (120) and the largest (160), close to the middle of the five values — a sensible average. The example shows the general procedure: take several observations of when the component fails, sum them, divide by the number of observations.
1.4.5 MTTD, MTTR, and MTBF
Three more metrics complete the failure story. MTTD, mean time to diagnose, is the time taken to detect which component has failed once something goes wrong. It can be minimal — a few seconds — and often negligible, but it is a real quantity measured as an average over a set of observations. MTTR, mean time to recovery (or repair), is the time to repair or recover the component: total maintenance time divided by total repairs. If one failure is fixed in 30 minutes, another in 20 minutes, another in 10, another in 40, the mean time to repair is the average of those values. MTBF, mean time between failures, is the time duration between the first failure and the second failure.
MTBF is the whole span between two failures. MTBF in general is the sum of the three activities that happen between failures — diagnosis, repair, and the running time:
\[ MTBF = MTTD + MTTR + MTTF \]
The timeline runs: system up and running (MTTF), fail, diagnose (MTTD), repair (MTTR), up and running again, fail again — the span between the two failures is MTBF. The three quantities are named after the failure rate: \(MTTF = \frac{1}{\lambda}\), \(MTTR\) is the repair time, and \(MTBF = MTTD + MTTR + MTTF\) ties the whole cycle together.
Exam note: In a numerical problem, if MTTD is not given, it is treated as negligible — assume it is 0. If it is specifically given, you must take it into account. In practice MTTD exists, but for computations it is taken as negligible unless stated. Stating this assumption in your answer is part of the answer.
1.4.6 Reliability in Serial Assembly
Components can be connected in series or in parallel, and that changes the system's MTTF. In serial assembly, the system C is composed of components A and B such that if A fails, C fails; if B fails, C also fails — failure of any component results in system failure.
The professor's picture — a vehicle. Think of a vehicle: whether the braking mechanism failed, the clutch is broken, or the accelerator wire is gone, the vehicle is not going to run. Every part is needed; any single failure stops the whole machine. That is a serial system.
The failure rate of the system is the sum of the failure rates of the individual components:
\[ \lambda_C = \lambda_A + \lambda_B = \frac{1}{M_A} + \frac{1}{M_B} \]
where \(M_A\) and \(M_B\) are the mean times to failure of components A and B. Since MTTF is the inverse of the failure rate, the system's mean time to failure is:
\[ M_C = \frac{1}{\lambda_C} = \frac{1}{\frac{1}{M_A} + \frac{1}{M_B}} \]
Generalizing to N components connected in series, the system MTTF is one divided by the sum of the reciprocal MTTFs:
\[ M_{system} = \frac{1}{\sum_{i=1}^{N} \frac{1}{M_i}} \]
Worked example — two parts in series. Suppose component A has \(M_A = 100\) time units and component B has \(M_B = 50\) time units. The system failure rate is:
\[ \lambda_C = \frac{1}{100} + \frac{1}{50} = 0.01 + 0.02 = 0.03 \]
So the system MTTF is:
\[ M_C = \frac{1}{0.03} = \textbf{33.3 time units} \]
Sense-check: the system MTTF (33.3) is smaller than both component MTTFs (100 and 50). A serial system is only as strong as its weakest link — and weaker than it, because every link adds failure chances. Every extra component in series makes the system worse — the reciprocal sum only grows, so the system MTTF only shrinks.
1.4.7 Reliability in Parallel Assembly
In parallel assembly, the components back each other up: if B fails alone, C does not fail; if A fails alone, C does not fail; only when both A and B fail does the system C fail. This is the kind of configuration used to build fault-tolerant distributed systems — multiple nodes achieving fault tolerance. The system's mean time to failure is the sum of the component MTTFs:
\[ M_C = M_A + M_B \]
This is a larger value than either individual component's MTTF, so the system's reliability increases. Generalizing to N components in parallel:
\[ M_{system} = \sum_{i=1}^{N} M_i \]
Worked example — two parts in parallel. Same parts: \(M_A = 100\), \(M_B = 50\) time units. The system MTTF is:
\[ M_C = 100 + 50 = \textbf{150 time units} \]
Sense-check: 150 is bigger than either part alone (100 or 50) — the system outlives its parts because a second part takes over when the first fails. Compare with the serial result (33.3) from the same two parts: the configuration alone turned a weak system into a strong one.
Pitfall — confusing "parallel" with physical wiring. Serial and parallel here are about failure behavior, not about how cables are laid. Serial means "one failure kills the system"; parallel means "all must fail for the system to fail." A second server in the same rack is parallel only if the system keeps working when the first server dies. Also note the scope: adding parallel redundancy increases the mean time to failure; adding serial components decreases it.
One precision note for the mathematically curious: for two independent components with failure rates \(\lambda_A, \lambda_B\), the standard textbook result is \(M_C = M_A + M_B - \frac{1}{\lambda_A + \lambda_B}\) — the lecture's \(M_A + M_B\) is the simplified form used in this course (and on its exams). Use the lecture's form unless told otherwise.
1.4.8 Worked Example: Availability of a Cluster
Worked example — availability of a cluster.
A node in a cluster fails every 100 hours — that is the observed MTTF, \(M_{TTF} = 100\) hours. On failure of the node, the whole system has to be shut down. (Note this is a bad cluster: typical big data systems and distributed systems are not supposed to behave that way — but the problem states it, so we accept it.) The faulty node has to be replaced, which takes 2 hours, and then the application needs to be restarted, which takes another 2 hours. So the repair time is \(M_{TTR} = 2 + 2 = 4\) hours. MTTD is not mentioned, so assume \(M_{TTD} = 0\). Availability is the fraction of time the system is up and available:
\[ A = \frac{M_{TTF}}{M_{TTD} + M_{TTR} + M_{TTF}} \]
Plugging in the numbers:
\[ A = \frac{100}{0 + 4 + 100} = \frac{100}{104} = 0.9615 = \textbf{96.15\%} \]
So the cluster is available 96.15% of the time.
Sense-check: the system is down 4 time units out of every 104 — about 3.85% — so the availability answer is very close to 96%, which matches 100/104. The formula for availability in general is the MTTF over the sum of MTTD plus MTTR plus MTTF, and since MTTD is negligible, the practical form is \(A = \frac{M_{TTF}}{M_{TTR} + M_{TTF}}\). High availability comes from a high MTTF combined with a low MTTR — minimize repair time.
1.4.9 Worked Example: The Yearly Cost of Downtime
Worked example — the yearly cost of downtime.
The second part of the same problem: downtime is costing 80,000 USD per hour. What is the yearly cost of downtime? Non-availability is the complement of availability:
\[ 100\% - 96.15\% = 3.85\% \]
The system is unavailable 3.85% of the time. A year has 365 days times 24 hours each day:
\[ 365 \times 24 = 8760 \text{ hours per year} \]
The unavailable hours per year are 3.85% of that total:
\[ 0.0385 \times 8760 \approx 337.26 \text{ hours} \]
At 80,000 USD per hour:
\[ 337.26 \times 80{,}000 \approx \$26{,}980{,}800 \]
So the downtime costs roughly USD 27 million per year.
Sense-check: almost 337 hours down per year is about 2 weeks of outage; at 80,000 USD per hour, 2 weeks of outage costing about 27 million USD — the arithmetic checks out.
Pitfall — forgetting the stated assumptions. This is simple arithmetic, but the problem depends on stated assumptions — here, MTTD not being given and so taken as zero. If the problem had given an MTTD of, say, 1 hour, the availability would change and the whole cost answer would shift. Stating assumptions is part of the answer, and the exam will reward it.
Recap and bridge. Reliability says how long until failure (MTTF and its inverse \(\lambda\)); availability says how much uptime you get (\(A = \frac{M_{TTF}}{M_{TTD} + M_{TTR} + M_{TTF}}\)). Serial assemblies add failure rates and shrink MTTF; parallel assemblies add MTTFs and grow it. The natural next question: given these numbers, what configurations should a system use so a failure costs the least downtime? That is the fault-tolerance configurations topic next.
1.5 Fault Tolerance Configurations
With multiple nodes, when one node fails we want another to take over, and we want to minimize downtime. This section walks the four classic configurations — load balanced, hot standby, warm standby, cold standby — from the most expensive and fastest-recovering to the cheapest and slowest, then looks at how they map onto active-active/active-passive deployments and the N+1 / N+M / N-to-1 / N-to-N topologies.
1.5.1 Load Balanced
The load-balanced configuration keeps both the primary node and the secondary node active: they process system requests in parallel, sharing the workload. The "secondary" node is so-called because it is also acting as a backup while sharing the load. If the primary fails, the whole workload shifts over to the secondary node.
Why failover is instant here. Because the secondary is already up and running, and the data and application state are synced bidirectionally between the two (based on software capabilities), failover time is zero — the system continues to be available without downtime. The backup node was doing real work all along, so there is nothing to cold-start: it simply absorbs the primary's share of the traffic.
1.5.2 Hot Standby
In hot standby, a software component is installed on both the primary node and the secondary node. The secondary node is up and running but does not process data until the primary node fails. The primary does the computations; when the primary fails, the secondary takes over, and the switching may take a few seconds because the secondary was not involved in the computations earlier.
Pitfall — confusing hot standby with load balancing. Both have a powered-on secondary, so they look similar. The difference is work: in load balancing, the secondary processes requests all along; in hot standby, it only runs and waits. Contrast with the load-balanced case, where the secondary was involved in computations and in regular sync — that is why load balancing gives zero failover time and hot standby takes a few seconds. If you treat hot standby as load balanced, you will overestimate its failover speed.
1.5.3 Warm Standby
In warm standby, the software component is installed and available on the secondary node, but it may not have been configured, and the data exchange and sync between primary and secondary may be less frequent than in load-balanced or hot-standby setups. When the primary fails, the software components are configured on the secondary node, started there, and the process is automated by the cluster manager. This may take a few minutes — an intermediate time between hot standby and cold standby.
1.5.4 Cold Standby
Cold standby keeps a secondary node that acts as a backup identical to the primary system, but the secondary is installed and configured only when the primary fails. At that moment the secondary node is powered on, data is restored, and the failed component is restarted. Because the standby node was not configured or installed in advance, this takes a few hours — so the term "cold" standby. It is the cheapest to run (nothing running, nothing synced) and the slowest to recover.
1.5.5 The Trade-off: Failover Time versus Cost
The four configurations form a trade-off curve. Moving from load balanced to hot standby to warm standby to cold standby, the mean time to repair increases — zero, few seconds, few minutes, few hours — while the cost decreases.
| Configuration | Secondary state | Failover (MTTR) | Cost |
|---|---|---|---|
| Load balanced | Active, processing, bidirectional sync | Zero | Highest |
| Hot standby | Running, not processing | A few seconds | High |
| Warm standby | Installed, maybe not configured, light sync | A few minutes | Medium |
| Cold standby | Installed/configured only at failover | A few hours | Lowest |
Load balanced is expensive but gives high availability; cold standby is cheap but compromises availability because MTTR is high. You buy high availability with money, or save money and accept longer downtime.
Think of it like backup generators at a hospital. The load-balanced version is a second generator running in parallel and sharing the load — switchover is instant. Hot standby is a second generator idling, warmed up and ready — a few seconds to engage. Warm standby is a generator stored, serviced occasionally, needing configuration when used — minutes. Cold standby is a generator in a crate in the basement — hours to unpack, install, and start. The analogy breaks in that servers can also share data state, which is why sync frequency matters as much as power-on state.
1.5.6 Active-Active and Active-Passive
The configurations map onto two deployment styles. Active-active: a load balancer stands in front of multiple nodes, distributing requests — the first request goes to one node, the second to another, the third to the first, and so on; when one node fails, the others take over. Active-passive: the standby is not operational in parallel; it keeps doing nothing until the primary fails.
How to tell them apart. Ask two questions about the standby: is it doing work (active) or waiting (passive)? And is it installed and synced in advance, or only at failover? Active-active matches the load-balanced configuration; active-passive covers hot, warm, and cold standby. Which variant of standby applies (hot, warm, or cold) depends on how frequently data is replicated to the standby, and on whether the standby node is installed when the primary fails or installed in advance with ongoing data exchange.
1.5.7 More Topologies: N+1, N+M, N-to-1, N-to-N
Fault tolerance configurations also address how many standby nodes to keep.
- N+1: one secondary node; if the primary fails, the secondary takes over — the simple model. One spare for N workers.
- N+M: m standby nodes, kept because it is anticipated that multiple nodes may fail at the same time. More spares than N+1, for tougher failure expectations.
- N-to-1: no dedicated secondary; instead there is one node with a lighter workload. If the primary fails, the tasks it was doing move to that low-load node temporarily, and once the primary is up and running again the tasks shift back.
- N-to-N: every node carries a similar workload and no special standby exists; whenever a node fails, its work is redistributed among the other nodes, because every node has some spare capacity.
Pitfall — thinking spares sit idle. In N-to-1 and N-to-N, there is no idle spare at all: the "standby" capacity is spare capacity distributed across working nodes. Load balancers may redistribute the load when a node fails, and when the failed node comes back, computations are restarted on it. The lesson: fault tolerance does not require a dedicated backup machine — it requires spare capacity somewhere, and the topologies differ only in where that spare capacity lives and how it is used.
Recap and bridge. Four configurations span the failover-vs-cost curve: load balanced (zero MTTR, highest cost) through hot, warm, and cold standby (hours of MTTR, lowest cost); they map onto active-active and active-passive deployments, and the N+1, N+M, N-to-1, N-to-N topologies decide how much spare capacity exists. Failover, however, does not start at the moment of switch: the system must first notice the failure — which is where recovery, the next topic, begins with diagnosis.
1.6 Recovery
1.6.1 Diagnosis
Once a system fails, recovery starts with diagnosis — the MTTD discussed earlier. There will always be some time to detect the failure and locate the failed component. One common detection mechanism is heartbeat messages: nodes in a cluster send "I am alive" messages to each other. If no heartbeat arrives from a node for a certain threshold amount of time, the master node considers that something is wrong with that node. This is a simple example; other mechanisms exist, but heartbeats are the common one.
Think of it like a watchman's rounds. In a guard tower, if the sentry checks in every hour and the check-in stops, the watch commander does not wait forever — after a threshold time without a check-in, the commander assumes something is wrong and investigates. The heartbeat is the check-in; the threshold is how long the master waits before declaring the node failed. The trade-off: too short a threshold and a slow-but-alive node is declared dead (false positive); too long, and a real failure goes unnoticed for longer.
1.6.2 Backward Recovery
Backward recovery is the checkpointing approach, familiar from the recovery module of the RDBMS course. The idea: periodically save the state of a node on stable storage; each saved state is a checkpoint. Every node is supposed to save its state periodically. On failure: isolate the failed component, roll back to the last checkpoint — look at the persistent storage for the most recent saved state — and resume normal operation from there. That is why it is called backward recovery: you go back to the last saved state and resume from that point.
Checkpointing as a safety net. The node's life is a timeline of states; checkpoints are periodic photographs of that timeline. Work done after the last photograph is lost, and the system simply replays from the photograph. The name says it all: recovery looks backward to the last good saved state. The cost is that checkpointing writes state to stable storage periodically — an overhead — and the benefit is that recovery is simple and predictable: restore the most recent checkpoint and continue.
1.6.3 Forward Recovery
Forward recovery is used in specialized systems: real-time or time-critical systems where you do not want to roll back, or cannot roll back. Instead, you reconstruct on the fly from diagnosis data. When the system fails, something is written to a log — the diagnosis data records what happened; you analyze that data and try to eliminate the failure from it. What to dump into the diagnosis data is important and application-specific, and forward recovery may also need more hardware support to recover from the failure.
Pitfall — using the wrong direction of recovery. Backward recovery (roll back to a checkpoint) works when rolling back is acceptable — batch and analytic systems are fine with it. Forward recovery (reconstruct forward) exists for real-time or time-critical systems where rolling back would be wrong or impossible — an in-flight control system cannot "undo" the last minute and re-run it. Reaching for checkpoints in a real-time system, or for forward reconstruction in a batch system where re-running is cheap, is using the wrong tool. Forward recovery also leans on diagnosis data quality and often extra hardware, so it is not the default choice.
Recap and bridge. Recovery starts with diagnosis — typically heartbeat messages and a timeout threshold (the MTTD we met earlier) — then chooses a direction: backward recovery rolls back to the most recent checkpoint on stable storage, while forward recovery reconstructs from diagnosis data on the fly for time-critical systems. One question still hangs over all of this: what can a system promise about consistency and availability while it is partitioned and recovering? That question is exactly what the CAP theorem answers next.
1.7 The CAP Theorem
Hook — a riddle no distributed system escapes. You have a bank balance stored on three servers. The network between two of them breaks, and a customer tries to read the balance from the isolated server. You must choose: tell them something even if it may be stale (available), tell them nothing until the truth arrives (consistent), or stop the system until the network heals. You cannot do all three. CAP is the proof that this riddle has no fourth answer.
CAP stands for consistency, availability, and partition tolerance. The next three subsections define each property, then the three scenarios show why you can hold at most two of them at once.
1.7.1 Consistency
Consistency means: a read of a data item from any node results in the same data across multiple nodes. Picture a network with nodes N1, N2, N3, N4 connected through an interconnection; whatever replication model they follow — primary-secondary, centralized, or a combination — if you read a data item X from node 4 and you read X from node 2, you should see the same value, say 5. If one node returns 7 and another returns 5, the system is inconsistent.
Worked example — consistency, then a divergence.
Replicas PRA, PRB, PRC all hold a bank account record with ID 3 whose amount is 49 — reading the amount for ID 3 from any replica gives 49, so the database is consistent.
Now suppose a user writes a new value 50 to PRA. The update reaches PRB but not PRC. After the update, a read at step 4 returns 49 and a read at step 5 returns 50 — different values at two different nodes, even though the first read happened after the update. That is an inconsistent system.
Sense-check: consistency is broken the moment two nodes can answer the same read with different values. The trigger here is a partially propagated write: the write succeeded on two replicas and missed the third, so the nodes no longer agree.
1.7.2 Availability
Availability means: a read or write request will always be acknowledged. If a user sends a read or write request through a node, the system responds with success or failure within a reasonable time. Whether the operation is allowed or not, the system should respond — it should not leave the request hanging for an unreasonable time; that state is what we call the system being unavailable.
Available does not mean successful. An available system answers — "yes, done" or "no, I cannot." A system that refuses to answer at all is unavailable. Suppose replica PRC is disconnected from the network. One option: it remains available by responding with a failure message when any request is made — "I cannot execute" — so users get an answer. The other option: it waits for the problem to be fixed before responding, which could take an unreasonably long time and leave the user request waiting — the system is then unavailable, giving low availability. A fast "no" is availability; a slow silence is not.
1.7.3 Partition Tolerance
Partition tolerance means: the system can continue to function when a communication outage splits the cluster into multiple silos, and can still service read and write requests. A node may get disconnected from the network; the question is whether the system continues to operate in that state or waits for the node to come back.
Visualizing a partition: draw the cluster as a ring of nodes N1, N2, N3, N4 connected by links. Now erase one link: the nodes on one side of the break form one silo and the nodes on the other side form another, with no message able to cross. That broken ring is the partition. The partition-tolerant system keeps serving both silos; the non-tolerant one effectively stops until the link returns.
1.7.4 The Three CAP Scenarios
The balance between the three properties is best seen through three scenarios, all involving a network partition where the user wants to update the value on replica PRC to 82.
Scenario 1 — CA, no P. A network partition happens and the user wants to update PRC. Any access by the user to PRC leads to a failure message. The system is available, because it comes back with a response; it is consistent, because the user's update is not processed and the value stays the same across all three replicas. But there is no partition tolerance: when the network partitioned, the system did not allow user operations to succeed. You have C and A, but no P.
Scenario 2 — AP, no C. A network partition happens and the user wants to update PRC. PRC records the update with success, even though it is disconnected and cannot communicate the update to PRA and PRB immediately. The value at PRC becomes inconsistent with the values at A and B. But the system is available — it responded with a success message — and it is partition tolerant, because it allowed the operation to complete across the partition. You have P and A, but no C.
Scenario 3 — CP, no A. A network partition happens and the user wants to update PRC. The user is made to wait until the partition is fixed and the data is replicated on PRC before the success message is sent. The update eventually reaches all nodes, so there is consistency; the system tolerated the partition, so there is partition tolerance. But the success message was delayed — the system was not available while waiting. You have C and P, but no A.
| Scenario | What the user gets | Gained | Sacrificed |
|---|---|---|---|
| 1 — CA | An immediate failure message | Consistency + availability | Partition tolerance (operations refused) |
| 2 — AP | An immediate success message | Availability + partition tolerance | Consistency (replicas diverge) |
| 3 — CP | A delayed success message | Consistency + partition tolerance | Availability (the user waits) |
1.7.5 The Theorem: You Get Two of Three
The CAP theorem states what these scenarios show: any distributed system running on a multi-node cluster can have any two of the three properties — CA, CP, or AP — but cannot have all three at the same time. You cannot have a system that provides consistency, availability, and partition tolerance simultaneously.
Why the choice is really between C and A. Partition tolerance is not optional in practice: links and node failures are common in distributed systems, so partitions are a given. Every real system must so plan for partitions — which removes P from the menu and leaves the real choice between consistency and availability. What the theorem leaves you is a choice between consistency and availability, and that choice depends on the application requirements — whether consistency matters more or availability matters more for the workload at hand. A bank chooses consistency (a wrong balance is a worse failure than a slow one); a social feed chooses availability (a stale like is better than no feed).
1.7.6 Student Questions and Answers on Network Partitions
Q: What does a network partition actually mean? A: Nodes are connected via an interconnection network. If a link between nodes fails, the nodes on one side of the broken link are separated from the rest — two nodes on one side, five or seven on the other. When the interconnection among the nodes gets disturbed so that one or two nodes can no longer communicate with the other set of nodes in the cluster, that is a network partition. It means the network in between is no longer good enough to communicate.
Q: Is a node disconnecting from the network different from a partition? A: It is the same thing. If one node disconnects, that is a partition between one node and the rest (N minus 1). If two nodes disconnect, those two may still connect to each other, giving a partition of 2 and N minus 2. Whether one node separates or multiple, it is a kind of partition — the "N minus k" picture is just a partition where one side happens to be small.
Q: If a node separates out in a load-balanced system, will it stop getting requests? A: Very likely it might not get requests, because heartbeat messages stop reaching it. But note the load balancer is a separate component responsible for distributing load. Even so, if the system is not allowed to handle requests through the partitioned node, that is less partition tolerance.
Q: So what should the system do during a partition? A: The system may allow operations to continue during the partition, but at the cost of consistency or availability. It depends on the application requirements: whether consistency matters or availability matters. Partition tolerance is a common problem in distributed systems because link and node failures are common — and the deeper treatment, including levels of consistency, continues in the next session.
Recap and bridge. CAP names the three properties every distributed system cares about — consistency (all nodes agree), availability (every request gets an answer), partition tolerance (the system survives a split) — and proves you can keep at most two, with partition tolerance effectively mandatory, so the real choice is consistency versus availability. That choice is made per application: banks and billing lean consistent, feeds and analytics lean available. The next session deepens this into levels of consistency — how much "agreement" a system can promise and still stay fast.
Exam Guidance Summary
- Expect mathematical problems on availability and reliability: MTTF, MTTR, availability percentage, and the cost of downtime. A practice problem on availability and reliability (of the kind worked in this unit) is posted on the forum.
- In numericals, state your assumptions — this is part of the answer. Specifically, if MTTD is not given, assume it is negligible (zero); if it is given, include it in the availability formula.
- Know the two assembly formulas: serial assembly makes system MTTF the reciprocal of the sum of reciprocal component MTTFs (system reliability worsens with every added component); parallel assembly makes system MTTF the sum of component MTTFs (reliability improves).
- MapReduce will be practiced in a lab session: be able to look at a problem and decide what code goes in the map task and what goes in the reduce task. Python is used for the labs. Questions about how data is shared between map and reduce tasks and where shuffling happens will be covered there.
- Know the CAP theorem in depth, including the three scenarios (CA, AP, CP). The full treatment of consistency levels continues in the next session.
Exam note — the one-page revision picture. Every numerical problem in this unit hangs off a single timeline: up for MTTF, fail, diagnose (MTTD, usually 0 unless stated), repair (MTTR). Availability is \(\frac{MTTF}{MTTD + MTTR + MTTF}\), and the cost of downtime is the unavailable fraction of the year at the given hourly rate. For the concept questions, the three big contrasts to be able to explain in a sentence each are: Hadoop versus RDBMS (flexible schema versus schema-first), MapReduce versus Spark (disk round trips versus in-memory), and CAP's three scenarios (CA, AP, CP).
Key Industry Applications
- Real-world: The data sources motivating big data systems — stock exchanges, online retail (Amazon, Facebook), banking transactions, sensor data — all feed the storage-and-processing problem Hadoop solves.
- Real-world: Hadoop's MapReduce is used in industry for batch workloads: identifying patterns in system logs, running ETL (extraction, transformation, loading) tasks, computing web indexes, and building recommendation systems.
- Real-world: Apache Spark (with Spark MLlib and Mahout) handles the workloads MapReduce handles poorly — iterative machine learning training, streaming, and low-latency analytics — by caching working data sets in memory.
- Real-world: The Hadoop ecosystem is the standard industry stack: HDFS + MapReduce for the core, YARN for resource management, Sqoop and Flume for data ingestion, Hive for SQL-like analytics, Pig (Pig Latin) for non-programmers, Oozie for job scheduling, ZooKeeper and Apache Ambari for coordination, and NoSQL databases for specialized stores.
- Real-world: Cloud providers deliver big data infrastructure as a service: AWS (S3 buckets for storage, EC2 for compute, Elastic MapReduce as a pre-installed Hadoop platform, DynamoDB, Redshift for data warehouse acceleration), Google Cloud Platform (Compute Engine, BigQuery, Prediction API), and Microsoft Azure (SQL Azure, HDInsight).
- Real-world: SaaS products such as Salesforce CRM show the software-as-a-service model, and vendors offer out-of-the-box SaaS for social media analytics and feedback monitoring.
- Real-world: Relational databases running OLTP workloads — day-to-day business transactions with ACID semantics and global commit for distributed transactions — remain the backbone of operational systems, coexisting with the big data stack.
- Real-world: Production clusters detect failed nodes with heartbeat messages, protect data with replication (factor three in HDFS), and use standby configurations (load balanced, hot, warm, cold) whose failover time versus cost trade-off is chosen per application.
How this unit's systems fit together in industry. A typical industrial big data platform is the Hadoop ecosystem (HDFS + MapReduce core, YARN on top, Sqoop/Flume bringing data in, Hive/Pig querying it) with Spark layered on for iterative and low-latency jobs, all running on cloud infrastructure rented from AWS, Google Cloud, or Azure. Underneath it all, the same reliability math this unit taught decides the answer to the question nobody can avoid: what does the platform cost — and what does it lose — when a node fails?
BDS Lecture 1 notes
Sections Breakdown
HDFS storage and the MapReduce compute model: replication, commodity hardware, schema-on-read versus schema-on-write, ACID versus jobs and tasks, cluster architecture, the word count worked example, advantages, and the Hadoop ecosystem.
Why MapReduce fails low-latency and iterative workloads; distributed RAM instead of disk; Spark's composable operators; word count in Spark; training loops at memory speed.
The sizing trap, the NIST definition, the 3-4-5 rule — five characteristics, four deployment models, three service models — and cloud services for big data plus the market leaders.
MTTF, MTTD, MTTR, MTBF, serial and parallel assembly formulas, and availability; worked examples: five CFL bulbs, cluster availability at 96.15%, and the yearly cost of downtime.
Load balanced, hot, warm, and cold standby; the failover-time-versus-cost trade-off; active-active versus active-passive deployments; N+1, N+M, N-to-1, and N-to-N topologies.
Diagnosis with heartbeat messages; backward recovery by checkpointing; forward recovery for real-time systems that cannot roll back.
Consistency, availability, and partition tolerance; the three scenarios CA, AP, CP; why partitions make the real choice consistency versus availability.
The professor's exam strategy: reliability numericals with stated assumptions, the two assembly formulas, MapReduce labs in Python, and the CAP theorem scenarios.
Real-world systems: Hadoop batch workloads, Spark for iterative machine learning and streaming, the standard ecosystem stack, cloud services for big data, and OLTP RDBMS coexisting with the big data stack.
Exam Revision Notes
Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.
Hadoop — Storage and Processing for Big Data
Must-know: MapReduce: split data into chunks; map tasks emit one key-value pair per item (no aggregation); reducers shuffle, sort, and aggregate per key. Hadoop stores any data type via HDFS blocks with replication factor three on commodity hardware; no transactions, only jobs and tasks.
⚠️ Top pitfall: Believing map tasks aggregate — they never do; every occurrence produces its own pair, aggregation is the reducer's job.
Self-check: Sentence 'a b a' goes to one map task; which pairs are emitted and what does the reducer output?
Connects to: 1.1.3, 1.1.5, 1.1.7
In-Memory Computing with Spark
Must-know: Spark caches working data in distributed RAM, replacing intermediate disk storage, to serve low-latency and iterative workloads; compose operators (map, flatMap, reduceByKey, join, groupBy) instead of writing fixed map-then-reduce functions.
⚠️ Top pitfall: Assuming Spark needs one giant machine; it pools each node's RAM across a cluster, with the intermediary layer handling sync.
Self-check: Why is a ten-iteration training loop fast in Spark but slow in MapReduce?
Connects to: 1.1.5, 1.4
Cloud Computing for Big Data
Must-know: 3-4-5 rule: 5 characteristics (on-demand self-service, broad network access, resource pooling, rapid elasticity, measured service), 4 deployment models (public, private, hybrid, community), 3 service models (IaaS, PaaS, SaaS). Private cloud shares resources among one organization's users, not across organizations.
⚠️ Top pitfall: Thinking elasticity means unlimited free resources; it means resources respond to demand and you pay per use (measured service).
Self-check: Which service model is Elastic MapReduce, and why does a private cloud still qualify as a cloud?
Connects to: 1.1, 1.3.5, 1.3.6
Reliability and Availability
Must-know: Availability = MTTF/(MTTD + MTTR + MTTF); MTTD = 0 unless given. Serial: M_system = 1/(sum 1/M_i) (shrinks). Parallel: M_system = sum M_i (grows). MTTF = 1/lambda; MTBF = MTTD + MTTR + MTTF.
\[A = \frac{M_{TTF}}{M_{TTD} + M_{TTR} + M_{TTF}}\]
⚠️ Top pitfall: Forgetting to state assumptions: MTTD not given means MTTD = 0; also confusing serial (any failure kills the system) with parallel (all must fail).
Self-check: Node fails every 100 hours, repair takes 4 hours; what is availability and the yearly cost at 80,000 USD/hour?
Connects to: 1.5, 1.4.6, 1.4.7
Fault Tolerance Configurations
Must-know: Load balanced = zero failover time (highest cost); hot standby = seconds; warm standby = minutes; cold standby = hours (lowest cost). You buy high availability with money, or save money and accept longer downtime.
⚠️ Top pitfall: Confusing hot standby (running but not processing) with load balanced (both processing); hot standby failover takes seconds, load balanced is instant.
Self-check: Which configuration has the highest failover time and the lowest cost?
Connects to: 1.4, 1.6
Recovery
Must-know: Diagnosis via heartbeat + timeout (MTTD); backward recovery = roll back to last checkpoint and resume; forward recovery = reconstruct from diagnosis data, for real-time systems that cannot roll back.
⚠️ Top pitfall: Using backward recovery where rollback is impossible (real-time systems) or forward recovery where re-running from a checkpoint is cheaper.
Self-check: Why is a control system more likely to use forward recovery than backward recovery?
Connects to: 1.4.5, 1.7
The CAP Theorem
Must-know: Any distributed system can have two of CA/CP/AP, never all three; partition tolerance is effectively mandatory (links and nodes fail), so the real choice is consistency vs availability by application needs. Know the three scenarios (CA, AP, CP) and what the user receives in each.
⚠️ Top pitfall: Equating availability with success: an immediate failure message IS availability; a hanging request is unavailability. Also treating a single node disconnect as something other than a partition (it is a partition of 1 and N-1).
Self-check: In a partitioned system where a write succeeds on only one side, which property is lost if the system answers immediately?
Connects to: 1.4, 1.5.6
Exam Guidance Summary
Must-know: Availability = MTTF/(MTTD + MTTR + MTTF) with MTTD = 0 unless given; serial assembly shrinks system MTTF, parallel grows it; CAP scenarios CA/AP/CP.
\[A = \frac{MTTF}{MTTD + MTTR + MTTF}\]
⚠️ Top pitfall: Omitting stated assumptions in numericals.
Self-check: How does the availability formula change when MTTD is given as nonzero?
Connects to: 1.4, 1.7
Key Industry Applications
Must-know: The standard industry stack and which workload each tool serves (ingestion, resource management, analytics, ML, scheduling, coordination).
Self-check: Which tool ingests structured data into HDFS, and which tool schedules jobs?
Connects to: 1.1.9, 1.3