Overview
Sequential proxy allows you to chain backend calls where the response from the first call is used in the request to subsequent calls. This is useful when you need to fetch related data that requires IDs or values from a previous response.Example: Hotel and Destination
The/sequential endpoint demonstrates a two-step process:
- Fetch hotel data to get the
destination_id - Use that
destination_idto fetch destination details
Try It
Configuration
Fromconfig/krakend/krakend.json:
How It Works
Step 1: Enable Sequential Mode
Step 2: First Backend Call
destination_id field.
Example Response:
Step 3: Use Response in Next Call
{resp0_destination_id} is replaced with the value from the first response.
Actual Request:
Response Variable Pattern
N= Backend index (0-based)field_name= Field from that backend’s response
Execution Timeline
Sequential (enabled):Use Cases
1. Related Data Fetching
2. Token-Based Authentication
3. Multi-Step Workflows
4. Dynamic Routing
Advanced Patterns
Multiple Fields from Response
Nested Field Access
For nested objects:Conditional Logic
Combine with CEL for conditional execution:Response Structure
By default, all backend responses are merged: Backend 0 Response:Grouping Responses
Usegroup to organize responses:
Performance Considerations
Latency
Sequential calls have cumulative latency:Error Handling
If any backend in the chain fails, the entire request fails:Optimization Tips
- Minimize Chain Length - Fewer steps = lower latency
- Cache Intermediate Results - Use caching on each backend
- Selective Field Extraction - Use
allowto minimize response size - Timeout Management - Set appropriate timeouts for the entire chain
Comparison: Sequential vs Parallel
| Aspect | Sequential | Parallel (Aggregation) |
|---|---|---|
| Execution | One after another | All at once |
| Latency | Sum of all calls | Max of all calls |
| Dependencies | Can use previous responses | Independent calls only |
| Use Case | Related data, workflows | Merge different data sources |
| Config | "sequential": true | Default behavior |
Error Handling
Best Practices
1. Use allow to Extract Only Needed Fields
2. Set Timeouts for the Entire Chain
3. Avoid Deep Chains
4. Combine with Caching
Cache intermediate results when possible:Learn More
- KrakenD Sequential Proxy Docs
- Data Aggregation - Parallel backend calls
- Response Manipulation