Chapter 9 - NoSQL & Big Data Processing

Updated 5 Oct 2026

Chapter 9 — NoSQL & Big Data Processing

CSS451 Cloud Computing · Cheat Sheet


🧭 Big Picture First

Think of traditional RDBMS as a single, well-organized filing cabinet. It works great for a small office, but when the entire city needs to file documents simultaneously, it becomes a bottleneck. NoSQL is the answer to that bottleneck — a distributed warehouse of flexible storage rooms, each designed for a different kind of data.


1. History: How We Got Here

  • Relational Databases (RDBMS) were the mainstay of business apps — because of ACID properties
  • Web-based apps (especially e-Commerce) caused sudden traffic spikes
  • Developers started fronting RDBMS with memcache or Ehcache to cope
  • Eventually the bottleneck wasn't cache — it was the database itself

The Core Scaling Problem

RDBMS were not designed to be distributed. When datasets grew too big, two main approaches emerged:

ApproachHowProblem
Scale UpBuy a bigger single machineExpensive, has hardware limits
Scale Out (horizontal)Add more cheap machinesRequires distributed design

2. Scaling RDBMS

Master/Slave Replication

  • All writes → Master
  • All reads → Slave (replicated copies)

Problems:

  • Critical reads may be stale — writes haven't propagated yet
  • Large datasets: master must duplicate data to all slaves

Like a newspaper: the editor (master) writes the stories, printing machines (slaves) copy them. But if the presses haven't caught up, readers get yesterday's news.


Sharding (Partitioning)

  • Splits data into smaller, independent pieces across multiple servers
  • Scales well for both reads and writes
  • BUT: application must be partition-aware, no JOINs across shards, loss of referential integrity

Like splitting a dictionary into volumes A–M and N–Z — each is independent, but together they cover everything.

Four Sharding Techniques

TechniqueHow It WorksKey Note
Vertical PartitioningTables for each feature on its own serverMay need resharding if tables grow too large
Range-BasedSplit by a value range (e.g., price 0–0–49, 50–50–99, $100+)Simple but can cause hot spots
Key/Hash-BasedHash function on key → determines which serverUniform distribution
Directory-BasedLookup service knows the partitioning schemeMost flexible; can change scheme without app changes

Other Scaling Techniques

TechniqueDetails
Multi-Master ReplicationINSERT only (no UPDATE/DELETE) to preserve consistency. No JOINs. De-normalized data.
In-Memory DatabasesEliminate disk access entirely → minimal response times

3. What Is NoSQL?

  • Stands for "Not Only SQL"
  • A class of non-relational data storage systems
  • Usually: no fixed table schema, no joins
  • All NoSQL offerings relax one or more ACID properties (→ see CAP Theorem)

NoSQL is like a flexible notebook instead of a rigid spreadsheet — add any kind of info without pre-defining the format.

Why NoSQL?

  • RDBMS can't be the "be-all/end-all" for all data storage needs
  • Just as we have different programming languages for different jobs, we need different storage tools
  • Triggered by:
    • Explosion of social media (Facebook, Twitter)
    • Rise of cloud (Amazon S3)
    • Shift to dynamically-typed data with frequent schema changes
    • Growth of the open-source community

The NoSQL Perfect Storm

Large datasets+Acceptance of alternatives+Dynamically-typed data=NoSQL\text{Large datasets} + \text{Acceptance of alternatives} + \text{Dynamically-typed data} = \text{NoSQL}

This is NOT a rebellion against RDBMS. SQL is a rich query language that NoSQL cannot rival — they serve different purposes.


4. Seeds of NoSQL: Dynamo & BigTable

Three major papers seeded the NoSQL movement:

  1. BigTable — Google
  2. Dynamo — Amazon
  3. Gossip Protocol — for discovery and error detection

