Upgrade queue to 5 and migrate worker configuration by loks0n · Pull Request #13814 · appwrite/appwrite · GitHub
Skip to content

Upgrade queue to 5 and migrate worker configuration - #13814

Merged
loks0n merged 3 commits into
mainfrom
codex/queue-5
Sep 21, 2026
Merged

loks0n merged 3 commits into
mainfrom
codex/queue-5

Conversation

@loks0n

@loks0n loks0n commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Upgrade Appwrite to Queue ^5.0.1 and Platform 1.0.0-rc24, with both released versions resolved in composer.lock. Only Queue and Platform change in the lockfile.

Worker configuration now uses coroutines, including the mail/notification connection pool sizing reads. Existing _APP_WORKER_MAX_COROUTINES deployment settings and per-worker concurrency values remain supported. Prefetch defaults to each queue's effective coroutine count; startup output shows both values. Databases retains one handler per worker, and combined workers retain independent per-queue caps.

Delete the 263-line in-memory Redis connection fake. Concurrency tests now exercise actual Redis Lua transitions with isolated namespaces and dedicated receive/locked command connections. They cover prefetch above concurrency and shutdown returning unstarted work without increasing retry attempts. Remove obsolete priority parameters from the publisher fake and rename its synchronous batch method to publishMany() for upstream #317. No production enqueueMany() callers were found.

Validation

Against the installed Queue 5.0.1 and Platform rc24 releases, PHP 8.5, Swoole, and Redis:

  • Worker resolution, Platform initialization/registration, event publisher tests, and worker concurrency: 37 tests, 363 assertions passed, using the normal repository bootstrap with no source overrides.
  • Changed-file PHPStan and Composer validation passed (existing exact-pin warnings). Changed PHP files passed Pint.
  • Host dependency installation used --ignore-platform-reqs; container/CI remains the full extension compatibility gate.

Full Appwrite service end-to-end tests, deployment canary, and downstream Cloud Redis/Dragonfly/NATS staging validation are still required. No prefetch tuning, codec change, transport migration, or deployment setting change is included.

Rollout and rollback

Replace workers orderly for the initial canary; observe backlog age, completion rate, settlement errors, retained processing/reservations, retries and memory. Before rolling back to queue 4, stop queue 5 receives, drain running work, recover expired reservations with queue 5 maintenance, and verify reservation state is empty and processing work accounted for. Queue 4 can read ready payloads but cannot recover queue 5 reservations; setting prefetch to one does not remove that requirement.

Downstream Cloud follow-on: https://github.com/appwrite-labs/cloud/pull/5998. Larger-prefetch experiments remain in https://github.com/appwrite-labs/cloud/issues/5996.

Closes #13813.
Upstream: utopia-php/monorepo#316 and utopia-php/monorepo#317.

@loks0n loks0n self-assigned this Sep 21, 2026
@greptile-apps

greptile-apps Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Comment on lines +51 to +52
$this->assertSame(1, Config::getParam('workers')['databases']['coroutines']);
$this->assertSame(8, Config::getParam('workers')['stats-usage']['coroutines']);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Configuration Values Mirrored

These assertions hard-code the exact coroutine values from app/config/workers.php instead of testing observable worker behavior. This violates the repository directive not to mirror source configuration in assertions; configuration shape and values belong in schema or static checks, while runtime tests should verify the resulting concurrency. This repository requirement must be satisfied before merging.

Suggested change
$this->assertSame(1, Config::getParam('workers')['databases']['coroutines']);
$this->assertSame(8, Config::getParam('workers')['stats-usage']['coroutines']);

Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/unit/Platform/Workers/RegistrationTest.php
Line: 51-52

Comment:
**Configuration Values Mirrored**

These assertions hard-code the exact coroutine values from `app/config/workers.php` instead of testing observable worker behavior. This violates the repository directive not to mirror source configuration in assertions; configuration shape and values belong in schema or static checks, while runtime tests should verify the resulting concurrency. This repository requirement must be satisfied before merging.

```suggestion

```

**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → codex/queue-5 (after).

⚠️ Before benchmark did not complete — change column unavailable.

Metric Before After Change
🚀 Requests/sec n/a 132.45 n/a
⏱️ Latency P50 n/a 126.31 ms n/a
⏱️ Latency P95 n/a 308.85 ms n/a
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 126.31 308.85 8,607 132.45 n/a
Account 263.43 485.78 453 7.54 n/a
TablesDB 120.61 234.51 4,681 74.63 n/a
Storage 121.6 261.87 2,265 37.81 n/a
Functions 179.55 357.27 1,208 21.01 n/a

Top API waits (after)

API request Max wait (ms)
account.prefs.update 728.19
account.name.update 714.24
functions.variables.update 674.13
functions.delete 569.82
functions.variables.create 545.01

@loks0n
loks0n marked this pull request as draft September 21, 2026 23:01
@loks0n
loks0n marked this pull request as ready for review September 21, 2026 23:12
@loks0n
loks0n merged commit 52682c3 into main Sep 21, 2026
54 checks passed
abnegate added a commit that referenced this pull request Sep 22, 2026
Re-apply the stats-calculations/stats-events split on top of #13669's
scheduler-based task and #13814's queue-5 worker configuration: the renamed
Tasks\StatsCalculations keeps main's Utopia\Schedule\Scheduler body and
subqueries hook, Schedule.php passes telemetry through, and workers.php uses
the new coroutines key for both queues.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade Appwrite to queue 5 and migrate worker configuration

1 participant