feat: store Redis cache payloads with the igbinary codec by loks0n · Pull Request #13732 · appwrite/appwrite · GitHub
Skip to content

feat: store Redis cache payloads with the igbinary codec - #13732

Merged
loks0n merged 1 commit into
mainfrom
feat/cache-igbinary-codec
Sep 16, 2026
Merged

loks0n merged 1 commit into
mainfrom
feat/cache-igbinary-codec

Conversation

@loks0n

@loks0n loks0n commented Sep 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Bumps utopia-php/cache to 5.1.0, which adds a Codec parameter to the cache adapters.
  • Passes Codec\Igbinary to the Redis cache adapter in app/init/registers.php, so cache entries are stored as igbinary rather than JSON. Every other adapter construction site goes through this pool, so this is the one change.
  • Declares ext-igbinary and bumps the base image to appwrite/base:2.1.0.

Why

From the codec benchmark in utopia-php/cache (1000 ops, median of 3, through Redis):

payload bytes json / igbinary load ops/s json / igbinary speedup
one document 539 / 506 13575 / 14591 1.07x
page of 50 27159 / 7246 5136 / 12472 2.43x

Single documents are round-trip bound. Lists and pages are where the win is: a quarter of the bytes held in Redis and shipped per read, and about 2.4x the load throughput.

Rollout

  • An entry the configured codec cannot decode is a miss, so JSON entries written by the previous release repopulate on first read. No migration and no flush.
  • During a mixed-version rollout, old and new pods overwrite each other's entries as misses. Invalidation is by key and unaffected.
  • Expect a short window of elevated cache misses right after deploy while entries rewrite. Watch cache hit rate and Redis memory (should drop) in Grafana.

Depends on

appwrite/docker-base#108 landing and being released as 2.1.0. Draft until then; CI cannot pass without the extension in the base image.

🤖 Generated with Claude Code

utopia-php/cache 5.1.0 lets an adapter take a Codec. Pass Igbinary to the
Redis cache adapter so entries are stored as binary rather than JSON: on
a page of 50 documents that is about a quarter of the bytes and a 2.4x
faster load through Redis. Entries written as JSON by an older release
decode as misses and are repopulated, so no migration is needed.

Needs appwrite/base 2.1.0, which ships the igbinary extension.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@loks0n loks0n self-assigned this Sep 16, 2026
@loks0n
loks0n marked this pull request as ready for review September 16, 2026 17:47
@greptile-apps

greptile-apps Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The PR should not merge until incompatible pre-deployment cache payloads can be treated as misses without emitting diagnostics into application responses.

Fix All in Claude CodeFindings

  1. P1 Legacy Entries Emit Warnings ▶
Fix with agent prompt
### Issue 1
app/init/registers.php:271
During a mixed-version rollout, legacy JSON cache entries reach `Igbinary::decode()`, which calls `igbinary_unserialize()` on incompatible data. PHP emits a warning before returning `false`; because the application enables `display_errors` with `E_ALL`, routine cache misses can leak warnings into or corrupt API responses while entries are repopulated. Incompatible payloads must be handled without emitting warnings before this codec is enabled on the existing keyspace.

---

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

Summary

This PR switches shared Redis cache payloads from JSON to igbinary and updates the runtime and dependency requirements needed to support that codec.

  • Selects Igbinary when constructing the centralized Redis cache adapter.
  • Upgrades utopia-php/cache to 5.1.0 and declares ext-igbinary.
  • Moves production, development, and Xdebug stages to appwrite/base:2.1.0.
  • The intended rolling-upgrade miss behavior still emits PHP diagnostics for legacy entries and needs hardening.

Reviews (1) · Last reviewed commit: "feat: store Redis cache payloads with th..."

Comment thread app/init/registers.php
@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/cache-igbinary-codec (after).

Metric Before After Change
🚀 Requests/sec 238.45 251.56 🟢 +5.5%
⏱️ Latency P50 73.49 ms 69.77 ms 🟢 -5.1%
⏱️ Latency P95 171.28 ms 161 ms 🟢 -6%
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 69.77 161 15,732 251.56 -10.28
Account 127.6 248.54 828 13.76 -3.6
TablesDB 67.36 123.81 8,556 139.53 -9.28
Storage 64.97 146.05 4,140 69.2 -0.8
Functions 98 194.27 2,208 37.55 -11.51

Top API waits (after)

API request Max wait (ms)
account.prefs.update 414.59
storage.files.create 355.32
account.name.update 353.81
functions.create 320.71
storage.files.update 294.9

@loks0n
loks0n merged commit f65e1f0 into main Sep 16, 2026
114 of 117 checks passed
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.

1 participant