Amazon Dynamo

  • Platform for Amazon's e-commerce: shopping cart, product catalog, best seller list, etc.
  • A highly available, distributed key-value storage system
  • Exposes only put() and get() interfaces
  • Aims for "always on" at the cost of some consistency
  • Introduced the CAP Theorem

Dynamo Design Principles

PrincipleMeaning
Incremental scalabilityScale out one node at a time
Minimal management overheadSelf-managing
SymmetryNo master/slave — decentralized
Decentralized controlCentralized control → outages
HeterogeneityExploit different node capabilities

5.1 Key/Value Store

  • Values looked up by a key (like a hashmap)
  • Keys can map to more than one value
  • Stored in native data types
"user:123" → { name: "Google", age: 21 }

Like a dictionary — you look up a word (key) and get its definition (value).

Examples: Amazon S3/Dynamo, Redis, Memcached, Voldemort, Scalaris


5.2 Document Database

  • Stores data as JSON or XML documents
  • Documents create hierarchies — the structure implies relationships
  • No fixed schema — different documents can have different fields

Relational vs. Document

AspectRelational DBDocument DB
StorageRows in a tableJSON/XML documents
StructureFixed columnsFlexible properties
ConstraintEvery row has same columnsEach document can differ
Doc 1: { "id": "1", "name": "John Smith" }
Doc 2: { "id": "2", "fullName": "Sarah Jones" }
Doc 3: { "id": "3", "fullName": { "first": "Adam", "last": "Stark" } }

Notice Doc 2 uses fullName instead of name, and Doc 3 nests the name — impossible in relational tables.

Examples: MongoDB, CouchDB


5.3 Graph Database

  • Stores data in nodes (vertices) and edges (relationships)
  • Graph traversal = how you query
  • Relationship info stored on the edges themselves
MATCH p=((tx:Transaction {txId:'123abc'})-[*..10]-(c:Car {plate: "LOVE NE04"})) RETURN p;

Two Key Advantages of Graph DBs

  1. Rich relationship modeling — relationships are first-class citizens
  2. Query performance — traversal is far faster than JOIN-heavy SQL for connected data

Why Graph DBs Are Powerful for Investigations

  • Easy for non-developers to query with Cypher + visualization tools
  • Fast at analyzing connected data (e.g., ongoing fraud/terrorist investigations)
  • Help users discover the "unknowns"

Like a social network map — instead of asking "who knows John?", draw lines between people and follow connections directly.

Examples: Neo4j, OrientDB


6. Neo4j Deep Dive

  • A graph is a collection of nodes (things) and edges (relationships)
  • Both nodes and relationships hold properties (key-value pairs)
  • Think of it as a key-value store with full relationship support

Four Core Concepts

ConceptDescription
NodesRepresent entities (people, places, transactions)
RelationshipsConnect two nodes; always have a direction and type
PropertiesKey-value pairs on nodes or relationships
IndexesMaps from properties → nodes/relationships for fast lookup (without full traversal)
Node: (Person {name: "Alice", age: 30})
Relationship: (Alice)-[:KNOWS]->(Bob)
Index: Find node where username = "master-of-graphs"

Neo4j Features

FeatureDetail
Performance~1000x faster than relational DBs for graph queries
ScalabilityBillions of nodes/relationships on a single machine; can shard
ACIDFully transactional
TraversalTraverses 1000 levels deep at millisecond speed
LicenseDual — open source + commercial
Use casesSocial networks, tagging, wikis, fraud detection, knowledge graphs

Property Rules

  • Keys are strings; values are primitives or arrays of one primitive type
  • null is NOT a valid property value — model nulls by the absence of the key

7. OrientDB

  • A combined graph + document database
  • Stores JSON documents in both nodes and edges
  • Uses HTTP REST API → easy to distribute
  • Runs on JVM → portable
  • APIs in C/C++, Ruby, PHP, Java

8. Distributed Databases

