Overview
The/fail endpoint demonstrates how KrakenD handles partial failures when aggregating data from multiple backends. One backend succeeds while another intentionally fails, showing the gateway’s fault tolerance behavior.
Endpoint Details
- Method: GET
- Path:
/fail - Authentication: None required
Try It
What It Demonstrates
This endpoint aggregates data from two backends:- A successful backend that returns user data
- A deliberately failing backend with an unresolvable hostname
Configuration
Fromconfig/krakend/krakend.json:
Response Behavior
Successful Backend
The first backend returns user data from the fake API:Failed Backend
The second backend attempts to connect tohttp://fake_url_that_should_not_resolve.tld, which does not exist and will timeout or fail to resolve.
Response Headers
KrakenD adds a special header to indicate incomplete aggregation:Expected Response
- The request still returns 200 OK despite one backend failing
- The successful backend data (
user) is included - The failed backend data (
nonegroup) is omitted - The
X-KrakenD-Completed: falseheader indicates partial failure
Key Concepts
Partial Failure Handling
KrakenD’s default behavior for aggregated endpoints:- Returns HTTP 200 if at least one backend succeeds
- Includes data from successful backends only
- Adds
X-KrakenD-Completed: falseheader when any backend fails
Backend Groups
Each backend is assigned to a group:Timeout Behavior
The failing backend will wait until timeout before the response is returned. The default timeout is specified in the main configuration:Use Cases
This pattern is useful for:1. Optional Data Sources
When some data is optional and the endpoint should succeed even if that data is unavailable:2. Graceful Degradation
Provide core functionality even when auxiliary services fail:3. Client-Side Error Handling
Clients can check theX-KrakenD-Completed header to detect partial failures:
Comparison with Sequential Calls
| Feature | Aggregation (/fail) | Sequential Calls |
|---|---|---|
| Backend calls | Parallel | Sequential |
| Partial failure | Returns partial data | Stops at first failure |
| Use case | Independent data sources | Dependent operations |
| Header | X-KrakenD-Completed | Not applicable |
Alternative Behavior
If you want the endpoint to fail completely when any backend fails, configure backend validation:Learn More
- Data Aggregation - Combining multiple backends
- Sequential Calls - Alternative for dependent operations
- KrakenD Aggregation Docs