Library / Case Studies
Moderating Promotional Spam and Inappropriate Content in Photos at Scale at Yelp
Moderating Promotional Spam and Inappropriate Content in Photos at Scale at Yelp Marcello Tomasini and Jeraz Cooper, Software Engineers May 12, 2021 The trust of our community of consumers and...
By Scale at Yelp engineers · Scale at Yelp · Added 2026-10-12
All content belongs to Scale at Yelp engineers / Scale at Yelp. We only link to it and give credit. Report a problem
Learn this case study
About 37 min left. Your work is saved as you go.
What you are about to study
Scale at Yelp explains a real system. You should know the basics: caching, queues and replication.
Ideas you will meet
- Distributed Systems
- Consensus, time, failure and the fundamentals of scale-out.
- Machine Learning Systems
- Recommendations, ranking, feature stores and serving models at scale.
What we already know about this
Our own lessons on these ideas. Read them here before you start, so it makes sense.
Real-World Systems · 11 minDesign an email system (Gmail)How a message travels between providers over SMTP, how spam and spoofing are filtered, and how a mailbox is stored and searched at huge scale.Read here
The problem
An email system receives and sends messages for billions of mailboxes, stores them for years, keeps spam out, and lets users search and organise (labels, threads).
Requirements
- Reliable delivery: a message is never silently lost.
- Interoperability with every other mail provider.
- Spam, phishing and virus filtering.
- Large attachments, fast search, and strong privacy.
How email moves between providers
Email uses SMTP to send between servers. The key ideas:
- MX records in DNS tell you which servers accept mail for a domain.
- Delivery is store-and-forward: a server accepts a message, persists it, and passes it on, retrying if the next hop is down.
- Clients usually read mail through IMAP (or POP3) or through a provider's web and mobile API.
100%Figure SDA-RWS-02-1 · Servers talk SMTP to each other; readers fetch with IMAP or POP · © forcsguy.com
Image: Tim Sheerman-Chase · CC BY 2.0 · Source · Wikimedia Commons: Old Post Sorting Office, PortsmouthArchitecture
100%Figure SDA-RWS-02-2 · Email delivery architecture · © forcsguy.com
Sending
- The client sends the message to its provider's submission server (with authentication).
- The message is saved and put on an outbound queue, so slow recipients never slow the sender.
- A worker finds the recipient domain's MX hosts, connects with SMTP, and delivers. The worker signs the message (DKIM).
- Temporary failures are retried with backoff for days; permanent failures generate a bounce message.
Receiving
- The incoming server accepts the connection and verifies the sender with SPF, DKIM and DMARC.
- Filters score the message for spam, phishing and malware (rules, reputation, and machine learning).
- The message is written to the user's mailbox: metadata in a scalable database, bodies and attachments in object storage, and an entry in the search index.
- Clients are told (push, IMAP IDLE) that new mail arrived.
100%Figure SDA-RWS-02-3 · Where a received message is stored and how readers are told · © forcsguy.com
Fighting spam and spoofing
Mechanism What it does SPF The domain lists which servers may send for it DKIM The sender signs the message; receivers check the signature DMARC The domain says what to do when SPF or DKIM fail, and gets reports Reputation Track sending behaviour per IP and domain; rate-limit new senders Content filters Spam classifiers, link and attachment scanning Storage design
- A mailbox is append-heavy and read by recent items. Partition by user id, so one user's mail sits together.
- Keep metadata (labels, flags, thread id, snippet) separate from large bodies and attachments.
- Threads group messages by headers (References, In-Reply-To) and subject.
- Search uses an inverted index per user, updated as mail arrives.
- Deduplicate identical large attachments with content hashes.
- Keep multiple replicas and backups: email is people's records.
Scale and reliability
- Queues absorb bursts, for example newsletter sends.
- Rate-limit outgoing mail per account to stop compromised accounts spamming.
- Spread incoming servers across regions; MX records can list several with priorities.
- Privacy: encrypt in transit (TLS between servers) and at rest, and control internal access carefully.
Real-world reading
Related reading
- Marc Brooker's BlogMarc Brooker · brooker.co.zaBlogs
- NATS ServerNATS · CNCF / NATSGitHub
- Confluent BlogConfluent engineers · ConfluentBlogs
- Elastic BlogElastic engineers · ElasticBlogs
Show 6 moreShow fewer
- Moving Core Business Search to Elasticsearch at YelpYelp engineers · YelpCase Studies
- Domain-Driven Design ReferenceEric Evans · Domain LanguageBooks
- Moderating Promotional Spam and Inappropriate Content in Photos at Scale at YelpScale at Yelp engineers · Scale at YelpCase Studies
- Google Research BlogGoogle researchers · GoogleBlogs
- Khan Academy Engineering BlogKhan Academy engineers · Khan AcademyBlogs
- Salesforce BlogSalesforce engineers · SalesforceBlogs
Go deeper on this
A path through videos, articles, other case studies and code on the same ideas as Moderating Promotional Spam and Inappropriate Content in Photos at Scale at Yelp.
Warm upGet the vocabulary first.
Books · Free from the author
Concurrent and Distributed Systems (Cambridge lecture notes)
Eight lectures on time, broadcast, replication, consensus and transactions, with notes, slides and video. Free from the author under CC BY-SA.
University of CambridgeIntermediate
Books · Free from the author
Computer Networks: A Systems Approach
How networks are built and why: protocols, routing, congestion control and the internet's architecture. The authors publish it free online under CC BY 4.0.
Systems ApproachIntermediate
WatchHow others solve the same problem, on video.
Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)
ReadEngineers explain it in their own words.
Blogs
Amazon Science
Technical deep-dives and perspectives from our scientists who are pushing boundaries across multiple scientific disciplines while solving real-world challenges. Explore how our teams combine research excellence, world...
AmazonIntermediate
Papers
Atom Smashing using Machine Learning at CERN
A real-world engineering write-up from CERN on distributed Machine Learning.
CERNIntermediate
See it in another companyThe same ideas, a different system.
Case Studies · Read here
Aroma: Using ML for Code Recommendation at Facebook
Thousands of engineers write the code to create our apps, which serve billions of people worldwide. This is no trivial task—our services have grown so diverse and complex that the codebase contains…
FacebookIntermediate
Case Studies · Read here
Concourse: Generating Personalized Content Notifications in Near-Real-Time at LinkedIn
Social media are computer-mediated platforms that facilitate creation and sharing of information, ideas, career interests, and other forms of expression via virtual communities and networks. In the last few years, not...
LinkedInIntermediate
Read the codeSee how it looks when it is real.
GitHub
Engineering Blogs
A huge directory of company engineering blogs to learn from real production systems.
kilimchoiIntermediate
GitHub
Awesome Scalability
Curated reading list of articles on the architecture of scalable, reliable systems.
binhnguyennusIntermediate
Keep learning
Loading community…