Recent Posts
Archives

Posts Tagged ‘Spark’

PostHeaderIcon [DevoxxFR2026] Production Troubleshooting: Enhancing Diagnostic Skills Through a Real-World Case Study

Lecturer

William Montaz is a technical leader at Criteo, where he tackles complex production issues in large-scale distributed systems. With extensive experience in machine learning infrastructure and data pipelines, he emphasizes methodical investigation techniques and cognitive bias awareness in high-stakes debugging scenarios.

Abstract

Critical incidents trigger immediate pressure: inconsistent data, unpredictable behaviors, and alarmed stakeholders. The instinctive response often involves blaming the most recent change or following intuition, frequently without meaningful progress. William Montaz guides participants through a genuine technical investigation where Apache Spark serves merely as context for a deeper exploration of methodology. The session demonstrates constructing systematic inquiries in unfamiliar territory, avoiding confirmation bias, breaking down obscure problems into testable hypotheses, and distinguishing correlation from causation. Through this concrete case of corrupted Spark job outputs during a datacenter migration, attendees learn practical skills for effective production troubleshooting.

The High-Stakes Nature of Production Incidents

Production environments demand rapid, accurate diagnosis under intense pressure. When jobs begin producing corrupted data—duplicate rows alongside missing entries—stakeholders naturally seek quick explanations. The temptation to attribute issues to recent changes or visible symptoms often leads investigations astray. Effective troubleshooting requires disciplined methodology rather than reactive speculation.

In large-scale data platforms like Criteo’s, where millions of containers process petabytes daily, incidents can cascade rapidly. Understanding both technical details and cognitive pitfalls becomes essential for resolution.

MapReduce and Spark: Foundational Concepts for the Investigation

To appreciate the case, familiarity with core distributed processing concepts proves valuable. MapReduce provides a framework for parallel computation across large datasets. The classic word count example illustrates the pattern: a map phase extracts key-value pairs (words as keys, counts as values), followed by shuffling to group related keys, and a reduce phase aggregates results.

Spark builds upon these principles with optimizations for iterative processing and in-memory computation. Jobs compile into directed acyclic graphs (DAGs) of stages, where each stage typically ends with a shuffle operation. This architecture enables fault tolerance through recomputation of failed tasks but introduces complexities around data consistency during retries.

Understanding these mechanics helps frame hypotheses about potential failure modes in distributed environments.

The Incident: Corrupted Data During Datacenter Migration

The reported issue involved Spark jobs producing inconsistent outputs with both missing and duplicated rows. The problem appeared intermittently, resolving after multiple retries. Context proved crucial: the organization was migrating its massive compute infrastructure between datacenters under tight timelines.

Initial observations suggested possible connections to the migration. Data replication across sites introduced network latency and potential consistency challenges. However, jumping to conclusions risked confirmation bias. Multiple hypotheses required systematic evaluation.

One theory posited replication inconsistencies between datacenters causing read anomalies. Another focused on increased disk pressure from migration activities leading to timeouts in shuffle operations. A third examined custom components like Kyuubi and AQ used for performance optimizations in the final job stages.

Systematic Investigation: Avoiding Cognitive Biases

Effective diagnosis demands awareness of common cognitive traps. The availability heuristic might overemphasize recent migration activities. Authority bias could discourage questioning framework behavior. Confirmation bias risks pursuing convenient explanations while ignoring contradictory evidence.

The investigation proceeded by gathering concrete data rather than speculating. Reproduction attempts in controlled environments revealed patterns: corruption occurred specifically during partial recomputes of the final stage under certain timing conditions. This narrowed focus to repartition operations and shuffle mechanics.

Code examination and instrumentation provided further clarity. Custom logging and Redis-based tracking of hash codes during repartitioning exposed non-deterministic behavior in floating-point aggregations. Order-dependent summation of floats, combined with retry mechanisms, produced the observed duplicates and omissions.

Root Cause Analysis and Resolution

