Part VIII: Case Studies and Capstone Projects
Chapter 38: Distributed Recommendation at Scale

Distributed Recommendation at Scale

The third case study: one recommender that serves billions of items to hundreds of millions of users in tens of milliseconds, where the model is too large for any single machine and is sharded by construction.

Conceptual illustration for Chapter 38: Distributed Recommendation at Scale

"I hold one slice of the embedding table, roughly forty million users I will never describe to you, and when a request arrives I look up my fragment, ship it onward, and trust the other ninety-nine shards to remember the rest. Together we are a model. Alone I am a hash bucket with opinions."

An Embedding Shard That Knows Its Place in the Table

Chapter Overview

Part VIII assembles the book into end-to-end systems, and this is its third and most omnivorous assembly: a production recommender that draws on nearly every axis of distribution at once. The first case study could centralize its corpus because the open web is public, and spent its engineering on scale. The second could centralize nothing, and spent its engineering on privacy. This one centralizes the data freely but cannot centralize the model: the embedding tables that map billions of items and hundreds of millions of users into learned vectors are, at production dimensionality, measured in terabytes, and no single machine holds a terabyte of fast memory. So the model is sharded before anything else happens, partitioned across a fleet exactly as the parameter servers and distributed embedding tables of Chapter 11 describe. That single fact, the model does not fit, organizes the chapter the way the no-data-movement constraint organized the last one.

The final stretch draws the system as a whole and hands it to the reader. Section 38.8 assembles the full system architecture, tracing one request through retrieval, ranking, feature lookup, and logging across the fleets that serve it, and accounting for the millisecond budget at every hop. Section 38.9 closes with a project extension that hands the reader the levers, adding a retrieval source, swapping the ranking model, tightening the latency budget, or wiring a contextual bandit into the serving loop, so the case study becomes a system to build and defend rather than only to read. Read in order, the nine sections make the argument the rest of Part VIII repeats in other domains: a real distributed AI system is shaped by its binding constraint, and when that constraint is a model too large to fit on one machine under a latency budget too tight to touch every item, sharding, the funnel, and online evaluation stop being features and become the architecture.

Prerequisites

This chapter is a synthesis, so it assumes the parts it composes rather than reteaching them. From Chapter 11 it assumes the parameter-server architecture and the sharded embedding tables that are the spine of the whole recommender, the push-pull lookup pattern that Section 38.2 turns into an online serving layer. From Chapter 25 it assumes distributed retrieval and approximate nearest neighbor over sharded indexes, the machinery that Section 38.3 uses to narrow billions of candidates to thousands. From Chapter 15 it assumes data-parallel training, the loop that fits the ranking and embedding models offline before they are served. From Chapter 9 it assumes stream processing and online AI, the freshness pipelines that Section 38.6 folds into real-time personalization. From Chapters 23 and 24 it assumes distributed inference and fleet serving, the request-level discipline that Section 38.4 and Section 38.8 hold to a millisecond budget. From Chapter 5 it assumes the evaluation methodology that Section 38.7 turns into online A/B testing. A reader comfortable with those threads can read this chapter as the place where sharded models, distributed retrieval, streaming features, and online experiments finally run together on one latency-bound system.

Learning Objectives

The One Idea to Carry Out of This Chapter

If you keep one thing from this chapter, keep this: when the model itself is too large to fit on one machine, it is sharded before a single prediction is made, and every other piece of the system, the retrieve-then-rank funnel, the feature store, the streaming personalization, the online experiment, exists to serve that sharded model fast enough and freshly enough to matter. The first case study distributed compute to reach a scale of data; the second moved the model to respect a constraint on data. This one partitions the model because the parameters, terabytes of learned embeddings, do not fit anywhere whole. That single fact reshapes everything downstream. The model cannot be scored against the whole catalog per request, so a cheap distributed retrieval pass narrows billions of items to thousands before an expensive distributed ranking pass scores them. The same features must reach training and serving without drifting apart, so a feature store becomes shared infrastructure rather than a convenience. A user's last few actions carry the most signal and decay the fastest, so streaming personalization lives on the serving path inside the latency budget. And an offline metric can improve while the product gets worse, so online evaluation is the only verdict that counts. Read forward, the chapter walks that system from the recommendation problem to the deployed, measured, continuously experimented fleet. Read as a question, it is the checklist you carry into any scale-bound serving system: which parameters refuse to fit, how does the funnel avoid touching every item, and does the live metric actually move? The roadmap below walks the nine sections that build that system end to end.

Chapter Roadmap

What's Next?

This chapter built a distributed AI system around a model too large to fit on one machine, served to hundreds of millions of users under a tens-of-milliseconds budget through a sharded retrieve-then-rank funnel. Chapter 39: Multi-Agent Robotics and Drone Swarms moves the distribution from the serving fleet into the physical world. The next case study trades a fleet of stateless services that any load balancer can route between for a swarm of embodied agents, each with its own sensors, its own position, and its own partial view, that must coordinate to act as one without a central controller in the loop. Where this chapter distributed a single model across machines that share a data center and a clock, the next distributes intelligence across robots that share neither, and the coordination, consensus, and partial-observability problems the recommender could push to its infrastructure become the agents' own responsibility. The distributed reinforcement learning infrastructure of Chapter 20 and the multi-agent reinforcement learning of Chapter 30 return there as the brains of a physical swarm. Read it next to see the same composition discipline tested against distribution that is embodied rather than served: not a model spread across a cluster, but minds spread across machines that move.

