Big Data Analytics | Semester 7 Complete Core Notes
Semester 7 - Page 2: Big Data Analytics. 25 numbered topics, highlighted rules, worked cases, answered exam questions, diagrams, comparison tables and three complete Python demos. General common-core guide, not an official syllabus. Verify required framework versions/algorithms against your course outline.
Topic map
- Workload-relative big data and the Vs
- Volume, velocity and sizing assumptions
- Distributed architecture and failure models
- Partitioning and data locality
- Replication versus backup
- HDFS concepts and block storage
- Map, shuffle and reduce
- Combiners and algebraic correctness
- Spark RDDs and lineage
- DataFrames, schema and SQL planning
- Lazy transformations and actions
- Shuffle, joins and skew
- Caching, memory and driver limits
- Batch, streams and ETL/ELT
- Event time and processing time
- Tumbling/sliding windows and boundaries
- Watermarks and late-data policies
- Retries, checkpoints and deduplication
- Delivery semantics and end-to-end effects
- Formats, schema evolution and quality
- NoSQL models and query tradeoffs
- Analytics types and causal caution
- Evaluation, time splits and numerical metrics
- Privacy, access and operational evidence
- End-to-end pipeline and exam checklist
1. Workload-relative big data and the Vs
Big data describes workloads whose storage, memory, processing or freshness constraints make one-machine handling impractical. Distribution adds coordination cost, not automatic speed.
Answer: No. Workload, hardware and constraints determine the problem.
2. Volume, velocity and sizing assumptions
Estimate payload, ingestion rate, retention, indexes, replicas and overhead separately. Use explicit decimal/binary units and measured variation.
Answer: No. Replication, metadata, logs and compression change it.
3. Distributed architecture and failure models
Separate clients, coordination, workers, storage and sinks. State what failures/network conditions the design tolerates rather than promising zero downtime.
Answer: No. Distribution creates new failure and communication paths.
4. Partitioning and data locality
Partitioning spreads records/work by hash, range or another policy. Locality can reduce transfer; cross-partition joins and uneven ranges cost more.
Answer: No. Key frequencies and workload matter.
5. Replication versus backup
Replication maintains copies for availability/fault tolerance under a system policy; backup preserves recoverable historical state. They address different failures.
Answer: No. They may share logical corruption/deletion.
6. HDFS concepts and block storage
HDFS separates filesystem metadata coordination from data-block storage and uses replication for fault tolerance. Layout and configured policy affect real capacity/access.
Answer: No. Inspect its actual configuration/state.
6A. Hadoop YARN: Resource Manager, Node Manager and ApplicationMaster
YARN (Yet Another Resource Negotiator) separates cluster resource management from application-specific task coordination. HDFS stores data; YARN manages the resources used to run applications. The ResourceManager, NodeManager and ApplicationMaster have different scopes.
Role of the Resource Manager (RM)
The ResourceManager is the cluster-level resource authority. It allocates available resources, such as memory and CPU, among applications according to the configured scheduling policy. It has two main components:
- Scheduler: allocates resources to applications, subject to capacity, queues and resource requirements. The Scheduler itself does not track application progress or restart failed tasks.
- ApplicationsManager: accepts application submissions, arranges the first container for the application's ApplicationMaster, and provides the service for restarting the ApplicationMaster container on failure.
Role of the Node Manager (NM)
The NodeManager is the per-machine agent on a YARN worker node. It launches and manages containers on that machine, monitors resource usage such as CPU, memory, disk and network, and reports node/container information to the ResourceManager. It does not decide the resource allocation policy for the whole cluster.
Role of the ApplicationMaster (AM)
Each application has an ApplicationMaster that negotiates resources from the ResourceManager and works with NodeManagers to execute and monitor that application's tasks. Application-specific progress and task coordination belong here, rather than in the ResourceManager's Scheduler. An application may be a single job or a directed acyclic graph of jobs.
| Component | Scope | Main responsibility | Do not confuse it with |
|---|---|---|---|
| ResourceManager | Cluster | Resource allocation and application admission | NameNode, which manages HDFS metadata |
| NodeManager | One worker machine | Container lifecycle and local resource monitoring | DataNode, which stores HDFS blocks |
| ApplicationMaster | One application | Request resources and coordinate/monitor tasks | The cluster-wide Scheduler |
Worked example: a word-count application
- The client submits the application to the ResourceManager.
- The ApplicationsManager arranges the first container for the ApplicationMaster.
- The ApplicationMaster requests resources for the application's tasks.
- The Scheduler allocates suitable resources; the ApplicationMaster asks the relevant NodeManagers to launch task containers.
- NodeManagers manage those local containers and report their status/resource use. The ApplicationMaster tracks the application's task progress.
Conclusion: The RM decides how cluster resources are allocated. Each NM runs and monitors containers on its machine. The AM coordinates the tasks of one application. A container represents allocated execution resources, not necessarily a Docker container.
Short exam questions and answers
It is the cluster-level resource authority in Hadoop YARN. Its Scheduler allocates resources among applications, while its ApplicationsManager accepts submissions and arranges the ApplicationMaster's initial container.
It is the per-machine YARN agent. It launches and manages containers, monitors their resource usage, and reports node/container information to the ResourceManager.
The AM coordinates one application's tasks across nodes. An NM manages containers on one machine, which may run work from several applications.
No. It allocates resources. Application-specific task monitoring and coordination belong to the ApplicationMaster; the ApplicationsManager provides the service for restarting a failed AM container.
Yes. HA deployments use active/standby ResourceManagers, with one active at a time.
Official references: Apache Hadoop YARN architecture and ResourceManager high availability.
7. Map, shuffle and reduce
Map emits intermediate key/value data, shuffle brings matching keys together, and reduce combines each key's group. Transfer and skew often dominate.
Answer: No. It illustrates aggregation semantics only.
Input records -> map: intermediate key/value -> shuffle: matching keys together -> reduce: one result per key -> output under sink policy
8. Combiners and algebraic correctness
A combiner is optional and cannot be assumed to run once or at all. Combining must preserve the final result under legal regrouping.
Answer: No. Weight by counts or combine sufficient statistics.
Sum/count combiner versus unweighted means
partitions = [[2,4], [10]]
stats = [(sum(part), len(part)) for part in partitions]
mean = sum(s for s,n in stats) / sum(n for s,n in stats)
wrong = sum(s/n for s,n in stats) / len(stats)
assert mean == 16/3 and wrong == 6.5
print("partition sum/count:", stats)
print("global mean:", format(mean,".6f"))
print("unweighted mean-of-means:", wrong)
print("Local algebra demo, not a Hadoop combiner execution claim.")
Checked output:
partition sum/count: [(6, 2), (10, 1)] global mean: 5.333333 unweighted mean-of-means: 6.5 Local algebra demo, not a Hadoop combiner execution claim.
9. Spark RDDs and lineage
RDDs are distributed collections with transformation dependencies. Lineage supports recomputation under relevant assumptions; persistence policy and source availability still matter.
Answer: No. Side effects need their own design.
10. DataFrames, schema and SQL planning
DataFrames represent named typed columns and enable SQL-like optimization. Validate schemas/units and inspect plans when performance or semantics matter.
Answer: No. Valid rewrites must preserve semantics.
11. Lazy transformations and actions
Transformations commonly build execution dependencies/plans; actions trigger work. Some APIs include analysis/eager behaviors, so inspect the actual operation.
Answer: No. Run the action and check actual results.
12. Shuffle, joins and skew
Redistribution groups data across workers and can cost network, disk and memory. Join strategy and skew depend on data sizes/distribution and actual plan.
Answer: No. The key's partitioning behavior remains a bottleneck.
13. Caching, memory and driver limits
Caching is a deliberate reuse choice; data may spill/evict or be recomputed. collect brings results to the driver, which can become a memory bottleneck.
Answer: No. Storage levels and execution determine behavior.
14. Batch, streams and ETL/ELT
Batch processes bounded input; streams handle ongoing input with state/time policies. ETL transforms before target loading; ELT transforms after loading.
Answer: No. Triggers, sources, state and sinks affect latency.
15. Event time and processing time
Event time reflects occurrence timestamps; processing time reflects handling/arrival. Their distinction matters for late/out-of-order data.
Answer: Not generally. Delays and retries reorder events.
16. Tumbling/sliding windows and boundaries
A tumbling window partitions time into non-overlapping intervals; sliding windows overlap. Define units, interval endpoints and timestamp parsing explicitly.
Answer: No. The upper bound is excluded and next lower bound included.
5-minute half-open tumbling windows: [0,5): minute 0,1,2,3,4 [5,10): minute 5,6,7,8,9
17. Watermarks and late-data policies
Watermarks/state cleanup express system-specific assumptions about progress/lateness. Accepted/drop/update behavior depends on actual query and configuration.
Answer: No. Query mode, state and runtime rules matter.
18. Retries, checkpoints and deduplication
Retries can repeat processing/delivery. Stable event IDs, checkpoints and idempotent writes address different boundaries; retention horizons limit deduplication.
Answer: No. A conflict policy is separate.
Stable-ID deduplication with explicit conflict rejection
from collections import defaultdict
# Event times are integer minutes; finite replay, no watermark implementation.
events = [("a",1,10),("b",4,20),("a",1,10),("c",5,30)]
seen = {}; windows = defaultdict(int)
for key, minute, amount in events:
payload = (minute,amount)
if key in seen:
if seen[key] != payload: raise ValueError("conflicting payload")
continue
seen[key] = payload
start = minute//5*5
windows[start] += amount
assert dict(windows) == {0:30,5:30}
print("unique IDs:", len(seen))
print("window totals:", sorted(windows.items()))
conflict = ("a",1,99)
print("conflicting a detected:", seen[conflict[0]] != conflict[1:])
print("Finite in-memory policy demo; no distributed checkpoint or late-data guarantee.")
Checked output:
unique IDs: 3 window totals: [(0, 30), (5, 30)] conflicting a detected: True Finite in-memory policy demo; no distributed checkpoint or late-data guarantee.
19. Delivery semantics and end-to-end effects
At-most-once, at-least-once and exactly-once claims need a named boundary. Source, processor and sink must cooperate for a particular end-to-end guarantee.
Answer: No. Verify the scope and sink behavior.
20. Formats, schema evolution and quality
Typed schemas, field units, null/error policies and evolution rules prevent silent meaning changes. Columnar formats can help selective analytics but are not universal fixes.
Answer: No. Semantic validation is separate.
21. NoSQL models and query tradeoffs
Key-value, document, wide-column and graph models support different access patterns. Choose by queries, consistency/failure behavior and operational limits.
Answer: No. Features depend on the actual system.
22. Analytics types and causal caution
Descriptive, diagnostic, predictive and prescriptive analyses answer different questions. Correlation does not identify causation without an appropriate design.
Answer: No. Confounding and design need consideration.
23. Evaluation, time splits and numerical metrics
Use unseen relevant data and time-aware boundaries for forecasting; fit preprocessing on training only. State metric counts/units and compare baselines.
Answer: No. Evaluate against the intended future/unseen setting.
Grouped filtering and exact MAE calculation
from collections import defaultdict
orders = [("A",100),("B",30),("A",50)]
totals = defaultdict(int)
for customer, amount in orders:
if amount >= 50: totals[customer] += amount
actual = [10,20,30]; predicted = [12,17,34]
errors = [abs(a-p) for a,p in zip(actual,predicted)]
assert dict(totals) == {"A":150} and errors == [2,3,4]
print("filtered customer sums:", sorted(totals.items()))
print("absolute errors:", errors)
print("MAE:", sum(errors)/len(errors))
print("Local finite-data calculation, not a Spark execution or generalization result.")
Checked output:
filtered customer sums: [('A', 150)]
absolute errors: [2, 3, 4]
MAE: 3.0
Local finite-data calculation, not a Spark execution or generalization result.
24. Privacy, access and operational evidence
Minimize sensitive fields, enforce access, protect logs/secrets and document retention. Observe lag, throughput, errors and restore/replay behavior without overstating live state.
Answer: No. Copies and pipelines can increase disclosure surfaces.
25. End-to-end pipeline and exam checklist
Trace ingestion, validation, partitioning, processing, output and recovery boundaries. Show correct units/results, retry policy and limitations.
Answer: Explicit workload/failure assumptions, correct semantics, worked calculations and scoped evidence.
Source -> validate/schema -> partition -> process/checkpoint -> permitted sink -> reconciliation + replay/restore evidence
Storage distinctions
| Mechanism | Purpose | Limit |
|---|---|---|
| Partition | Spread records/work | Skew and cross-partition costs |
| Replication | Current copies/availability | Logical deletion can propagate |
| Backup | Recover historical state | Actual restore test needed |
| Cache | Reuse chosen computation/data | Eviction/spill/recompute possible |
Time and processing models
| Term | Meaning | Check |
|---|---|---|
| Batch | Bounded run input | Replay/input version |
| Stream | Ongoing input/state | Checkpoint and sink policy |
| Event time | Occurrence timestamp | Parsing and late-data rule |
| Processing time | Handling/arrival clock | Not occurrence order |
| Tumbling window | Non-overlapping intervals | Endpoint/unit convention |
Semantic and evaluation pitfalls
| Mistake | Better evidence |
|---|---|
| Mean of unequal partition means | Combine sums and counts |
| Counting retry twice | Stable ID plus conflict/idempotency policy |
| Exactly-once without scope | Name source/processor/sink boundary |
| Timing plan construction as full work | Run actions and measure actual result |
| Huge collect to inspect data | Bounded samples/aggregates with stated limits |
| Training score as forecast proof | Relevant unseen/time-separated evaluation |
Revision checklist
Check units, raw versus replicated storage, partition skew, shuffle, lazy actions and driver limits. Explain event versus processing time, window endpoints and retry boundaries. State privacy and restore assumptions. Local toy output is not evidence of a live cluster guarantee.
Resources and sources
Original sources are preserved alongside official framework references. Runtime guarantees/settings depend on version, query and source/sink configuration.
Comments
Post a Comment