System Program Development: Should Interfaces Be Synchronous or Asynchronous? Missing Callback Configuration Can Lose Orders Online
Simple conclusion: synchronous interfaces suit strong consistency, low concurrency, and callers willing to wait; asynchronous interfaces suit cross-system operations, slow operations, and peak shaving. However, what truly determines online stability is often not sync vs async itself, but the reliability of asynchronous callbacks—if callbacks are not configured properly, even a fast interface can lose orders.
Synchronous and Asynchronous Interfaces: What Differs Is More Than 'Waiting'
A synchronous interface blocks the caller until it receives a response; an asynchronous interface first returns an 'accepted' status, then notifies the result via callback or polling. In 2026 project deliveries, many internal services mix both. The focus is not on 'which is more advanced,' but on 'how long can the business tolerate before knowing the result.' In one sentence: synchronous focuses on the result; asynchronous focuses on compensation.
- Synchronous interface: simpler logic, intuitive debugging, but call chain timeouts can drag down upstream.
- Asynchronous interface: fast response and clear peak shaving, but the result delivery path is longer, so failure fallback must be designed.
Three-Step Method to Determine Sync vs Async
This is a decision framework distilled from project delivery—check in order. Don't just look at the interface itself; trace the call chain to see if business operations suffer from latency.
- First, check consistency: Does this operation require 'immediately seeing the latest state'? For example, payment deductions or inventory decrements usually must be synchronous.
- Second, check wait cost: Can the caller tolerate 2–5 seconds of blocking? If yes, sync is acceptable; if not, switch to async and move timeout control to the outermost layer.
- Third, check failure cost: If a message is lost after going async, can it be automatically compensated? Without any compensation mechanism, it's better to use sync than to run async without protection.
The order of these three steps must not be changed: first business correctness, then wait cost, and finally concurrency performance. Many online order losses happen because teams skip the first two steps and switch to async purely to 'handle high concurrency,' leading to incorrect business states throughout.
In actual delivery, a common mismatch is: inventory deduction should be synchronous, but it's changed to async because the interface is slow. As a result, inventory oversells, refunds are used as compensation, and customer complaints pile up. This is the cost of not first checking business consistency.
Common Pitfalls and Fallback Solutions for Asynchronous Callbacks
Common pitfalls include: hardcoding callback URLs to external test environments, callbacks without authentication, non-idempotent results, and lack of persistent retry mechanisms. Any of these can cause duplicate shipments or unilateral accounts online. During delivery, first verify the callback URL, signature validation, and idempotency key, then talk about 'how fast async can be.'
In projects, a common scenario: the client requires all orders to go through asynchronous callbacks to integrate with external channels. The channel callback occasionally delays, and without an idempotency table, duplicate refunds were processed for the same order. Before launch, we added a local deduplication table, set callback retries to 1/5/30 minutes, and used reconciliation to backfill missed orders—only then did we clean the dirty data. This cost could have been avoided at the design stage (Xiyue Company recommends confirming the callback protocol at least two versions ahead in delivery).
- Idempotency table: use a unique constraint on the business ID for each callback record; duplicate arrivals only update status, not re-trigger actions.
- Retry interval: typical range is 1 minute, 5 minutes, 30 minutes, next day; backoff should not be too aggressive.
- Reconciliation report: daily scheduled comparison between 'local status' and 'third-party status'; inconsistencies trigger automatic compensation.
- Observability: callback arrival rate must be visible on the monitoring dashboard; alert when the missed rate exceeds 0.1%.
'What counts as qualified?' At least three things: callbacks are authenticated, processing logic is idempotent, and failures have automatic or manual compensation channels. If any of the three is missing, it's recommended not to go async.
For retries, use a callback record table to persist every request. Mark it successful after processing; schedule a task to scan uncompleted records and replay on a time ladder. Even if the third-party's retry mechanism is poor, we can still catch it.
Solution Comparison: Synchronous vs Asynchronous Order Handling
We usually compare across four dimensions.
- Response time: synchronous typically 200ms–2s; asynchronous returns within 100ms, but the final result depends on callback completion, with overall time possibly 1–30 minutes.
- Consistency: sync provides strong consistency and controllable transactions; async provides eventual consistency, requiring intermediate state queries and 'processing' display.
- Failure handling: sync fails immediately with an error code, so the business can report an error directly; async failure relies on callback failure queues and manual replay.
- Operational cost: sync's connection pool, timeouts, and circuit breakers are more straightforward; async adds a message queue, callback gateway, and scheduled reconciliation.
Based on 2026 project delivery habits, low-frequency, result-critical interfaces do not need async; high-frequency interfaces with uncontrollable downstream may consider it. There is no silver bullet—only whether 'this scenario can bear the complexity of various fallbacks.'
Applicable Scenarios and Boundaries
Sync is more suitable for: internal service calls, strongly consistent operations, and management backends with low request volumes. Async is more suitable for: SMS/email sending, payment callbacks, cross-platform product syncing, and post-seckill asynchronous order verification after inventory deduction.
- More suitable for sync: internal service calls, strongly consistent operations, management backends with low request volumes.
- More suitable for async: SMS/email sending, payment callbacks, cross-platform product syncing, and post-seckill asynchronous order verification after inventory deduction.
Not suitable or unnecessary for async: when the caller needs immediate results to make decisions, and the team lacks message queue operational capability; or when the third-party cannot cooperate with the callback protocol—then sync is actually the more stable choice. If you're going async just 'to improve interface response speed' and eventual consistency is acceptable, that's fine; but if the business requires 'failures to be immediately known to users,' async will introduce a flood of false positives.
FAQ
Can sync and async interfaces be mixed?
Yes. A common flow uses sync in the first half and async in the second half—for example, ordering returns an order number synchronously, while shipping status is updated via callback. The key is to define which states must be completed in the main chain and which can be eventually consistent.
How long is too long for an async callback delay?
The most common threshold is: no callback after 30 minutes triggers an alert, and after 2 hours triggers compensation. Depending on business tolerance, for payments it's recommended to compress to 10 minutes.
What happens if the callback is not configured for idempotency?
Duplicate callbacks can lead to duplicate shipments, duplicate refunds, and extra inventory deductions. The fix is to add a unique business key for deduplication at the callback entry and use a state machine to restrict transitions from 'pending' to 'completed.'
When should you switch from sync to async?
Consider async when synchronous calls persistently trigger upstream timeouts, or when third-party response time exceeds 3 seconds and cannot be optimized. Before switching, confirm the failure rate's impact on the business and set up retry and reconciliation.
How many retries are appropriate for callback failures?
A common practice is 3–5 retries with intervals of 1 minute, 5 minutes, and 30 minutes. If it still fails after 5 attempts, don't retry infinitely—escalate to manual handling or use a reconciliation task to fetch.
First, use the three-step decision framework to define the current interface: strong consistency means sync; only if eventual consistency is acceptable can you consider async. If you decide on async, confirm four things before launch: callback authentication, idempotency, retry, and reconciliation. If you currently have an async flow but lack these fallbacks, add them before iterating.
-
In System Development, Is It Okay to Call APIs Inside a Transaction? When Database Connections Run Out, Everything Freezes
Date: Aug 29, 2026 Read: 8
-
System Program Development: Store Time Fields as Timestamp or String? Time Zones Cause Repeated Rework
Date: Aug 28, 2026 Read: 9
-
Logs too sparse to trace issues, too verbose to afford — what to do when production troubleshooting always misses that one key detail?
Date: Aug 27, 2026 Read: 13
-
How Detailed Should API Return Codes Be to Avoid Back-and-Forth During Integration?
Date: Aug 27, 2026 Read: 18
-
System Development: Too Few Comments Make Code Hard to Understand, Too Many Are Ignored—How Many Is Enough?
Date: Aug 26, 2026 Read: 19




