App Engine Task Queue Alternative: Push and Pull Queues Over REST

If you are moving off App Engine Task Queue and want to keep its model rather than redesign around a message broker, altengine Tasks is a managed queue with the same shape: push queues that deliver each task and retry it with exponential backoff, pull queues your workers lease from, and task names that make an add idempotent. You reach it over a REST/JSON API instead of the App Engine SDK, so your queue design and retry tuning carry over and the code that adds and handles tasks is rewritten.

What carries over from Task Queue

The ideas that made Task Queue useful are all present. A push queue delivers each task to a target and keeps retrying until the target accepts it or the attempts run out. A pull queue never delivers; your workers lease tasks, do the work and acknowledge them. A task can be delayed or scheduled for a time, and a task name already used in the queue is refused, so a retried request cannot enqueue the same work twice.

The retry knobs you set in queue.yaml map almost one to one onto a queue's retry policy:

App Engine queue.yaml settings and their altengine Tasks equivalents
queue.yamlaltengine TasksDefault and range
rateratePerSecond10; 0.01–100 per second
max_concurrent_requestsmaxConcurrent5; 1–50
task_retry_limitmaxAttempts10; 1–100, the first attempt included
task_age_limitmaxAgeSeconds7 days; 0 is no limit, at most 30 days
min_backoff_secondsminBackoffSeconds10; 1–86,400
max_backoff_secondsmaxBackoffSeconds3,600; 1–604,800
max_doublingsmaxDoublings8; 0–16

The backoff curve behaves the way you expect: after the nth failed attempt the wait is minBackoffSeconds × 2^(n−1); past maxDoublings it grows linearly by the last doubled step, capped at maxBackoffSeconds. With the defaults that is 10 s, 20 s, 40 s and so on, reaching 2,560 s before the tenth and last attempt. Watch one off-by-one when you port numbers: maxAttempts counts the first attempt, so it is your old retry limit plus one.

What you rewrite

The call layer. There is no taskqueue.add() and no queue.yaml deploy. Queues are created in the console or with a POST, and tasks are added the same way. This is the documented quickstart:

curl -X POST https://api.altengine.net/v1/tasks/jobs/queues \
  -H "Authorization: Bearer $ALTENGINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"emails","target":{"function":"app/send-receipt"},"ratePerSecond":5}'

curl -X POST https://api.altengine.net/v1/tasks/jobs/queues/emails/tasks \
  -H "Authorization: Bearer $ALTENGINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"payload":{"orderId":"o-1041"},"name":"receipt-o-1041","delay":60}'

The second difference is the target. A Task Queue push task called a URL on your own app. Here a push queue's target is exactly one of a function on altengine, a channel (the task is published as a message) or an https webhook. A webhook can be your existing handler wherever it now runs, which is usually the shortest migration path: point the queue at it and verify the signature. Every webhook delivery carries x-altengine-timestamp and an HMAC-SHA256 x-altengine-signature over <timestamp>.<raw body>, keyed with the instance's signing key.

The third is the payload. A task is one JSON value, up to 128 KB, delivered in a POST body alongside a task object with its id, queue, name, attempt number and deadline. Form-encoded params and arbitrary HTTP methods are not part of it. Anything bigger than 128 KB goes in Blob, with its key in the payload.

Handlers decide the outcome with their status code

A 2xx finishes the task, and up to 16 KB of the response body is kept as its result. A 408, 429, 5xx, a network error or no answer by the deadline is retried with backoff. Any other 4xx, and any 3xx, fails the task at once: a payload the target refuses does not improve by retrying. That last rule is worth checking in old handlers that returned a 4xx to mean try again later.

Delivery is at least once. A delivery cut off part-way is retried, so the same task can arrive twice. The documented handler shape deduplicates on task.id:

export default {
  async fetch(request, env) {
    const { task, payload } = await request.json();
    if (await alreadySent(task.id)) return new Response("dup");   // at-least-once
    await sendReceipt(payload.orderId);
    return new Response("sent");                                  // 2xx: done
  },
};

Handlers can also steer their own retries with response headers.Retry-After sets when the next attempt runs, x-task-retry: never fails the task now, and x-task-retry: defer runs it again later without spending an attempt — useful when the record a task needs simply is not there yet:

// the record this task needs is not there yet: try again in a minute, without using an attempt
return new Response("waiting", { status: 503, headers: { "x-task-retry": "defer", "retry-after": "60" } });

A task can be deferred 1,000 times, and maxAgeSeconds still ends it. Set a queue's targetControl to false if you would rather the headers were ignored.

Pull queues and long work

A pull queue is "mode": "pull". A worker calls POST …/queues/{queue}/lease with count (1–100) and leaseSeconds (1–3,600, default 300), then acknowledges each task with its leaseId, extends the lease, or releases it with a delay. A lease that runs out without an ack is a failed attempt and is retried with backoff, and any later call with the old leaseId answers 409 LEASE_LOST, so a slow worker cannot finish a task another worker now holds.

Pull queues are also the answer for long jobs. A push target is waited for at most 840 seconds (deadlineSeconds, 600 by default). Past it the attempt counts as failed and is retried, though the original is not stopped and the retry waits for it to return. For anything longer than 14 minutes, lease the task and extend the lease as you go.

One addition with no Task Queue equivalent: a dead-letter queue. Name another queue in the same instance as deadLetterQueue, and a copy of every task that fails lands there with task.deadLetterOf set, to be delivered to its own target or leased for inspection.

Where it stops

  • No recurring schedule in a queue. App Engine kept cron separate from Task Queue, and so does altengine: cron expressions belong to Functions. A scheduled function is waited for 30 seconds and is not retried, so for anything that must not be lost, have it add a task named after the period (nightly-2026-11-18) and let the queue do the retrying.
  • Thirty days ahead, at most. delay or runAt cannot schedule a task further out.
  • Names are only reserved while the record is kept. A finished task is kept for retentionDays, 7 by default and at most 30. After that its name can be used again.
  • Throughput ceilings. Up to 100 deliveries a second and 50 in flight per queue, 50 in flight across a whole instance, 50 queues per instance, and 100 tasks per add.
  • A running delivery cannot be cancelled. Cancel works on scheduled and leased tasks; purging a queue lets a running delivery finish and drops its outcome.
  • Server-side keys only. Every call takes an organization API key with a grant on the instance. An end-user identity token is refused, so browsers cannot enqueue directly; add tasks from a function or your backend.

What it costs

Tasks is billed on tasks added at $2.00 per million, deliveries to a channel or webhook target at $1.00 per million attempts (retries included), and the data an instance keeps at $0.80 per GB-month, averaged over the month. A delivery to a function is not a delivery charge; it bills as a function invocation. There is no cluster to keep warm, and the first $3 of usage each month is free on the one pay-as-you-go plan, with no card to start. A queue sending a million webhook tasks a month, each delivered once, comes to $3.00 plus storage before that free allowance.

Datastore writes, blob uploads and incoming mail can add tasks on their own through triggers, and the local emulator serves the same API and delivers tasks within about a second. The Tasks API reference has every field, state and limit quoted here.

Start free in the console

← Back to the blog