What is the Remote Process Invocation Request-And-Reply pattern and what operational risks does it introduce in Salesforce?
Answer
Basics: This is one of the standard Salesforce integration patterns (Remote Process Invocation). Examples: validating an address, getting a credit score or a tax quote while a user waits. You use it when the outcome of the call changes what happens next in the same user interaction.
How it works:
- A user action or process invokes Apex (or a Flow with an HTTP/External Services action, or a Lightning/Aura controller).
- Apex builds
HttpRequestusing a Named Credential, callsHttp.send(), and blocks. - The response is parsed and the logic continues; errors are shown to the user or logged.
Variants: Apex callout,
Continuation(long-running calls from LWC/Aura/Visualforce), External Services actions in Flow, and Salesforce Connect for virtual data.
Advanced / deep dive: Operational risks:
- Latency: the user waits; default callout timeout is 10 s, maximum 120 s.
- Limits: 100 callouts per transaction, 120 s cumulative callout time, heap 6 MB sync.
- Concurrency: if 10 or more requests run longer than 5 seconds at once in an org, new ones can be rejected with a "concurrent requests" limit error. Slow endpoints therefore threaten the whole org.
Continuationcalls do not count toward this limit. - Callouts are not allowed after uncommitted DML in the same transaction ("You have uncommitted work pending"), and cannot run directly from triggers (need
@future(callout=true)or Queueable). - Availability coupling: if the remote system is down, the Salesforce user action fails. The remote call also cannot be rolled back, so a later Apex failure can leave the two systems inconsistent unless you design compensation. Mitigations: short timeouts, retries only for idempotent calls, circuit breakers (for example disable calling via a custom metadata flag after repeated failures), caching, and switching to fire-and-forget when the answer is not needed immediately.