Urgent.News

What's breaking now, across hundreds of outlets.

Tech

How to Implement an API Readiness Endpoint

An API readiness endpoint is a dedicated HTTP endpoint used by the surrounding infrastructure to determine whether an application can currently receive traffic. Missing or incorrect readiness handling can cause: New instances to receive traffic before startup is complete. Unavailable instances to continue receiving traffic. Healthy instances to be removed from traffic because of optional…

An API readiness endpoint is an HTTP endpoint used by infrastructure to determine if an application can receive traffic. Misconfigured readiness handling can lead to new instances receiving traffic prematurely, unavailable instances continuing to receive traffic, healthy instances being removed from traffic, and repeated checks causing overload of failing dependencies.

To implement an API readiness endpoint, track the application's state (starting, ready, or shutting down), expose a dedicated endpoint (e.g., GET /ready) that returns HTTP 200 OK when ready and HTTP 503 Service Unavailable otherwise. Configure the infrastructure to periodically call the endpoint and route traffic only to applications reporting as ready.

Create a singleton class to keep track of the application's state, with methods to get the current state and update it. Mount the readiness endpoint after lightweight observability middleware, but before authentication, validation, business logic, or middleware that may fail for unrelated reasons.

Verify the health of each dependency that, if failing, would prevent the application from serving traffic. For example, if PostgreSQL is required for request processing, return HTTP 503 Service Unavailable if PostgreSQL is unavailable. Perform lightweight dependency checks that do not cause side effects, such as executing a SELECT 1 query.

Run independent dependency checks concurrently to prevent response time accumulation and ensure the endpoint responds within the probe timeout. Apply a short timeout to each check to prevent slow or unresponsive dependencies from blocking the endpoint's response.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Which UK public bodies pay their suppliers late? What 675 official payment reports say (2026)

The Procurement Act 2023 came into force in England, Wales and Northern Ireland on 24 February 2025. One of its quieter rules (section 69) says a contracting authority must publish a payments…

  • 94% of invoices paid within 30 days by typical public bodies
  • Universities and housing associations had lowest payment rates
  • London councils lagged behind other councils in payment times

Demystifying Greedy Algorithms: How Local Choices Solve Global Problems in Node.js

What is a Greedy Algorithm? A greedy algorithm is an algorithmic strategy that solves a problem by making the most optimal decision at each individual step.

  • Greedy algorithms make locally optimal decisions at each step
  • Efficiently solve complex problems like network routing and query optimization
  • Node.js example shows quick coin change calculation using greedy method

More from Thursday, 15 October 2026 →