StrategyWhat It DoesProsCons
ReplicationCopies the entire DB to all nodesFast reads, high reliabilityHigh network + memory overhead
ShardingSplits data across nodes (horizontal = by rows, vertical = by columns)Fast read/write, low overheadPotential data loss
  • Nearly all NoSQL systems natively support distributed design — this is a key appeal

9. CAP Theorem ⭐

Three Properties of a Distributed System

PropertyMeaning
Consistency (C)Read always returns the most recent write
Availability (A)System always responds (may not be latest data)
Partition Tolerance (P)System continues working even if nodes can't communicate

CAP: You can only guarantee 2 out of 3\boxed{\text{CAP: You can only guarantee 2 out of 3}}

Pick 2SacrificeExamples
C + APartition ToleranceTraditional RDBMS (not distributed)
C + PAvailabilityHBase, BigTable
A + PConsistencyCassandra, DynamoDB

To scale out, you must have Partition Tolerance (P) → you must choose between C and A. In most cases: choose Availability over Consistency (but not always!)

Like a group project: you can't have work that's consistent (everyone has the same version), available(everyone can always access it), and partition-tolerant (works even if members are unreachable) — never all three perfectly.

Real-World CAP Decisions

ScenarioChoiceReason
Shopping cartAvailabilityAlways honor "add to cart" — revenue-producing; fix errors later
Order submissionConsistencyMultiple services (credit card, shipping, reporting) access data simultaneously

10. ACID vs. BASE

ACIDBASE
Full formAtomicity, Consistency, Isolation, DurabilityBasically Available, Soft-state, Eventual Consistency
ModelStrong ConsistencyWeak Consistency
Used byRDBMSMost NoSQL

ACID Properties

PropertyMeaning
AtomicTransaction is all-or-nothing — either fully happens or not at all
ConsistentDB constraints are preserved before and after transaction
IsolatedTransactions appear to execute sequentially, even if concurrent
DurableOnce committed, changes survive crashes

Key ACID Concepts

  • Commit = transaction completes → all changes saved permanently
  • Abort/Rollback = transaction fails → all changes undone completely
  • Static Integrity Constraints = rules all DB states must satisfy (e.g., curreg≤maxregcur_{reg} \leq max_{reg})
  • Transaction Consistency: a correct transaction both maintains DB constraints AND keeps the DB in sync with reality:

