Cómo reintentar tareas de aplicaciones fallidas
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Las tareas de aplicaciones que se procesan a través de una lista de tareas en cola pueden fallar por muchas razones. Si un controlador no puede ejecutar una tarea (y, por lo tanto, muestra cualquier código de estado HTTP fuera del rango 200–299), App Engine reintenta la tarea hasta que se ejecuta con éxito.
De manera predeterminada, el sistema reduce gradualmente la tasa de reintentos para evitar sobrecargar su aplicación con demasiadas solicitudes, pero programa los intentos de reintento para que se repitan como máximo una vez por hora hasta que la tarea tenga éxito.
Reintenta tareas
Si agregas el elemento reintentar parámetros en queue.yaml
, puedes personalizar tu propio esquema para realizar los reintentos de tareas. Esto te permite especificar la cantidad máxima de veces que se reintentarán las tareas fallidas en una cola específica. También puedes establecer un límite de tiempo para reintentar y controlar el intervalo entre intentos.
En el siguiente ejemplo, se muestran varias situaciones de reintento:
- En
fooqueue
, las tareas se vuelven a intentar hasta siete veces y durante dos días, como máximo, desde el primer intento de ejecución. Una vez que se pasan ambos límites, la tarea falla de forma permanente.
- En
barqueue
, App Engine aumenta el intervalo linealmente entre cada reintento hasta alcanzar la máxima retirada para reintentar las tareas, y lo hace de manera indefinida en el intervalo máximo (por lo que los intervalos entre solicitudes son de 10 segundos, 20, 30, …, 190, 200, 200, …).
- En
bazqueue
, el intervalo de reintento comienza con 10 segundos, luego, se duplica tres veces, después, aumenta de forma lineal y, por último, se reintenta de forma indefinida en el intervalo máximo (por lo que los intervalos entre solicitudes son de 10 segundos, 20, 40, 80, 160, 240, 300, 300, …).
queue:
- name: fooqueue
rate: 1/s
retry_parameters:
task_retry_limit: 7
task_age_limit: 2d
- name: barqueue
rate: 1/s
retry_parameters:
min_backoff_seconds: 10
max_backoff_seconds: 200
max_doublings: 0
- name: bazqueue
rate: 1/s
retry_parameters:
min_backoff_seconds: 10
max_backoff_seconds: 300
max_doublings: 3
Próximos pasos
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-09-04 (UTC)
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[[["\u003cp\u003ePush tasks in App Engine are automatically retried upon failure, with the system gradually reducing the retry rate to prevent application overload, up to a maximum of once per hour.\u003c/p\u003e\n"],["\u003cp\u003eCustom retry schemes can be configured using the \u003ccode\u003eretry_parameters\u003c/code\u003e element in \u003ccode\u003equeue.yaml\u003c/code\u003e, allowing control over the maximum number of retries, the retry time limit, and the interval between retries.\u003c/p\u003e\n"],["\u003cp\u003eDifferent retry strategies can be implemented, including fixed retry limits, linearly increasing retry intervals, and exponentially increasing intervals with a cap, as demonstrated by the \u003ccode\u003efooqueue\u003c/code\u003e, \u003ccode\u003ebarqueue\u003c/code\u003e, and \u003ccode\u003ebazqueue\u003c/code\u003e examples.\u003c/p\u003e\n"],["\u003cp\u003eThis retry API is compatible with first-generation runtimes and can be used during upgrades to second-generation runtimes, with a separate migration guide for PHP 7/8 runtimes.\u003c/p\u003e\n"]]],[],null,["# Retrying Failed Push Tasks\n\nPush tasks being processed via a task queue can fail for many reasons. If a handler\nfails to execute a task (and therefore returns any HTTP status code outside of\nthe range 200--299), App Engine retries the task until it succeeds.\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| php-gen2\n|\n| /services/access). If you are updating to the App Engine PHP 7/8 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/php-differences) to learn about your migration options for legacy bundled services.\n\nBy default, the system gradually reduces the retry rate to avoid overloading your application with too many\nrequests, but schedules retry attempts to recur at a maximum of once per hour\nuntil the task succeeds.\n\n\nRetrying tasks\n--------------\n\nYou can customize your own scheme for task retries by\nadding the [retry\nparameters](/appengine/docs/legacy/standard/php/config/queueref#retry_parameters)\nelement in [`queue.yaml`](/appengine/docs/legacy/standard/php/config/queueref). This\naddition allows you to specify the maximum number of times to retry failed tasks\nin a specific queue. You can also set a time limit for retry attempts and\ncontrol the interval between attempts.\n\nThe following example demonstrates various retry scenarios:\n\n- In `fooqueue`, tasks are retried up to seven times and for up to two days from the first execution attempt. After both limits are passed, it fails permanently.\n- In `barqueue`, App Engine attempts to retry tasks, increasing the interval linearly between each retry until reaching the maximum backoff and retrying indefinitely at the maximum interval (so the intervals between requests are 10s, 20s, 30s, ..., 190s, 200s, 200s, ...).\n- In `bazqueue`, the retry interval starts at 10s, then doubles three times, then increases linearly, and finally retries indefinitely at the maximum interval (so the intervals between requests are 10s, 20s, 40s, 80s, 160s, 240s, 300s, 300s, ...).\n\n queue:\n - name: fooqueue\n rate: 1/s\n retry_parameters:\n task_retry_limit: 7\n task_age_limit: 2d\n - name: barqueue\n rate: 1/s\n retry_parameters:\n min_backoff_seconds: 10\n max_backoff_seconds: 200\n max_doublings: 0\n - name: bazqueue\n rate: 1/s\n retry_parameters:\n min_backoff_seconds: 10\n max_backoff_seconds: 300\n max_doublings: 3\n\nWhat's next\n-----------\n\n- Learn more about the [task queue parameters](/appengine/docs/legacy/standard/php/config/queueref)."]]