What common integration antipatterns should architects avoid to prevent governor limit exhaustion and system brittleness?
Answer
Basics: An antipattern is a common design that looks reasonable but fails at scale. In Salesforce integrations the failures usually show up as limit errors, row-lock contention, API quota exhaustion, or silent data loss.
How it works: Common antipatterns and fixes:
- Polling an API every few seconds: wastes API calls (daily quota is shared). Use Platform Events, CDC, outbound messages or Pub/Sub API instead.
- Point-to-point mesh: N systems means N-squared connections. Use middleware/ESB or an event bus.
- Chatty record-at-a-time calls: use Composite, sObject Collections or Bulk API.
- Callouts in loops or sync triggers: 100 callouts per transaction; triggers cannot callout synchronously. Use Queueable with
Database.AllowsCallouts. - Large synchronous payloads: 6 MB sync heap, timeouts. Use async and paging.
- No idempotency or retry: duplicates and lost messages.
- Over-privileged integration users and hard-coded credentials.
Advanced / deep dive: Concurrency is a hidden killer: more than 25 requests running longer than 20 seconds each trigger concurrent request limits, and parallel loads against the same parent cause UNABLE_TO_LOCK_ROW (use serial mode or sort by parent). Data skew (one account with hundreds of thousands of children, or one owner with huge record counts) makes sharing recalculation slow. Request-reply for long-running work blocks threads; prefer fire-and-forget with callback. Ignoring the API consumption model (24-hour rolling limit) lets one noisy integration starve others. Tight coupling to field API names makes schema changes break integrations; use a canonical contract and versioned endpoints.