Bibliography & Further Reading

Models & Ranking

Naumov, M., Mudigere, D., Shi, H.-J. M., et al. "Deep Learning Recommendation Model for Personalization and Recommendation Systems (DLRM)." 2019. arXiv:1906.00091

The open reference architecture for an industrial recommender: large sharded embedding tables for categorical features combined with a dense network, and the model-parallel embedding plus data-parallel MLP split that Section 38.2 and Section 38.4 build on.

📄 Paper

Covington, P., Adams, J., Sargin, E. "Deep Neural Networks for YouTube Recommendations." ACM RecSys 2016. research.google

The paper that made the retrieve-then-rank funnel canonical: a candidate-generation network narrows millions of videos to hundreds, then a ranking network scores them, the two-stage design at the heart of Sections 38.3 and 38.4.

📄 Paper

Cheng, H.-T., Koc, L., Harmsen, J., et al. "Wide & Deep Learning for Recommender Systems." DLRS 2016. arXiv:1606.07792

Joins a wide linear model that memorizes feature crosses with a deep network that generalizes, the template for the ranking models that score the survivors of retrieval in Section 38.4.

📄 Paper

Wang, R., Fu, B., Fu, G., Wang, M. "Deep & Cross Network for Ad Click Predictions (DCN)." ADKDD 2017. arXiv:1708.05123

Learns bounded-degree feature interactions explicitly through a cross network, removing the hand-engineering that wide-and-deep still needed; a workhorse ranking architecture for the deep scoring stage of Section 38.4.

📄 Paper

Koren, Y., Bell, R., Volinsky, C. "Matrix Factorization Techniques for Recommender Systems." IEEE Computer 42(8), 2009. ieeexplore.ieee.org

The classic that framed recommendation as learning user and item vectors whose dot product predicts preference; the conceptual ancestor of the learned embeddings that Section 38.2 shards across a fleet.

📄 Paper

Retrieval & Systems

Zhai, J., Liao, X., Liu, S., et al. "Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations." 2024. arXiv:2402.17152

Introduces HSTU-style generative recommenders, reports industrial-scale online gains and scaling behavior, and grounds the semantic-ID and sequence-generation discussion added to Section 38.3.

📄 Paper

Meta RecSys. "Generative Recommenders." GitHub repository. github.com/meta-recsys/generative-recommenders

Open implementation and configurations for Meta's generative recommender models, useful for connecting the HSTU concept to reproducible model and serving artifacts.

🔧 Tool

Spotify Research. "Semantic IDs for Generative Search and Recommendation." 2025. research.atspotify.com

Explains how catalog embeddings can be converted into semantic IDs and used as tokens in a joint generative search and recommendation model, the practical mechanism behind the semantic-ID candidate source in Section 38.3.

📝 Blog Post

Johnson, J., Douze, M., Jegou, H. "Billion-Scale Similarity Search with GPUs (FAISS)." IEEE Transactions on Big Data, 2019. arXiv:1702.08734

The library and methods behind GPU-accelerated approximate nearest neighbor at billion-vector scale; the retrieval engine that turns an embedding lookup into the candidate-generation pass of Section 38.3.

🔧 Tool

Guo, R., Sun, P., Lindgren, E., et al. "Accelerating Large-Scale Inference with Anisotropic Vector Quantization (ScaNN)." ICML 2020. arXiv:1908.10396

A quantization scheme tuned to preserve the inner products that ranking cares about, pushing the speed-recall frontier of the retrieval pass that feeds the funnel in Section 38.3.

📄 Paper

Li, M., Andersen, D. G., Park, J. W., et al. "Scaling Distributed Machine Learning with the Parameter Server." OSDI 2014. usenix.org

The canonical parameter-server design whose sharded key-value store holds the embedding tables of this chapter; the push-pull architecture that Section 38.2 turns into an online serving layer.

📄 Paper

Evaluation & Bandits

Kohavi, R., Deng, A., Frasca, B., et al. "Online Controlled Experiments at Large Scale." ACM KDD 2013. kdd.org

The reference on running trustworthy A/B tests at industrial scale, the pitfalls, the variance, and the discipline; the methodology that Section 38.7 applies to decide whether a recommender change actually helps.

📄 Paper

Li, L., Chu, W., Langford, J., Schapire, R. E. "A Contextual-Bandit Approach to Personalized News Article Recommendation (LinUCB)." WWW 2010. arXiv:1003.0146

Frames recommendation as a contextual bandit that balances exploiting known-good items against exploring uncertain ones; the online-learning lever that the project extension of Section 38.9 wires into the serving loop.

📄 Paper