Shopify's Playbook for Scaling Machine Learning
Shopify's approach to scaling machine learning grew out of its first ML product, an order fraud detector that replaced a rule-based system with a high false-positive rate. Teams should pick a problem users care about, confirm the data is trustworthy and accessible, account for downstream dependencies such as fulfillment, and optimize for product outcomes rather than raw model scores. Shopify shipped a simple logistic regression model, built in Python, serialized to PMML, scheduled with Airflow and served in real time from Rails. To scale to hundreds of models, Shopify relies on input/output reconciliation, shadow backtesting, drift monitoring, platform-enforced best practices and automated model operations.
Related posts
- 5 Steps for Building Machine Learning Models for Business
Shopify Engineering mediumAdeptA five-step workflow for building ML models in a business context: confirm ML is warranted (defer it for brand-new products and beat a heuristic baseline first), start with simple models and basic features or off-the-shelf pretrained components, and pick a metric tied to business impact before optimizing. The advice also covers sanity-checking outputs via confusion matrices and residuals, since 98% accuracy on rare-event fraud data can mean a useless model. Model iteration should run through staging flows or A/B tests with fair comparisons and attention to run-to-run variance, and teams should watch prediction stability for individual users across retrains.
- Unlocking Real-time Predictions with Shopify's Machine Learning Platform
Shopify Engineering mediumAdeptShopify extended its Ray-based Merlin ML platform with online inference, running each real-time model as a dedicated service in its own namespace on GKE that loads models from the Comet ML registry and can read features from the Feast-based Pano store. The serving layer is written in Python and offers three tiers: no-code MLServer configs, low-code custom MLServer classes, and fully custom FastAPI services, all scaffolded by a Merlin CLI from cookiecutter templates. Users test serving layers in short-lived Merlin Workspaces, then deploy through Shopify's standard Services DB, Buildkite and Shipit pipelines with separate staging and production configs for autoscaling and resource tuning.
- The Magic of Merlin: Shopify's New Machine Learning Platform
Shopify Engineering mediumAdeptMerlin is Shopify's redesigned ML platform built on open source tools. It uses Ray clusters running on Kubernetes as short-lived, per-use-case "Merlin Workspaces", and "Merlin Projects" are Docker images with isolated Python environments built through CI/CD. Data scientists prototype from JupyterHub through the Ray Client, then productionize by scheduling Airflow DAGs that create a workspace, run the job and tear it down, with Datadog and Splunk for monitoring. Onboarding the product categorization model took few code changes: Ray Train distributed TensorFlow training, and Ray ActorPool distributed multi-step batch inference.
- Rocket Money x Hugging Face: Scaling Volatile ML Models in Production
Hugging Face easyNoviceRocket Money replaced a regex-and-decision-table merchant detector with a BERT-family transformer classifier spanning 4000+ classes, served through Hugging Face's hosted Inference API rather than an in-house MLOps stack. They picked it over AWS SageMaker and a hand-rolled host after a three-month evaluation with gradual traffic ramps and worst-case load tests. An A/B split of new users showed better paid retention, and the rollout reached 100% over two months. A pre-inference cache cut costs, hitting about 85% hit rate in production against a theoretical 93%, as volume grew past a billion transactions per month. The team hit an outage when expanding classes and a stale-model caching bug on the vendor side, and so far has found LLMs slower and costlier than specialized classifiers.
- Training Orchestrator: Unifying Model Training at Yelp
Yelp Engineering mediumAdeptYelp's Training Orchestrator replaces per-team monolithic Spark training scripts with a declarative, configuration-driven framework. Pipelines are composed of typed steps whose dependencies form a DAG executed in topological order. Pydantic configs validate parameters and step input/output schemas up front, and injected Spark/MLflow context lets the same pipeline run locally, in Jupyter or in production. The payoff is local runs and unit-testable steps, config errors caught in seconds instead of hours into training, automatic MLflow logging of full configs for reproducibility, and swappable settings-plus-function pairs for reuse across batches.