Build Log / Entry 001 / Field notes

Self-service Spark for data scientists, in 2017.

In 2017, Deloitte's data scientists needed to run ML jobs on tens of terabytes without touching Spark. What we built, and what we'd build with today.

The short version

  • Let data scientists submit jobs, not clusters: an API that resolves datasets by name hides Spark entirely.
  • Keep storage separate from compute: moving to Parquet on S3 was the main source of an 80% cut in processing cost.
  • Enforce PII and PHI masking in the platform, not in each data scientist's code.
  • Today, build it from open source: Spark Connect, Spark on Kubernetes, Iceberg, catalog-level masking and MLflow.
Published
Read
5 min
Written by
Data team
Stack
Apache Spark · Amazon EC2 · Amazon S3 · Parquet
In this entry · 7 sections
  1. 01The problem in 2017
  2. 02A job, not a cluster
  3. 03Clusters swapped behind the API
  4. 04Spark without Hadoop
  5. 05Sensitive data handled by the platform
  6. 06What we’d do differently today
  7. 07The results

In 2017 and 2018 we built a self-service machine learning platform for Deloitte. The goal was narrow: let data scientists run a job quickly, against tens of terabytes of data, without having to think about the back end.

Most of what we built by hand is now a standard feature of managed data platforms. This entry looks back at what the platform did, what each piece is called today, and what we would build it with now. It’s eight years on, so it covers design decisions rather than configuration values.

The problem in 2017

Deloitte’s data scientists wrote ML algorithms in Python, Scala and Java. Running one on Spark meant knowing Spark: which cluster to submit to, how to size executors, where the input files lived in storage, which libraries were on the classpath. None of that had anything to do with the algorithm.

Hosted platforms had their own ways to run jobs, but for Spark running on infrastructure you controlled, there was no simple, standard way to submit a job without knowing the cluster. Apache Livy, the closest open-source option, had only entered the Apache Incubator in June 2017, and officially supported running jobs locally or on Hadoop’s YARN. AWS Glue launched that August as a serverless ETL service, not a place to iterate on ML algorithms.

Fig. 001.1: Data scientists name a dataset and an algorithm; the API decides which cluster runs it. The cluster can be replaced without anyone changing how they submit.

A job, not a cluster

The platform’s central idea was that a data scientist submits a job, never a cluster. A job referenced its data and its logic by name: a dataset, an algorithm, its parameters. The platform resolved the rest: where the dataset lived in S3, which cluster would run the job, and how that cluster was configured.

That abstraction is what made the platform fast to use. A data scientist could go from a new idea to a job running against the full dataset without learning anything about Spark beyond the API of their own language.

Clusters swapped behind the API

Because every job went through the API, the cluster underneath was ours to change. When we needed a new Spark version or a different configuration, we brought up a new cluster, pointed the API at it, and retired the old one. Data scientists kept submitting jobs the same way throughout.

Spark without Hadoop

In 2017, running Spark at this scale usually meant running it on Hadoop: YARN to schedule it, HDFS to store the data. Amazon EMR packaged that whole stack. We ran Spark Standalone on EC2 instead, with the data in Parquet on S3 and no HDFS at all, so storage and compute could scale separately.

That separation is now the default design for a data platform. In 2017 it took more care: S3 only became strongly consistent in December 2020, and Spark’s tooling assumed HDFS in more places than it does now. Moving the data to Parquet, a columnar format, meant a job paid only for the columns it read, and that change was the main source of the 80% cut in processing cost.

Sensitive data handled by the platform

Some of the data included PII and PHI. The platform masked or dropped those columns before a job ran, according to the submitter’s permissions, so each data scientist didn’t have to handle it correctly in their own code. Column-level masking is now a built-in feature of data catalogs; in 2017, it was code we wrote.

What we’d do differently today

We’d keep the shape: data scientists submit jobs, not clusters; the platform owns the rules about data access; storage stays separate from compute. Most of the parts we built by hand, we’d now take from open-source projects instead.

  • Job submission: Spark Connect. Since Spark 3.4 (April 2023), Spark itself separates a thin client from the cluster it runs on. Much of what our REST API did by hand is now part of Spark. We’d still put a small API in front of it, to resolve datasets by name, but it would be far less code.
  • The cluster: Spark on Kubernetes. Spark’s Kubernetes support has been production-ready since Spark 3.1.1 (March 2021). Each job gets its own executors, so one data scientist’s heavy job doesn’t slow down another’s, and replacing the cluster becomes a routine node upgrade rather than a migration.
  • The data: Apache Iceberg tables. Plain Parquet files on S3 worked, but an open table format such as Iceberg (or Delta Lake) adds schema changes without rewriting data, safe concurrent writes and a catalog of tables. For ML, its time travel matters most: a model can be retrained on exactly the data it was first trained on.
  • Data access: masking in the catalog. We’d put PII and PHI rules in a catalog such as Unity Catalog (open source since June 2024) or Apache Ranger, so the engine enforces them however a job reads the data. Where jobs need to join on an identifier, such as a patient ID, we’d tokenize it rather than null it, so the join still works without exposing the value.
  • Experiments: MLflow. First released by Databricks in June 2018, MLflow records each run’s parameters, metrics and resulting model. Paired with Iceberg’s time travel, it means any result can be traced back to the exact code and data that produced it.

The results

The platform went from a blank page to production in six months, cut processing cost by 80%, and ran with no PII or PHI exposure incidents. The full story, including how the work split between us and Deloitte’s engineers and data scientists, is in the Deloitte ML platform case study.

Let's Discuss
Your Ideas

Tell us what you're building. We'll tell you how we'd approach it.

Schedule a call