The true cause emerged from careful observation of Spark’s internal repartition logic. Non-deterministic shuffle ordering during retries, combined with floating-point summation sensitivities, created inconsistent aggregations. The system assumed deterministic behavior across recomputations, an assumption violated under failure conditions.

Resolution involved enforcing deterministic partitioning and explicit sorting before aggregations. This fix eliminated the corruption while maintaining performance characteristics.

The case highlights that symptoms (duplicates, missing rows) traced back through multiple layers: migration pressure, shuffle timeouts, retry mechanics, and subtle numerical properties. Premature conclusions would have missed this chain.

Key Lessons for Production Troubleshooting

Several principles emerge from this investigation. Avoid premature extrapolation and maintain intellectual humility regarding framework perfection. Actively seek disconfirming evidence rather than supporting data. Leverage general knowledge and orders of magnitude to identify anomalies. Reading source code, when accessible, provides invaluable insights.

Presenting partial findings to colleagues surfaces blind spots and strengthens reasoning. Treat production systems with appropriate respect for their complexity while systematically eliminating hypotheses.

These approaches scale beyond Spark to any distributed system. They transform troubleshooting from art to disciplined practice.

Conclusion

Production incidents test both technical knowledge and cognitive discipline. By following methodical investigation practices, acknowledging biases, and pursuing root causes through evidence rather than assumption, teams can resolve complex issues effectively. The Spark corruption case during datacenter migration exemplifies how apparent framework problems often trace to subtle interactions requiring patient, thorough analysis. These skills prove invaluable for maintaining reliable large-scale systems.

Links:

PostHeaderIcon Demystifying Parquet: The Power of Efficient Data Storage in the Cloud

Unlocking the Power of Apache Parquet: A Modern Standard for Data Efficiency

In today’s digital ecosystem, where data volume, velocity, and variety continue to rise, the choice of file format can dramatically impact performance, scalability, and cost. Whether you are an architect designing a cloud-native data platform or a developer managing analytics pipelines, Apache Parquet stands out as a foundational technology you should understand — and probably already rely on.

This article explores what Parquet is, why it matters, and how to work with it in practice — including real examples in Python, Java, Node.js, and Bash for converting and uploading files to Amazon S3.

What Is Apache Parquet?

Apache Parquet is a high-performance, open-source file format designed for efficient columnar data storage. Originally developed by Twitter and Cloudera and now an Apache Software Foundation project, Parquet is purpose-built for use with distributed data processing frameworks like Apache Spark, Hive, Impala, and Drill.

Unlike row-based formats such as CSV or JSON, Parquet organizes data by columns rather than rows. This enables powerful compression, faster retrieval of selected fields, and dramatic performance improvements for analytical queries.

Why Choose Parquet?

✅ Columnar Format = Faster Queries

Because Parquet stores values from the same column together, analytical engines can skip irrelevant data and process only what’s required — reducing I/O and boosting speed.

Compression and Storage Efficiency

Parquet achieves better compression ratios than row-based formats, thanks to the similarity of values in each column. This translates directly into reduced cloud storage costs.

Schema Evolution

Parquet supports schema evolution, enabling your datasets to grow gracefully. New fields can be added over time without breaking existing consumers.

Interoperability

The format is compatible across multiple ecosystems and languages, including Python (Pandas, PyArrow), Java (Spark, Hadoop), and even browser-based analytics tools.

☁️ Using Parquet with Amazon S3

One of the most common modern use cases for Parquet is in conjunction with Amazon S3, where it powers data lakes, ETL pipelines, and serverless analytics via services like Amazon Athena and Redshift Spectrum.

Here’s how you can write Parquet files and upload them to S3 in different environments:

From CSV to Parquet in Practice

Python Example

import pandas as pd

# Load CSV data
df = pd.read_csv("input.csv")

# Save as Parquet
df.to_parquet("output.parquet", engine="pyarrow")

To upload to S3:

import boto3

s3 = boto3.client("s3")
s3.upload_file("output.parquet", "your-bucket", "data/output.parquet")

Node.js Example

Install the required libraries:

npm install aws-sdk

Upload file to S3:

