Apex at scale: async patterns for ad sales and U-GO
How I combine Batch, Queueable, Scheduled Apex, Platform Events, and a REST service layer for NBCUniversal ad sales and the U-GO re-platforming program.
When Salesforce becomes the system of record for high-volume commercial workflows, synchronous Apex stops being a default. I have spent much of the last several years at NBCUniversal shaping asynchronous and API-first patterns that keep user interfaces responsive while back-end work catches up safely.
Two programs, one platform mindset
The work splits into two shapes that still share the same architectural instincts.
NBCUniversal Ad Sales needed an event-driven, API-first architecture. Downstream systems and internal tools had to react to commercial lifecycle changes without tight coupling to a single UI transaction. Platform Events and REST endpoints became the seams where order, booking, and integration payloads could be published and consumed with clear contracts.
U-GO was the opposite migration problem: a large Oracle PL/SQL footprint rebuilt as domain-driven Apex. Projects, titles, bills of materials, and reporting logic that lived in the database tier had to land in Salesforce with explicit service boundaries, testable units, and async offload for anything that would blow governor limits in a single trigger chain.
Neither program rewarded “put it all in the trigger.” Both rewarded naming domains, isolating side effects, and choosing the right async vehicle per workload.
Choosing the async vehicle
I treat the choice between Batch, Queueable, Scheduled Apex, and immediate synchronous work as a capacity and reliability question, not a style preference.
Batch Apex is still my first stop for large, chunkable data work: backfills, reconciliation passes, migration hygiene, and any job that needs a defined scope and predictable chunk size. U-GO migration and sharing-model hardening leaned on batch jobs because the row counts and dependency graphs were too large for a single chain.
Queueable is for “this must happen soon, once, after commit” work: callouts, chained follow-ups, and fan-out that should not block the user. Ad-sales integrations that needed a REST callout right after a DML commit often ended in Queueable implementations with careful idempotency keys.
Scheduled Apex orchestrates recurring hygiene: nightly reconciliation, rolling snapshots, and housekeeping that must run on a clock regardless of user activity.
Platform Events carry notifications and loosely coupled handoffs. Producers publish facts; subscribers decide what to do. That pattern fit the ad-sales push toward event-driven design better than point-to-point triggers calling six classes deep.
REST as the service layer
A REST service layer sits above the domain code in both contexts. External callers and Experience Cloud clients get stable URLs, versioned payloads, and authentication boundaries. Internally, the same service classes back @AuraEnabled or LWC controllers so UI and API do not fork business rules.
An illustrative pattern I reuse:
@RestResource(urlMapping='/services/booking/v1/*')
global with sharing class BookingService_v1 {
@HttpPost
global static BookingResponse create(BookingRequest body) {
return BookingDomain.createFromApi(body);
}
}
The domain class owns validation, sharing checks, and the decision to enqueue async work. The REST shell stays thin.
Platform Events in the ad-sales picture
For API-first ad sales, I publish events when a commercial fact is durable in Salesforce: a booking state change, an integration checkpoint, or a handoff to downstream finance. Subscribers might enqueue Queueable callouts, update related aggregates, or write integration logs. The trigger’s job is to validate and publish; not to perform every downstream effect inline.
Domain-driven Apex for U-GO
U-GO taught me to mirror the old PL/SQL modules as domain services with explicit inputs and outputs, not as copies of stored procedures sprinkled through triggers. Batch jobs orchestrated migration waves; Queueable jobs handled post-migrate enrichment; scheduled jobs kept reporting snapshots aligned.
Triggers became entry points that delegate to a single handler per object, and handlers call domain services. That discipline made it possible to test BOM and title logic without standing up an entire UI flow.
Operational lessons
Governor limits are a design constraint, not a surprise in production. I log async job ids, use custom metadata for batch scope sizes where tuning is expected, and keep callouts out of triggers. For integrations, idempotency and dead-letter handling belong in the same story as the happy path.
Closing thought
Apex at scale is less about clever code and more about clear boundaries: REST for contracts, domain classes for rules, and the right async primitive for the volume and latency you actually have. NBCUniversal ad sales and U-GO looked different on paper, but both needed that same separation to stay maintainable under real enterprise load.