Skip to content

Add true-async-server framework#694

Open
EdmondDantes wants to merge 10 commits intoMDA2AV:mainfrom
true-async:true-async
Open

Add true-async-server framework#694
EdmondDantes wants to merge 10 commits intoMDA2AV:mainfrom
true-async:true-async

Conversation

@EdmondDantes
Copy link
Copy Markdown
Contributor

Adds TrueAsync Server as an HttpArena framework entry under frameworks/true-async-server/.

What it is

A native PHP extension that runs an HTTP/1.1 + HTTP/2 + HTTP/3 server inside the PHP process — no FastCGI, no separate proxy. Built on the TrueAsync coroutine engine. One process, N event-loop threads (SO_REUSEPORT), coroutine-per-request, ALPN-driven protocol selection.

Subscribed profiles (7)

baseline, pipelined, limited-conn, json, upload, baseline-h2, json-tls

All 26 validation checks pass on the published Docker image:

=== Results: 26 passed, 0 failed ===

(Verified via ./scripts/validate.sh true-async-server against trueasync/php-true-async:0.7.0-alpha.5-php8.6.)

Local benchmark snapshot

./scripts/benchmark-lite.sh true-async-server baseline-h2 (h2load -c 512 -m 32 -t 8, server WORKERS=16, 16-core WSL2 host, 5s × 3 runs):

Run req/s Errors
1 1 033 337 0
2 1 010 158 0
3 994 134 0
Best 991 686 (CPU 871 %, Mem 339 MiB)

ALPN selects h2, TLS 1.3 / AES-256-GCM throughout. Server contention with the load generator on the same host bounds the ceiling here; on dedicated 64-core hardware the number is expected to be higher.

Not subscribed yet (transparent in README)

  • static, static-h2, static-h3 — need a built-in static handler at the C level (production-tier rules forbid the user-land file cache entry.php would otherwise rely on).
  • json-comp — the server's transparent gzip middleware is in 0.7.0-alpha.5 but not yet wired into entry.php.
  • baseline-h2c, json-h2c — HttpArena requires port 8082 to refuse HTTP/1.1; per-listener protocol mask is on the server roadmap (currently server-wide).
  • async-db, crud, api-4, api-16, fortunes — DB-backed; PostgreSQL adapter ships in PostgreSQL.php but the suite isn't fully validated yet.
  • baseline-h3, static-h3, gateway-h3addHttp3Listener exists in the server, not yet enabled in entry.php.

The full feature roadmap is tracked in FUTURES.md on the server repo. Each profile will land as the corresponding server feature does.

What's in the PR

  • frameworks/true-async-server/Dockerfile — pulls the published trueasync/php-true-async:0.7.0-alpha.5-php8.6 image, adds opcache JIT settings, copies entry.php and PostgreSQL.php.
  • frameworks/true-async-server/Dockerfile.local + build.sh — local-development override; copies a host-built php binary and true_async_server.so over the published image. Not used by HttpArena CI.
  • frameworks/true-async-server/entry.php — flat dispatcher: 8080 (h1 cleartext), 8081 (h1+TLS for json-tls), 8443 (h1+h2+TLS via ALPN); routes /baseline11, /baseline2, /pipeline, /json/{N}, /upload, /static/*, /async-db.
  • frameworks/true-async-server/PostgreSQL.php — async PDO PostgreSQL adapter using the TrueAsync connection pool.
  • frameworks/true-async-server/meta.json — declares the 7 subscribed profiles, tier tuned, maintainer.
  • frameworks/true-async-server/README.md — architecture, listener layout, subscribed / not-yet-subscribed profiles, related repositories.
  • frameworks/true-async-server/test/ — local Docker-Compose smoke tests.

EdmondDantes and others added 10 commits May 4, 2026 11:22
Native PHP HTTP server using TrueAsync coroutine engine with ThreadPool
for SO_REUSEPORT multi-worker scaling. Supports HTTP/1.1 and HTTP/2 over
TLS via ALPN. Covers baseline, pipelined, json, upload, static, async-db,
api-4/16, baseline-h2, static-h2, json-tls test profiles.
- Add docker-compose.yml: postgres + server + validator services on
  a shared bridge network; validator exits with the test result code
- Add test/Dockerfile + test/validate.sh: full HTTP/1.1, HTTP/2,
  TLS, JSON, upload, static, async-db and TCP-fragmentation tests
- Fix entry.php: require PostgreSQL.php inside each per-thread
  closure so every worker thread has the class in its PHP environment
- Fix Dockerfile: switch to slim base image with INI tuning
- Add ISSUES.md: documents 4 remaining alpha.3 failures with root
  causes and suggested server-level fixes
Validator now reports 38/38 in steady state against a locally-built
php-src + true-async-server. Documents the remaining minor first-run
Content-Type race and the host-PHP extensions required when using
the override mount.
Five consecutive validator runs against a locally-built php-true-async
report 38/38 with no flakes. Removes the previously-noted intermittent
Content-Type race (root cause was an external debug print, not a
server-side bug).
…ding parsing

- Remove temporary set_error_handler finalize-race tracer.
- Remove per-request fopen('/tmp/handler.log') in the HTTP handler — it dominated every benchmark.
- Remove per-worker /tmp/worker.log open at thread start.
- Reorder dispatch so /baseline11|/baseline2 is checked first (baseline + pipelined + limited-conn all hit it).
- Parse Accept-Encoding with comma split + q=0 honoring instead of substring match, so 'br;q=0' no longer falsely selects brotli.
…tests

- Remove read/write/keep-alive/shutdown timeout knobs from HttpServerConfig — bench runs are short and the per-connection timer arming is pure overhead here.
- Drop the manual 405 in /baseline2|/baseline11 and replace the userland sum loop with array_sum() on the parsed query (matches Swoole's shape).
- meta.json: remove async-db, api-4, api-16 — DB-backed profiles are not supported yet (api-4/api-16 mix in /async-db).
- Delete ISSUES.md (stale).
Static-file profiles will be re-enabled once the server gains a built-in
static handler (see FUTURES.md in the server repo).
The HttpArena validator probes json-tls on port 8081 (h1-over-TLS),
distinct from :8443 (h2/h1 over TLS via ALPN). Without this listener
all 5 json-tls checks fail.

Validator: 19 → 25 passing.
- README documents architecture, listener layout, subscribed and not-yet-subscribed profiles, related TrueAsync repos.
- Dockerfile FROM trueasync/php-true-async:0.7.0-alpha.3-php8.6 → 0.7.0-alpha.5-php8.6 (HTTP/2 default-enabled build, gzip middleware, bailout firewall portability fix).
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