const AWS = require('aws-sdk');
const fs = require('fs');

const s3 = new AWS.S3();
const fileContent = fs.readFileSync('output.parquet');

const params = {
    Bucket: 'your-bucket',
    Key: 'data/output.parquet',
    Body: fileContent
};

s3.upload(params, (err, data) => {
    if (err) throw err;
    console.log(`File uploaded successfully at ${data.Location}`);
});

☕ Java with Apache Spark and AWS SDK

In your pom.xml, include:

<dependency>
    <groupId>org.apache.parquet</groupId>
    <artifactId>parquet-hadoop</artifactId>
    <version>1.12.2</version>
</dependency>
<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-s3</artifactId>
    <version>1.12.470</version>
</dependency>

Spark conversion:

Dataset<Row> df = spark.read().option("header", "true").csv("input.csv");
df.write().parquet("output.parquet");

Upload to S3:

AmazonS3 s3 = AmazonS3ClientBuilder.standard()
    .withRegion("us-west-2")
    .withCredentials(new AWSStaticCredentialsProvider(
        new BasicAWSCredentials("ACCESS_KEY", "SECRET_KEY")))
    .build();

s3.putObject("your-bucket", "data/output.parquet", new File("output.parquet"));

Bash with AWS CLI

aws s3 cp output.parquet s3://your-bucket/data/output.parquet

Final Thoughts

Apache Parquet has quietly become a cornerstone of the modern data stack. It powers everything from ad hoc analytics to petabyte-scale data lakes, bringing consistency and efficiency to how we store and retrieve data.

Whether you are migrating legacy pipelines, designing new AI workloads, or simply optimizing your storage bills — understanding and adopting Parquet can unlock meaningful benefits.

When used in combination with cloud platforms like AWS, the performance, scalability, and cost-efficiency of Parquet-based workflows are hard to beat.


PostHeaderIcon [ScalaDaysNewYork2016] Perfect Scalability: Architecting Limitless Systems

Michael Nash, co-author of Applied Akka Patterns, delivered an insightful exploration of scalability at Scala Days New York 2016, distinguishing it from performance and outlining strategies to achieve near-linear scalability using the Lightbend ecosystem. Michael’s presentation delved into architectural principles, real-world patterns, and tools that enable systems to handle increasing loads without failure.

Scalability vs. Performance

Michael Nash clarified that scalability is the ability to handle greater loads without breaking, distinct from performance, which focuses on processing the same load faster. Using a simple graph, Michael illustrated how performance improvements shift response times downward, while scalability extends the system’s capacity to handle more requests. He cautioned that poorly designed systems hit scalability limits, leading to errors or degraded performance, emphasizing the need for architectures that avoid these bottlenecks.

Avoiding Scalability Pitfalls

Michael identified key enemies of scalability, such as shared databases, synchronous communication, and sequential IDs. He advocated for denormalized, isolated data stores per microservice, using event sourcing and CQRS to decouple systems. For instance, an inventory service can update based on events from a customer service without direct database access, enhancing scalability. Michael also warned against overusing Akka cluster sharding, which introduces overhead, recommending it only when consistency is critical.

Leveraging the Lightbend Ecosystem

The Lightbend ecosystem, including Scala, Akka, and Spark, provides robust tools for scalability, Michael explained. Akka’s actor model supports asynchronous messaging, ideal for distributed systems, while Spark handles large-scale data processing. Tools like Docker, Mesos, and Lightbend’s ConductR streamline deployment and orchestration, enabling rolling upgrades without downtime. Michael emphasized integrating these tools with continuous delivery and deep monitoring to maintain system health under high loads.

Real-World Applications and DevOps

Michael shared case studies from IoT wearables to high-finance systems, highlighting common patterns like event-driven architectures and microservices. He stressed the importance of DevOps in scalable systems, advocating for automated deployment pipelines and monitoring to detect issues early. By embracing failure as inevitable and designing for resilience, systems can scale across data centers, as seen in continent-spanning applications. Michael’s practical advice included starting deployment planning early to avoid scalability bottlenecks.

Links: