Urgent.News

What's breaking now, across thousands of outlets.

Tech

Opinion-Driven Architecture Piece

Why Direct REST Endpoints Fail for Asynchronous Payment Workflows When designing third-party payment and integration workflows, engineering teams frequently rely on synchronous REST endpoints: a client hits POST /process-payment , the server synchronously dials Stripe or Razorpay, performs multi-table database operations, and holds the HTTP socket open until the third-party gateway responds. In…

Synchronous REST endpoints often fail when handling asynchronous payment workflows in production environments. Engineers typically use POST /process-payment for these tasks, initiating a synchronous connection to Stripe or Razorpay, executing multi-table database operations, and maintaining the HTTP socket open until the third-party gateway replies. While this approach works smoothly in low-traffic staging, it leads to cascading microservice failures during traffic surges in live production settings.

The main issue stems from thread-pool exhaustion. When a Node.js or containerized microservice makes an outgoing HTTPS request to a payment processor, the incoming client connection remains blocked. Spikes in downstream latency, such as a response time increasing from 250ms to 3.5 seconds during network degradation, quickly fill up the open socket pool.

This causes cascading denial of service, with unrelated API endpoints like health checks or user profile lookups timing out due to all available sockets waiting for gateway responses.

Engineers often defend synchronous REST for payments by claiming the need for immediate user feedback. However, even a successful HTTP call does not guarantee consistency, as banks execute settlements asynchronously. A network drop severing the connection after the bank charges the card but before the server writes the database ledger results in an inconsistent state where the charge is successful, but the order is unrecorded. Synchronous REST merely masks where network drops occur, providing no real consistency guarantee.

The asynchronous alternative involves using durable queues (like BullMQ, Redis Streams, or RabbitMQ) to decouple initial request acceptance from transaction settlement. When a client sends a POST /payments request, it validates the request and pushes the payload to the queue, returning an HTTP 202 (Accepted) response. A worker pool then takes over, dialing the gateway and committing the ledger atomically.

This approach offers deterministic latency, better handling of backpressure and rate throttling, and built-in circuit breakers and retries for transient gateway timeouts without tying up front-facing API threads.

In conclusion, for applications processing mission-critical transactions or integrating with third-party banking APIs, it is essential to transition away from synchronous HTTP execution models. Decoupling ingestion from settlement using background job queues protects server thread pools from third-party provider latency, ensuring a more resilient and reliable payment workflow.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

How I Built a Free Online Quiz Website

I recently started working on a small project called Unbotium, a free online quiz website. The idea was pretty simple: pick a subject, start a quiz, answer the questions before the timer runs out, and…

  • Created free online quiz website called Unbotium
  • Used AI tools like ChatGPT, Claude, and Grok in development
  • Website live at https://unbotium.com for exploration

"Compressing a PDF to a Target Size in the Browser", a developer write-up with code from the site's own compressor

an exact target file size (e.g., < 2 MB) using WebAssembly, PDF.js, and Canvas?In this write-up, we’ll explore how browser-based PDF compression works, why reaching a specific target size requires a…

  • JavaScript libraries like PDF.js and pdf-lib compress PDFs in browsers
  • Binary search algorithm adjusts image quality and scale for compression
  • Offloads tasks to Web Workers and cleans DOM to optimize performance

Apple TV app – Top Movies

  • Apple unveils new TV app for streaming top movies and shows.
  • $205.00 annual subscription includes 10% discount, subject to automatic renewal.
  • Terri Gale leaves CTV Your Morning after 15 years.

More from Tuesday 6 October →