Distributed Computing
Distributed computing is what allows for storage and processing of massive datasets across multiple machines.
Let’s talk about some of the tools and frameworks that make this type of distributed computing possible.
This Lesson Will Cover
- 🌍 Distributed Computing Fundamentals
- 🏗️ Apache Hadoop Architecture & Components
- ⚡ Apache Spark Overview & Features
- 🗄️ Distributed Storage Systems
- 💻 Code Examples & Best Practices
What is Distributed Computing?
Distributed computing splits computational tasks across multiple machines, or nodes, working together as a cohesive system. This allows us to process datasets that are too large for a single machine to handle effectively.
For ML, distributed computing is essential for tasks like data processing, model training and batch predictions.
Apache Hadoop
Apache Hadoop was one of the pioneering frameworks for distributed computing, originally developed by Yahoo in 2006 based on Google’s MapReduce paper.
Key Components
- HDFS (Hadoop Distributed File System):
- A fault-tolerant storage system designed to scale across many machines. It splits large files into blocks, replicates them across multiple nodes for redundancy, and provides automatic failure recovery.
- MapReduce:
- A programming model for processing large datasets in parallel.
- The Map phase splits data and processes it in parallel
- The Reduce phrase aggregates results from mapped data
- This model distributes complex computations by breaking them down into smaller tasks that can be distributed across a cluster.
Historical Impact & Legacy
While Hadoop was groundbreaking in the early 2000s, modern organizations have largely moved away from it due to:
- Complex configuration and maintenance requirements
- Limited programming model compared to modern alternatives
- Poor performance with interactive (e.g., ad-hoc SQL queries) and iterative (e.g., training a machine learning model) workloads
Today, Hadoop primarily exists in legacy systems, with organizations increasingly adopting more modern solutions like:
- Apache Spark for distributed processing
- Cloud-native services (AWS EMR, Google Dataproc)
- Modern data lakehouse architectures (Databricks, Snowflake)
Here’s how you might interact with Hadoop:
# Upload a local CSV file to HDFS
hdfs dfs -put sales_data.csv /data/input/
# Run MapReduce job to aggregate sales by region
hadoop jar sales-aggregator.jar \
/data/input/sales_data.csv \
/data/output/sales_by_region
# Check that the job completed successfully
hdfs dfs -ls /data/output/sales_by_region
# Download the results back to local machine
hdfs dfs -get /data/output/sales_by_region/part-00000 ./local_sales_report.csv
# Clean up input/output data from HDFS when done
hdfs dfs -rm -r /data/input/sales_data.csv
hdfs dfs -rm -r /data/output/sales_by_region
Apache Spark
Apache Spark builds on the strengths of Hadoop but introduces significant speed and ease-of-use improvements due to its in-memory processing capabilities, optimized execution engine, and more flexible programming model.
Unlike Hadoop’s disk-based MapReduce, Spark keeps data in memory between operations, reducing I/O overhead and enabling much faster iterative computations.
Core Features of Spark
- RDDs (Resilient Distributed Datasets): Immutable data structures distributed across a cluster.
- In-Memory Processing: Enables faster computations by reducing disk I/O.
- Wide Language Support: APIs for Python, Java, Scala, and R.
- Libraries for AI Tasks: Spark MLlib for scalable machine learning.
Example: Word count using PySpark
from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("WordCount").getOrCreate()
text_file = spark.read.text("input.txt")
words = text_file.selectExpr("explode(split(value, ' ')) as word")
word_counts = words.groupBy("word").count()
word_counts.show()
Distributed Storage Systems
For distributed computing to work, we need distributed storage systems that can handle massive amounts of data, by scaling horizontally across multiple machines.
Distributed Storage System Examples
- HDFS (Hadoop Distributed File System): Part of the Hadoop ecosystem, designed for high-throughput data access.
- Amazon S3: A cloud-based object storage service offering high durability and availability.
- Google Cloud Storage: Google’s version of s3.
- Azure Blob Storage: Microsoft’s version of s3.
Example: Using Spark with s3
df = spark.read.format("csv").option("header", "true").load("s3://my-bucket/data.csv")
df.write.format("parquet").save("s3://my-bucket/output/")
Conclusion
If you’re working with big data then you need a distributed compute solution.
It’s that simple.
The solutions, however (as you can see here), are not simple at all.
Key Takeaways
🌍 Distributed computing enables the processing of massive datasets by splitting work across multiple machines.
🛠️ Apache Hadoop pioneered distributed computing but has largely been replaced by more modern solutions.
⚡ Apache Spark offers significant improvements over Hadoop with in-memory processing and better APIs.
☁️ Cloud storage solutions like S3, GCS, and Azure Blob provide scalable distributed storage options.
🔄 Modern data processing often combines distributed computing with cloud infrastructure.
🎯 Understanding these fundamentals is crucial for working with big data and ML at scale.
Next: Data Warehousing Solutions
The tools in this section are suitable for regular batch-style workloads or ad-hoc analysis and ML jobs. But they are not suitable for storing, maintaining and querying structured analytics-oriented datasets.
For that, we want to use a data warehouse.
Comments (0)
No comments yet.