{"id":14983647,"url":"https://github.com/avtonom/delay-exponential-backoff-bundle","last_synced_at":"2026-02-18T16:30:58.483Z","repository":{"id":62490032,"uuid":"81841456","full_name":"Avtonom/delay-exponential-backoff-bundle","owner":"Avtonom","description":"Exponential backoff to delay for Symfony2 bundle for PHP","archived":false,"fork":false,"pushed_at":"2017-02-14T16:08:20.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-14T22:16:50.572Z","etag":null,"topics":["backoff","bundle","delay","exponential-backoff","jitter","job","retry","symfony2"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Avtonom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-13T15:43:44.000Z","updated_at":"2017-02-14T16:09:45.000Z","dependencies_parsed_at":"2022-11-02T09:31:23.602Z","dependency_job_id":null,"html_url":"https://github.com/Avtonom/delay-exponential-backoff-bundle","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Avtonom/delay-exponential-backoff-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avtonom%2Fdelay-exponential-backoff-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avtonom%2Fdelay-exponential-backoff-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avtonom%2Fdelay-exponential-backoff-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avtonom%2Fdelay-exponential-backoff-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Avtonom","download_url":"https://codeload.github.com/Avtonom/delay-exponential-backoff-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avtonom%2Fdelay-exponential-backoff-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279021760,"owners_count":26087053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backoff","bundle","delay","exponential-backoff","jitter","job","retry","symfony2"],"created_at":"2024-09-24T14:07:43.717Z","updated_at":"2025-10-14T22:16:51.172Z","avatar_url":"https://github.com/Avtonom.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Avtonom Exponential backoff to delay\n==============================\n\nExponential backoff is an algorithm that uses feedback to multiplicatively decrease the rate of some process, in order to gradually find an acceptable rate.\n\nPage bundle: https://github.com/Avtonom/delay-exponential-backoff-bundle\n\n```php\n\n    $ php bin/console exponential-backoff\n    $ php bin/console exponential-backoff halfDelay -l 20\n    \n```\n|attempt | microseconds | seconds | minutes | hours\n------------ | ------------- | ------------- | ------------- | -------------\n|1 | 150000000 | 150 | 2.5 | 0.04\n|2|300000000|300|5|0.08|\n|3|600000000|600|10|0.17|\n|4|1200000000|1200|20|0.33|\n|5|2400000000|2400|40|0.67|\n|6|4800000000|4800|80|1.33|\n|7|9600000000|9600|160|2.67|\n|8|19200000000|19200|320|5.33|\n|9|38400000000|38400|640|10.67|\n|10|76800000000|76800|1280|21.33|\n|11|153600000000|153600|2560|42.67|\n\n#### To Install\n\nRun the following in your project root, assuming you have composer set up for your project\n\n```sh\n\ncomposer.phar require avtonom/exponential-backoff-bundle ~1.1\n\n```\n\nSwitching `~1.1` for the most recent tag.\n\nAdd the bundle to app/AppKernel.php\n\n```php\n\n$bundles(\n    ...\n            new Avtonom\\ExponentialBackoffBundle\\AvtonomExponentialBackoffBundle(),\n    ...\n);\n\n```\n\nConfiguration options (parameters.yaml):\n\n``` yaml\n\nparameters:\n    avtonom_exponential_backoff.cap: 1000000 # [OPTIONAL] - Max duration allowed (in microseconds). If backoff duration is greater than cap, cap is returned\n    avtonom_exponential_backoff.max_attempts: 0 # [OPTIONAL] - Number of attemps before thrown an Exception\n    \n```\n\n# API\n\n### getDefaultOptions():\n\nThis method is static and returns an array with the default options:\n- `cap`: Max duration allowed (in microseconds). If backoff duration is greater than cap, cap is returned, default is `1000000` microseconds.\n- `maxAttempts`: Number of attempts before thrown an Yriveiro\\Backoff\\BackoffException. Default is `0`, no limit.\n\n### halfDelay($attempt):\n\n### delay($attempt):\n\n### exponential($attempt):\n\nThis method use and exponential function `E(attempt) = (2**attempt - 1)` to calculate backoff time.\n\n#### Parameters\n- `attempt`: incremental value that represents the current retry number.\n\n### equalJitter($attempt);\n\nExponential backoff has one disadvantage. In high concurrence, we can have multiples calls with the same backoff time due the time is highly bound to the current attempt, different calls could be in the same attempt.\n\nTo solve this we can add a jitter value to allow some randomization.\n\n`equalJitter` uses the function: `E(attempt) = min(((2**attempt - 1) / 2), random(0, ((2**attempt - 1) / 2)))`.\n\n#### Parameters\n- `attempt`: incremental value that represents the current retry number.\n\n### fullJitter($attempt);\n\nFull jitter behaves like `equalJitter` method, the main difference between them is the way in how the jitter value is calculated.\n\n`fullJitter` uses the function: `E(attempt) = min(random(0, (2**attempt - 1) / 2))`.\n\n#### Parameters\n- `attempt`: incremental value that represents the current retry number.\n\n# Usage\n\n\n```php\n\n    $attempt++;\n    usleep($this-\u003e('avtonom_exponential_backoff')-\u003eequalJitter($attempt));\n    \n```\n\n\nRead information https://habrahabr.ru/post/227225/\n\nUse https://github.com/yriveiro/php-backoff\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favtonom%2Fdelay-exponential-backoff-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favtonom%2Fdelay-exponential-backoff-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favtonom%2Fdelay-exponential-backoff-bundle/lists"}