Rebuilding Guardian: How Pinterest Upgraded Its Real-Time Abuse Platform to Modern Infrastructure at Scale
Authors: Sharon Xie, Sr. Staff Software Engineer | Zhenxiao Luo, Sr Staff Software Engineer |Yi Pan, Principal Software Engineer | Vikram Deshpande, Sr. Engineering Manager
Guardian helps Pinterest teams turn real-time event data into meaningful insights and operational outcomes. It enables subject matter experts to analyze real-time event streams, identify evolving patterns, and operationalize those learnings through signals, policies, and downstream workflows. Over the years, Guardian has supported a wide range of use cases, including spam and fraud response, account takeover detection, risk monitoring, and unsafe content enforcement. As Pinterest scaled, however, the original Guardian platform began to reach its limits. To meet growing demands around scale, reliability, and compliance, we rebuilt the system as Guardian V2 on top of modern data infrastructure.
In this blog series, we’ll share our journey in building the next generation of Guardian, or Guardian V2. In this first part, we’ll discuss the challenges we faced, the architecture shift, and the foundational decisions that improved the platform’s reliability, scalability and compliance alignment.
Background & Motivation
Guardian’s biggest strength was the fast loop it enabled from investigation to operational response. In the asynchronous pipeline, teams could analyze enriched event data, identify suspicious patterns, convert those insights into actions, and trigger downstream actions quickly. Preserving that workflow was a core requirement for Guardian V2.
As Pinterest scaled, however, the previous generation of Guardian presented several challenges:
- Scalability, scalability became a growing issue. Guardian V1 used a monolithic architecture to support interactive querying, continuous event to action processing, and backfill workflows, which made it increasingly difficult to optimize each path independently as traffic, workload volume, and use cases expanded.
- Reliability, reliability became harder to maintain. Slow or broken queries affected investigations, while indexing failures in the async pipeline could lead to missed evaluations and gaps in downstream processing. Historical rewind and replay workflows also became more difficult to run consistently.
- Governance, the legacy data foundation created governance and compliance risks. The async database had grown to hundreds of terabytes outside Pinterest’s standard data governance processes, making it harder to align the platform with evolving compliance requirements.
- Maintenance Cost, the system had become costly to evolve. Because Guardian V1 relied on custom-built infrastructure, the team could not easily take advantage of improvements in Pinterest’s broader data stack.
As a result, engineering effort was often spent maintaining platform-specific workarounds rather than building new capabilities. These limitations defined the direction for Guardian V2: preserve the speed of the original workflow, while rebuilding the system for greater scalability, reliability, maintainability, and compliance.
Figure 1 shows the Guardian V1 architecture. Incoming events first pass through a feature-enrichment stage, where Trust & Safety-related signals are hydrated and prepared for downstream use. The enriched events are then consumed by Guardian’s core module, which powers both interactive querying and continuous processing. When events satisfy the conditions defined in an action definition written in GSQL, Guardian initiates downstream processing for the corresponding content or user, enabling Pinterest to respond quickly to abusive actors and unsafe content.
This architecture was built as a monolithic system that handled pattern discovery, action evaluation, and historical rewind workflows within the same core. This monolithic design worked well in Guardian’s early years and enabled a fast loop from query to action. But as Pinterest scaled, the architecture became harder to sustain: interactive analytics, live processing, and backfill workflows placed very different demands on the system, making it increasingly difficult to scale reliably and efficiently.
Guardian V2 evolves Guardian from a monolithic, in-house system into a modular platform for transforming event data into insights, signals, and operational outcomes at scale. Built on Pinterest-supported data infrastructure, Guardian V2 expands the platform’s ability to support a broad range of real-time and historical workflows. Figure 2 shows the high-level Guardian V2 architecture.
As in V1, the pipeline begins with feature enrichment, but the system diverges from there. Rather than routing every workload through a tightly coupled core, Guardian V2 separates real-time analytics, continuous signal generation, action evaluation, downstream processing, and historical replay into distinct paths, each designed for its own scaling and operational requirements.
This architectural shift was shaped by five key decisions: preserving a unified workflow for defining and operationalizing signals, policies, and downstream workflows through GSQL V2; reshaping the data plane with stream splitting and pruning; rebuilding real-time analytics on StarRocks; moving asynchronous evaluation and downstream processing to FlinkSQL; and rebuilding replay and rewind on Iceberg-backed datasets.
A Unified Query-to-Action Workflow with GSQL V2
One of Guardian’s most valuable properties in V1 was the short path from investigation to operational insight. Users could explore suspicious patterns through queries, refine their logic, and then operationalize those learnings without switching tools or rewriting the logic from scratch. That workflow was especially important because Guardian is used not only by engineers, but also by subject matter experts and analysts responding to fast-moving abuse patterns.
Preserving that experience was a core goal in Guardian V2. Even though V2 introduced specialized systems for analytics, continuous evaluation, and historical processing, it continues to present a unified interface through GSQL V2. From the user’s perspective, queries and operational definitions share the same model; behind the scenes, a thin translation layer maps them to the right backend, translating GSQL into StarRocks SQL for analytics and FlinkSQL for continuous processing.
A key reason this model works is that GSQL was intentionally designed to stay simple. The language exposes only a minimal DML surface, operates on a relatively simple data model, and benefits from upstream feature enrichment that hydrates and denormalizes Trust & Safety signals for downstream use. As part of Guardian V2, we also updated the GSQL spec to align more closely with ANSI SQL. Together, these decisions kept the translator lightweight: a thin Java-based service built with ANTLR4 that connects Guardian’s user-facing workflow to specialized execution engines without becoming a complex system of its own. In this way, Guardian V2 preserved the unified workflow from investigation to operationalization that made V1 effective, while decoupling the backend architecture enough to scale it much further.
Reshaping the Data Plane with Stream Splitting and Pruning
A major lesson in Guardian V2 was that scalability would not come only from choosing faster backend systems. We also needed to reduce the size and complexity of the data flowing into those systems.
In V1, enriched events from many different domains were pushed into a broad shared model. That created two related challenges. First, the analytics layer had to index extremely wide and sparse datasets, since many fields were relevant to only a small subset of events. Second, action-processing jobs had to consume broad event streams and repeatedly filter out irrelevant data before evaluating the logic they actually cared about. As Pinterest scaled, this made both storage and processing increasingly inefficient.
To address this, Guardian V2 introduced stream splitting and pruning as a core part of the data plane. As shown in Figure 3, enriched events are first written into a unified stream, and then split into smaller, more correlated event-family streams. For especially high-volume domains, those streams can be split again into even narrower substreams tailored to downstream processing needs. This staged design allows Guardian to shape the data based on how it will actually be queried and processed, instead of forcing every downstream system to operate on the full complexity of the original enriched stream.
This decision improved both analytics and action evaluation. On the analytics side, stream splitting significantly reduced sparsity and brought the effective column scale of indexed datasets down from O(20K) to O(K), while maintaining the usability of query analysis. On the action-processing side, it allowed FlinkSQL jobs to consume only the events relevant to their workloads, which improved latency, optimized throughput, and made resource allocation more efficient and predictable.
More importantly, stream splitting and pruning changed where complexity lives in the system. Instead of pushing that complexity into every analytics query and every downstream processing job, Guardian V2 handles it once in the shared data plane. That made the rest of the platform easier to scale, easier to operate, and better suited for both real-time analytics and asynchronous processing.
StarRocks for Real-time Analytics
The reshaped data plane in Guardian V2 made a dedicated analytics path possible, but we still needed a real time storage and query engine that could support Guardian’s workload in practice. Guardian’s query path is part of an operational workflow: investigators use it to explore suspicious activity in real time, validate hypotheses, and iterate quickly on signals that may later become enforcement actions. That requires a system that is optimized for both continuous ingestion and real time analytics.
StarRocks is a distributed SQL engine. It provides high performance by leveraging vectorized execution, columnar storage, indices, and materialized views. A large number of use cases are running on StarRocks at Pinterest, including Ads reporting, Experiments(A/B testing), Pinalytics, Metrics Board, Ads API debugger, S3 storage utilization insights, unsafe text check, etc.
We rebuilt this path with StarRocks and paired it with several key storage-layout strategies. First, we used duplicate key tables, which are well suited for Guardian’s write-heavy ingestion pattern. Second, we designed sort keys to accelerate common filter and scan patterns used in investigations. Third, we used partitioning and bucketing to improve data distribution, allowing ingestion and query workloads to scale more efficiently across the cluster.
On top of that storage design, we further optimized analytical feature discovery by making fuller use of StarRocks’ indexing capabilities. In particular, we introduced Bloom filter indexes on selected columns in big tables (e.g. Pin event table) to accelerate high-selectivity lookups. This allowed some feature-discovery queries on those columns to reach a few seconds to sub-second latency, which is especially valuable in workflows where investigators are iterating quickly on hypotheses during active abuse analysis.
These choices complemented the upstream stream-splitting design. Narrower and less sparse datasets reduced the effective column scale from O(20K) to O(K), while StarRocks provided the ingestion and query performance needed to make those datasets operationally useful. The result was an analytics path that is not only faster, but also much better aligned with Guardian’s real-time investigation workflow.
A Unified Flink Execution Foundation for Actions, Signals and Replay
If StarRocks gave Guardian V2 a dedicated path for real-time investigation, FlinkSQL and Iceberg provided the corresponding foundation for continuous action processing and historical replay.
Guardian’s asynchronous processing engine needs to do more than evaluate live streams. It also needs to support replay workflows when new abuse patterns are discovered or when action logic changes over time. In V1, these scenarios were too tightly coupled to the same monolithic architecture, which made them harder to scale, harder to operate, and harder to evolve consistently. Guardian V2 addressed this by rebuilding both live execution and historical replay around a shared FlinkSQL-based execution model. In the live path, FlinkSQL jobs continuously evaluate qualifying conditions over streaming events and send qualified events to downstream action sinks. In the historical path, the same general execution model can be applied to replayable datasets, allowing Guardian to reprocess past data for backfill and validation workflows. This was an important architectural shift: replay was no longer treated as a special-case extension of the live system, but as a first-class part of the platform.
Flink Unified Driver
A key enabler of this model was the Unified Driver, a Pinterest Flink platform initiative that provides a common execution foundation for FlinkSQL applications. Previously, different SQL execution scenarios relied on separate driver programs with overlapping logic for runtime setup, configuration parsing, SQL templating, UDF support, and execution management. This duplication increased operational complexity and made the platform harder to scale cleanly.
The Unified Driver replaced that fragmentation with a shared layer for building and executing SQL from multiple input forms, including direct SQL, file-based SQL, and templated SQL. Although largely transparent to Guardian users, it became an important part of Guardian V2’s platform unification strategy: reducing duplicated logic, standardizing execution patterns, and improving maintainability and reliability across live action processing and replay workflows.
Flink SQL Async Action Processing
With that shared foundation in place, Guardian V2 could standardize how asynchronous signals and actions are expressed and executed. In Guardian V2, every asynchronous action is implemented as a FlinkSQL statement.
At a high level, an action selects qualified events from a source stream and writes them into an action sink. Each action definition follows a simple SQL template: a SELECT clause containing action metadata and the appropriate action UDF, a FROM clause for the source stream, and a WHERE clause containing the qualifying conditions. At runtime, Guardian materializes this as a full FlinkSQL DML statement: INSERT INTO the action sink, followed by the SELECT query that identifies qualifying events.
This model made action logic declarative rather than application-specific. It also made action launches easier to scale across multiple streams. Many actions share the same logical structure but differ in source streams or action parameters, so Guardian uses SQL templating to generate concrete FlinkSQL statements from common templates instead of duplicating nearly identical FlinkSQL jobs. This reduced duplicated logic and made the growing action surface easier to manage.
Flink SQL Replay on Iceberg
Guardian’s historical workflows are built on Iceberg-backed datasets. Through the Voracity V2 ingestion pipeline, Kafka events are ingested into Iceberg in near real time, creating a reliable and efficient foundation for historical storage while also helping address compliance risks in the legacy async path.
This design made replay significantly more practical. The same FlinkSQL queries used for live action processing can also run against Guardian V2 Iceberg tables for up to 30 days of historical data, reducing the gap between online processing and retrospective replay. Rewind jobs can also be auto-deployed against these datasets, lowering manual overhead and making replay workflows more consistent. Beyond replay, this Iceberg-based foundation enables broader cross-table and large-scale data processing use cases that were difficult to support cleanly in V1.
Taken together, FlinkSQL, Unified Driver, and Iceberg gave Guardian V2 a unified and manageable execution foundation for both continuous action processing and historical replay.
Summary of Outcomes
Guardian V2 preserved what made Guardian valuable — the fast path from investigation to meaningful action — while rebuilding the platform for a very different stage of scale.
By separating analytics, live signal evaluation and action processing, and historical replay, Guardian V2 gave each workload a foundation better suited to its needs. Stream splitting and pruning reduced the complexity of the data plane, StarRocks improved real-time investigation, and FlinkSQL plus Iceberg created a more unified execution model for both live workloads and historical replay. Together, these changes improved scalability, reliability, manageability, and compliance alignment across the platform.
More importantly, Guardian V2 did not just solve immediate scaling challenges. It created a stronger foundation for the next set of problems Guardian needs to support, from richer monitoring needs, signal generation to safer schema evolution and more advanced evaluation primitives. In that sense, Guardian V2 was not just a migration — it was a platform reset for the next generation of Content Quality and Trust Safety systems at Pinterest.
Acknowledgements
The success of this project would not have been possible without the significant contributions and support of:
- Xenon Platform: Ashish Jhaveri, Tucker Harvey, Kevin Browne, Kanchi Masalia, Heng Zhang, Chen Qin
- Real-time Analytics Platform: Mingmay Hu, Richer Duong, Ramtin Boustani, Kapil Bajaj
- Logging: Vahid Hashemian, Shardul Jewalikar
- Real-time Data Warehouse: Lu Liu
- Real-time Risk Systems: Alysa Meng, Drake Vu, Hanyi Zhang, Mike Kan, Abhishek Jathan
- Content Quality Serving Delivery: Dinula De Silva, Joshua George, Zack Calaily
- Trust & Safety Tools: Alberto Castaneda, Arthur Zheng, Ismael Duan, Natalie Barba, Harry Shamansky
- Platform Integrity: Conner Evans, Clark Huang, Vikram Singh, Hanh Tong, Max Vu, Lang Yu, Beatrice Zhang, Carmen Dekmezian, Brooke Anderson
- Trust Safety Product: Margot Chock, Alex Taitague
- Leadership: Andrey Gusev, Faisal Farooq
Rebuilding Guardian: How Pinterest Upgraded Its Real-Time Abuse Platform to Modern Infrastructure… was originally published in Pinterest Engineering Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.



