Skip to content
Beranda

/

Glosarium

/

Infrastruktur

/

Retry Logic

Infrastruktur

3 menit baca

Apa itu Retry Logic?

Retry logic is a fault-tolerance pattern that automatically re-attempts failed operations with configurable delays, backoff strategies, and maximum attempt limits to handle transient errors without manual intervention.

What is Retry Logic?

Retry logic is a programming pattern that automatically re-executes a failed operation based on predefined rules. When a network request times out, an API returns a 503 error, or a database connection drops, retry logic catches the failure and tries again after a calculated delay.

Retry Strategies

Different backoff strategies control the timing between retries:

  • Immediate retry — Retry instantly. Only appropriate for very fast, transient glitches.
  • Fixed delay — Wait the same amount of time between each retry (e.g., 5 seconds every time).
  • Exponential backoff — Double the delay each time: 1s, 2s, 4s, 8s, 16s. This progressively reduces load on the struggling service.
  • Exponential backoff with jitter — Add random variation to the delay to prevent multiple clients from retrying simultaneously (thundering herd problem).
  • Linear backoff — Increase the delay by a fixed amount each time: 1s, 2s, 3s, 4s.
  • When to Retry

    Not every failure should trigger a retry. Retry logic should distinguish between:

  • Retryable errors — Network timeouts, 429 (rate limited), 500/502/503/504 (server errors), connection resets. These are transient and likely to succeed on retry.
  • Non-retryable errors — 400 (bad request), 401 (unauthorized), 403 (forbidden), 404 (not found). These indicate a problem with the request itself, and retrying will not help.
  • Circuit Breaker Pattern

    When retries consistently fail, a circuit breaker prevents further attempts. After a threshold of failures, the circuit "opens" and immediately rejects requests for a cooldown period. After the cooldown, it allows a test request through. If that succeeds, the circuit "closes" and normal operation resumes. This prevents your automation from endlessly hammering a down service.

    Mengapa Ini Penting

    Retry logic is the difference between a fragile script that fails at the first network hiccup and a resilient automation that handles transient errors gracefully. Any production workflow that interacts with external services needs retry logic to maintain reliability.

    Bagaimana Autonoly Menyelesaikannya

    Autonoly's workflow execution engine includes automatic retry logic at every step. Failed browser actions, API calls, and data operations are retried with exponential backoff. You can configure retry counts, delay strategies, and failure thresholds per workflow step through the visual builder.

    Pelajari lebih lanjut

    Contoh

    • A web scraping step that retries 3 times with exponential backoff when it encounters a 503 error, then moves to the next URL if all retries fail.

    • An API integration that detects a 429 rate limit response, reads the Retry-After header, waits the specified time, then resubmits the request.

    • A file upload workflow with a circuit breaker that stops attempting uploads after 5 consecutive failures and alerts the user instead of continuing to fail silently.

    Pertanyaan yang Sering Diajukan

    Exponential backoff increases the wait time between retries exponentially (1s, 2s, 4s, 8s...). Jitter adds a random component to this delay so that multiple clients do not all retry at exactly the same moment. For example, instead of waiting exactly 4 seconds, a client might wait between 2 and 6 seconds. This prevents thundering herd problems.

    Three to five retries is a common default. The right number depends on your use case: API calls might need only 3 retries with short delays, while critical data pipeline operations might warrant 5-10 retries over a longer period. Always set a maximum to prevent infinite retry loops.

    Berhenti membaca tentang otomasi.

    Mulai mengotomatisasi.

    Jelaskan apa yang Anda butuhkan dalam bahasa sehari-hari. AI agent Autonoly membangun dan menjalankan otomasi untuk Anda — tanpa kode.

    Lihat Fitur