balance′=balance+amtdeposit\boxed{balance' = balance + amt_{deposit}}

Techniques for Isolation

  • Two-Phase Locking (Lock phase → Shrinking phase)
  • Timestamp Ordering

Why Not Just Use Serial Execution?

Serial execution (one transaction at a time) is 100% correct but too slow. Concurrent/interleaved execution = better performance but requires careful isolation management.

BASE Properties

BASE=Basically Available+Soft State+Eventual Consistency\boxed{BASE = \text{Basically Available} + \text{Soft State} + \text{Eventual Consistency}}

PropertyMeaning
Basically AvailableSystem seems to work all the time
Soft StateDoesn't have to be consistent at all times
Eventually ConsistentBecomes consistent at some later point

Like a Wikipedia edit — your change may take time to appear across all server regions. Eventually, everyone sees the same version.

Durability Implementation

ApproachMechanism
Non-stop DBMSMirrored disks
Recovery-based DBMSLog files, data backup, checkpoints

11. Consistency Model

Determines rules for visibility and apparent order of updates.

  • Strong Consistency → you always read the latest write (ACID)
  • Eventual Consistency → you might read a stale value, but it will eventually be correct (BASE)
  • Consistency is a continuum — usually traded against Availability

12. NoSQL Trade-offs Summary

What You Gain

  • Cheap and easy to implement (open source)
  • Data replicated to multiple nodes → fault-tolerant
  • Data can be partitioned
  • No single point of failure
  • No schema required
  • Can scale up and down
  • Relaxed consistency (CAP tradeoff)

What You Give Up

  • JOIN operations
  • GROUP BY / ORDER BY
  • ACID transactions
  • SQL's expressive query language
  • Easy integration with SQL-supporting apps

13. NoSQL Categories & Examples

CategoryExamples
Key/ValueAmazon Dynamo, Redis, Memcached, Voldemort, Scalaris
DocumentMongoDB, CouchDB
Column-basedCassandra, HBase
GraphNeo4j, OrientDB

14. BigTable (Google) — C+P System

CAP category: Consistency + Partition Tolerance

Data Model

(row:string, column:string, time:int64)→byte array\boxed{(row:string,\ column:string,\ time:int64) \rightarrow \text{byte array}}

  • A table is a sparse, distributed, persistent, multidimensional sorted map
  • Supports: lookups, inserts, deletes
  • Only single-row transactions (no multi-row ACID)

Key Concepts

TermDescription
Row KeyLexicographically sorted — enables efficient range scans
Column FamilyGroup of related columns; family:qualifier format
TimestampEvery cell can have multiple versions, indexed by time
TabletA dynamically partitioned row range — unit of distribution

Think of it as an enormous multi-layered spreadsheet where rows are web pages and columns store attributes — with timestamps so you can see historical versions.

Internal Storage Format

(RowKey, ColumnFamily:Column, Timestamp)→Value\boxed{(RowKey,\ ColumnFamily:Column,\ Timestamp) \rightarrow Value}

BigTable Building Blocks

BigTable=GFS+Chubby+SSTables\text{BigTable} = GFS + Chubby + SSTables

ComponentRole
GFSGoogle File System — distributed storage
ChubbyDistributed coordination — master election, schema storage, ACLs
SSTableSorted Strings Table — actual data storage format

15. Chubby

  • A distributed coordination service
  • Goal: allow apps to synchronize and manage dynamic config state

Chubby's Role in BigTable

  • Ensures only one active master at a time
  • Stores bootstrap location of BigTable data
  • Used to discover tablet servers
  • Stores BigTable schema and access control lists

Chubby is like a traffic controller — ensures only one car (master) controls an intersection, and everyone knows where to look for directions.


16. SSTable (Sorted Strings Table)

  • A file of key/value string pairs, sorted by keys
  • Persistent, ordered, immutable map from keys to values
  • Stored in GFS; structured as 64KB blocks + index at the end
[ 64K block | 64K block | 64K block | ... | Index ]
  • Index loaded into memory when SSTable is opened
  • Lookup = 1 seek: find block in memory index → seek to that block on disk

SSTable Pros & Cons

✅ Advantages❌ Disadvantages
Fast key-based lookupsImmutable (write-once)
Duplicate keys allowedKeys must be sorted before creating
Sharding + compression automaticOnly lookup by key
Easy to use with MapReduce

When to Use SSTable

  1. As input/output of a MapReduce job
  2. As a random-access lookup table for an application server

17. Tablet

  • A dynamically partitioned range of rows built from multiple SSTables
  • The unit of distribution and load balancing
  • Key rule: A tablet is served by only one tablet server at a time, but SSTables can be shared between multiple tablets

SSTable→Tablet→Table\boxed{SSTable \rightarrow Tablet \rightarrow Table}

A tablet is like one drawer in a filing cabinet. The entire cabinet is the table; each drawer holds a sorted range of files.


18. BigTable Architecture

Three Components

  1. Client Library
  2. Single Master Server
  3. Tablet Servers

Master Responsibilities

  • Assigns tablets to tablet servers
  • Detects addition/expiration of tablet servers
  • Balances tablet server load
  • Handles garbage collection and schema changes

Tablet Server Responsibilities

  • Manages 10–1,000 tablets per server (each 100–200 MB)
  • Handles read and write requests
  • Splits tablets that grow too large
  • Maintains exclusive lock on a Chubby file per tablet

Who Initiates What?

ActionInitiated By
Table creation/deletionMaster
Tablet mergingMaster
Tablet splittingTablet Server

Tablet Location Hierarchy

Chubby
  └── Root Tablet (METADATA table)
        └── METADATA Tablets
              └── User Tablets

Clients cache tablet locations after discovery.


19. Tablet Server Internals: Reads & Writes ⭐

Write Path

Write Request
  → WAL (Write Ahead Log / commit log) — stores REDO records
  → Memtable (in-memory cache of recent writes)
  → SSTable files in GFS (older writes)

Read Path

Read Request
  → Merged view of: Memtable + SSTables
  (Both are lexicographically sorted → merge is efficient)

WAL (Write Ahead Log)

  • We do NOT flush data pages to disk on every commit
  • Data written to log files first, then flushed to disk later
  • On crash:
    • Uncommitted changes → UNDO (roll-backward)
    • Committed but not flushed → REDO (roll-forward)

REDO is preferred for data recovery — it replays committed transactions that weren't flushed to disk yet.


20. Compactions

Compaction = cleaning up your desk over time

TypeWhat HappensPurpose
Minor CompactionConverts memtable → SSTableReduces memory usage + log traffic
Merging CompactionMerges a few SSTables + memtable → new SSTableReduces number of SSTables
Major CompactionAll SSTables → one SSTableOnly live data remains; no deletion records

21. BigTable Performance Observations

Access PatternPerformanceWhy
Scans🟢 BestBatch multiple reads into one RPC → high throughput
Random reads (memory)🟡 FastServed from memtable
Random reads (disk)🔴 WorstEach request = 64KB SSTable block read from GFS
Random writes ≈ Sequential writes🟡 SimilarBoth result in appends to WAL log

22. HBase — Open-Source BigTable

HBase = BigTable clone, open-source, built on HDFS (Hadoop)

Why HBase?

  • RDBMS is great for transaction processing but not for very large-scale analytic processing
  • BigTable/HBase handles:
    • Big queries — range scans, table scans
    • Big databases — 100s of TB
  • Sharding is NOT a good solution for scaling open-source RDBMS — application-specific and labor-intensive

HBase vs. RDBMS

FeatureHBase
IndexesNo real indexes (row key only)
PartitioningAutomatic
ScalingLinear, automatic with new nodes
HardwareCommodity servers
ReliabilityFault tolerant
ProcessingBatch processing support

HBase Data Model

(Row, Family:Column, Timestamp)→Value\boxed{(Row,\ Family:Column,\ Timestamp) \rightarrow Value}

  • Tables sorted by Row
  • Schema defines only column families — columns exist only when inserted (NULLs are free / sparse)
  • Everything except table names is byte[]
Row key → [Column Family : [Column : [Timestamp → Value]]]

HBase Consistency (Why It's C+P)

  • Strongly consistent — each row hosted by one region server at a time
  • Uses row locks + MVCC (multiversion concurrency control) within a row
  • During failover: new region server doesn't accept writes until previous is blocked out
  • Replication at the HDFS layer — not acknowledged to client until flushed to 3 HDFS replicas

HBase Architecture

ComponentRole
MasterMonitors region servers, load balancing, redirects clients
RegionServer (Slaves)Handles Write/Read/Scan, sends heartbeat to Master

HBase Client Access

MethodDetails
Java clientget(byte[] row, byte[] column, long timestamp, int versions)
Thrift serverRuby, C++, Java via Thrift
REST serverHTTP REST API
MapReduceTableInput/OutputFormat
HBase ShellJRuby IRB with get, scan, admin commands

23. RDBMS vs. Column Family Model

Relational DBColumn Family (HBase/BigTable)
SchemaRigid, pre-defined, fixedFlexible
StructureTables with fixed columnsColumn families with dynamic columns
ScaleVertical (scale up)Horizontal (scale out)
JoinsYesNo
ACIDFullPartial (row-level only)