Skip to main content
Version: 1.1.x

Retry Flow

The Retry Flow automatically handles retries for failed API requests based on configurable criteria, such as status codes and retry strategies. It is designed to enhance API reliability by managing temporary failures without requiring client-side retry logic.

Flow Diagram


Scenarios

  1. Handling Temporary API Failures: Automatically retry failed requests, reducing manual error handling.
  2. Improving Reliability: Manage network issues and server downtime with exponential backoff retries.
  3. Enhanced Monitoring: Track retry attempts, cooldowns, and related performance metrics.

Flow Components


Flow Example

This is an example of a fully configured Retry Flow that retries failed API requests based on status codes, with exponential backoff.

/etc/lunar-proxy/flows/flow.yaml
name: RetryFlow

filter:
url: "api.com/resource/{id}"
processors:
RetryProcessor:
processor: Retry
parameters:
- key: attempts
value: 5
- key: cooldown_between_attempts_seconds
value: 5
- key: cooldown_multiplier
value: 1.5
- key: maximum_cooldown_seconds
value: 3600
FilterProcessor:
processor: Filter
parameters:
- key: status_code_range
value: "400-500"
flow:
request:
- from:
stream:
name: globalStream
at: start
to:
stream:
name: globalStream
at: end
response:
- from:
stream:
name: globalStream
at: start
to:
processor:
name: FilterProcessor
- from:
processor:
name: FilterProcessor
condition: miss
to:
stream:
name: globalStream
at: end
- from:
processor:
name: FilterProcessor
condition: hit
to:
processor:
name: RetryProcessor
- from:
processor:
name: RetryProcessor
condition: retry
to:
stream:
name: globalStream
at: end
- from:
processor:
name: RetryProcessor
condition: failed
to:
stream:
name: globalStream
at: end

Troubleshooting

  1. Retries Not Triggering:
    • Verify that status_code_range is correctly configured.
    • Ensure the API response status code falls within the specified range.
  2. Excessive Retry Attempts:
    • Check the attempts parameter and reduce it if necessary.
    • Adjust the cooldown_multiplier to increase wait times between retries.
    • Make sure that in case of long cooldown the value of LUNAR_RETRY_REQUEST_TIMEOUT_SEC is also increased. the default is 100