docs: record the probe resultsUnverified
8215677 parent: ee04d77 added
docs/probe-results.md +104 -0 | new file mode 100644 | ||
| @@ -0,0 +1,104 @@ | ||
| 1 | +# Probe results | |
| 2 | + | |
| 3 | +Measured on 2026-11-14 with the [probe](../probe/README.md) on the `php85` (PHP 8.5.12) and `php84` (PHP 8.4.27) runtimes, region `fr-par`. | |
| 4 | +Both runtimes behaved identically. | |
| 5 | +Client addresses are replaced with documentation addresses (`2001:db8::1`, `203.0.113.66`). | |
| 6 | + | |
| 7 | +## Process | |
| 8 | + | |
| 9 | +- The runtime is one long-lived PHP CLI process (`sapi` = `cli`, pid 8) running a ReactPHP HTTP server (`/home/app/index.php`, `SCW_RUNTIME_BRIDGE`) that includes `/home/app/function/handler.php` and calls `handle()`. | |
| 10 | +- Warm Processes are reused: consecutive Invocations hit the same pid with an increasing counter. | |
| 11 | +- `$_SERVER['SCRIPT_FILENAME']`, `PHP_SELF` and `argv[0]` are `/home/app/index.php`; `$_GET`, `$_POST`, `$_COOKIE`, `$_FILES` are empty. | |
| 12 | +- The working directory is `/home/app/function`, which is writable, as is `/tmp`. | |
| 13 | +- Function environment variables (plain and secret) reach `getenv()`; the platform also sets `SCW_APPLICATION_NAME`, `SCW_APPLICATION_ID`, `SCW_NAMESPACE_ID`, `SCW_APPLICATION_REGION`, `SCW_APPLICATION_MEMORY`, `SCW_PAYLOAD_MAX_SIZE` (6291456), `SCW_PUBLIC`, `SCW_HANDLER_NAME`, `SCW_HANDLER_PATH`. | |
| 14 | +- Anything written to stdout does not end up in the response body. | |
| 15 | +- An uncaught exception yields `500` with the body `Error while executing function`. | |
| 16 | + | |
| 17 | +## Deployment and Composer | |
| 18 | + | |
| 19 | +- When the zip has a `composer.json` at its root, Scaleway runs `composer install` at deploy time (`COMPOSER_DEV_MODE=0`, i.e. `--no-dev`) in `/home/app/function`, replacing any shipped `vendor/`. | |
| 20 | +- A shipped `composer.lock` is respected (a package pinned to an older version in the lock was installed at that version). | |
| 21 | +- Composer scripts run (`post-install-cmd`; `post-update-cmd` when no lock is shipped). | |
| 22 | +- Function environment variables are not available to Composer scripts at deploy time (`APP_ENV` and custom variables were unset). | |
| 23 | +- A failing Composer script does not fail the deployment: the function still becomes `ready`. | |
| 24 | +- With `composer.json` and `vendor/` in a subdirectory instead of the zip root, Scaleway does not run Composer and keeps the shipped `vendor/`. | |
| 25 | + | |
| 26 | +## HTTP Event | |
| 27 | + | |
| 28 | +Keys: `resource`, `path`, `httpMethod`, `headers`, `multiValueHeaders` (null), `queryStringParameters`, `multiValueQueryStringParameters` (null), `pathParameters` (null), `stageVariables`, `requestContext` (with `httpMethod`), `body`, `isBase64Encoded`. | |
| 29 | + | |
| 30 | +- The method is in `httpMethod`; there is no `method` key. | |
| 31 | +- `queryStringParameters` is decoded and keeps the last value of repeated keys: `?repeated=a&repeated=b&list[]=x&list[]=y` gives `{"repeated": "b", "list[]": "y"}`; it is an empty list `[]` when there is no query string. | |
| 32 | +- Header names are canonicalised (`X-Custom`, `User-Agent`), single string values. | |
| 33 | +- There is no `Host` header. | |
| 34 | +- `isBase64Encoded` is `true` with a base64 body for binary and multipart bodies, `true` with an empty body for GET, and absent for text bodies (JSON, plain text). | |
| 35 | +- Bodies up to 6 MiB are accepted; 7 MiB is rejected by the platform with `413` before reaching the function. | |
| 36 | + | |
| 37 | +Headers added by the platform on an external HTTP call: | |
| 38 | + | |
| 39 | +``` | |
| 40 | +Forwarded: for="[2001:db8::1]";proto=https, for=100.96.1.187 | |
| 41 | +K-Proxy-Request: activator | |
| 42 | +X-Envoy-External-Address: 2001:db8::1 | |
| 43 | +X-Forwarded-For: 2001:db8::1, 100.96.1.187, 100.96.38.33 | |
| 44 | +X-Forwarded-Proto: https | |
| 45 | +X-Real-Ip: 2001:db8::1 | |
| 46 | +X-Request-Id: <uuid> | |
| 47 | +``` | |
| 48 | + | |
| 49 | +Headers sent by the client: | |
| 50 | + | |
| 51 | +| Header | Behaviour | | |
| 52 | +| --- | --- | | |
| 53 | +| `X-Forwarded-For` | Client value prepended: `203.0.113.66,2001:db8::1, 100.96.2.180, 100.96.36.219` | | |
| 54 | +| `X-Forwarded-Host`, `X-Forwarded-Port` | Passed through unchanged (forgeable) | | |
| 55 | +| `Forwarded` | Client value replaces the platform one (forgeable) | | |
| 56 | +| `X-Forwarded-Proto` | Overwritten with `https` | | |
| 57 | +| `X-Real-Ip`, `X-Envoy-External-Address`, `X-Request-Id`, `K-Proxy-Request` | Overwritten by the platform | | |
| 58 | +| `Host` | Not forwarded to the function (an unknown host routes to a 404) | | |
| 59 | + | |
| 60 | +## CRON Event | |
| 61 | + | |
| 62 | +```json | |
| 63 | +{ | |
| 64 | + "path": "/", | |
| 65 | + "httpMethod": "POST", | |
| 66 | + "headers": { | |
| 67 | + "Content-Length": "40", | |
| 68 | + "Content-Type": "application/json", | |
| 69 | + "Forwarded": "for=100.96.2.180;proto=http", | |
| 70 | + "K-Proxy-Request": "activator", | |
| 71 | + "User-Agent": "Go-http-client/1.1", | |
| 72 | + "X-Forwarded-For": "100.96.2.180, 100.96.36.219", | |
| 73 | + "X-Forwarded-Proto": "http", | |
| 74 | + "X-Request-Id": "<uuid>" | |
| 75 | + }, | |
| 76 | + "queryStringParameters": [], | |
| 77 | + "body": "{\"probe\":\"cron\",\"nested\":{\"list\":[1,2]}}" | |
| 78 | +} | |
| 79 | +``` | |
| 80 | + | |
| 81 | +- The trigger `args` arrive as a JSON string in `body`, without `isBase64Encoded`. | |
| 82 | +- CRON Events carry neither `X-Real-Ip` nor `X-Envoy-External-Address`, which the platform always sets (overwriting client values) on external HTTP calls. | |
| 83 | + | |
| 84 | +## Context | |
| 85 | + | |
| 86 | +An `array`: `{"memoryLimitInMb": 256, "functionName": "probe-php85", "functionVersion": ""}`. | |
| 87 | + | |
| 88 | +## Function Response | |
| 89 | + | |
| 90 | +- Array header values are sent as repeated headers (`Set-Cookie` included). | |
| 91 | +- Binary bodies with `isBase64Encoded: true` are decoded by the platform. | |
| 92 | +- Without `headers`, the response gets `Content-Type: text/plain; charset=utf-8`. | |
| 93 | +- Custom status codes pass through (`418`). | |
| 94 | +- `HEAD` responses carry `Content-Length` and no body. | |
| 95 | +- The platform adds `Access-Control-Allow-Origin: *` and `Access-Control-Allow-Headers: Content-Type` to every response. | |
| 96 | + | |
| 97 | +## Terraform | |
| 98 | + | |
| 99 | +- Replacing a function (for example changing `runtime`) deletes its CRON triggers server side; Terraform recreates them only on the next apply. | |
| 100 | + | |
| 101 | +## Not measured | |
| 102 | + | |
| 103 | +- Cockpit logs (where stdout and uncaught exceptions are logged). | |
| 104 | +- Whether a deployment with a failing Composer script serves the new code or keeps the previous version. | |
| new file mode 100644 | |||
| @@ -0,0 +1,104 @@ | |||
| 1 | +# Probe results | ||
| 2 | + | ||
| 3 | +Measured on 2026-11-14 with the [probe](../probe/README.md) on the `php85` (PHP 8.5.12) and `php84` (PHP 8.4.27) runtimes, region `fr-par`. | ||
| 4 | +Both runtimes behaved identically. | ||
| 5 | +Client addresses are replaced with documentation addresses (`2001:db8::1`, `203.0.113.66`). | ||
| 6 | + | ||
| 7 | +## Process | ||
| 8 | + | ||
| 9 | +- The runtime is one long-lived PHP CLI process (`sapi` = `cli`, pid 8) running a ReactPHP HTTP server (`/home/app/index.php`, `SCW_RUNTIME_BRIDGE`) that includes `/home/app/function/handler.php` and calls `handle()`. | ||
| 10 | +- Warm Processes are reused: consecutive Invocations hit the same pid with an increasing counter. | ||
| 11 | +- `$_SERVER['SCRIPT_FILENAME']`, `PHP_SELF` and `argv[0]` are `/home/app/index.php`; `$_GET`, `$_POST`, `$_COOKIE`, `$_FILES` are empty. | ||
| 12 | +- The working directory is `/home/app/function`, which is writable, as is `/tmp`. | ||
| 13 | +- Function environment variables (plain and secret) reach `getenv()`; the platform also sets `SCW_APPLICATION_NAME`, `SCW_APPLICATION_ID`, `SCW_NAMESPACE_ID`, `SCW_APPLICATION_REGION`, `SCW_APPLICATION_MEMORY`, `SCW_PAYLOAD_MAX_SIZE` (6291456), `SCW_PUBLIC`, `SCW_HANDLER_NAME`, `SCW_HANDLER_PATH`. | ||
| 14 | +- Anything written to stdout does not end up in the response body. | ||
| 15 | +- An uncaught exception yields `500` with the body `Error while executing function`. | ||
| 16 | + | ||
| 17 | +## Deployment and Composer | ||
| 18 | + | ||
| 19 | +- When the zip has a `composer.json` at its root, Scaleway runs `composer install` at deploy time (`COMPOSER_DEV_MODE=0`, i.e. `--no-dev`) in `/home/app/function`, replacing any shipped `vendor/`. | ||
| 20 | +- A shipped `composer.lock` is respected (a package pinned to an older version in the lock was installed at that version). | ||
| 21 | +- Composer scripts run (`post-install-cmd`; `post-update-cmd` when no lock is shipped). | ||
| 22 | +- Function environment variables are not available to Composer scripts at deploy time (`APP_ENV` and custom variables were unset). | ||
| 23 | +- A failing Composer script does not fail the deployment: the function still becomes `ready`. | ||
| 24 | +- With `composer.json` and `vendor/` in a subdirectory instead of the zip root, Scaleway does not run Composer and keeps the shipped `vendor/`. | ||
| 25 | + | ||
| 26 | +## HTTP Event | ||
| 27 | + | ||
| 28 | +Keys: `resource`, `path`, `httpMethod`, `headers`, `multiValueHeaders` (null), `queryStringParameters`, `multiValueQueryStringParameters` (null), `pathParameters` (null), `stageVariables`, `requestContext` (with `httpMethod`), `body`, `isBase64Encoded`. | ||
| 29 | + | ||
| 30 | +- The method is in `httpMethod`; there is no `method` key. | ||
| 31 | +- `queryStringParameters` is decoded and keeps the last value of repeated keys: `?repeated=a&repeated=b&list[]=x&list[]=y` gives `{"repeated": "b", "list[]": "y"}`; it is an empty list `[]` when there is no query string. | ||
| 32 | +- Header names are canonicalised (`X-Custom`, `User-Agent`), single string values. | ||
| 33 | +- There is no `Host` header. | ||
| 34 | +- `isBase64Encoded` is `true` with a base64 body for binary and multipart bodies, `true` with an empty body for GET, and absent for text bodies (JSON, plain text). | ||
| 35 | +- Bodies up to 6 MiB are accepted; 7 MiB is rejected by the platform with `413` before reaching the function. | ||
| 36 | + | ||
| 37 | +Headers added by the platform on an external HTTP call: | ||
| 38 | + | ||
| 39 | +``` | ||
| 40 | +Forwarded: for="[2001:db8::1]";proto=https, for=100.96.1.187 | ||
| 41 | +K-Proxy-Request: activator | ||
| 42 | +X-Envoy-External-Address: 2001:db8::1 | ||
| 43 | +X-Forwarded-For: 2001:db8::1, 100.96.1.187, 100.96.38.33 | ||
| 44 | +X-Forwarded-Proto: https | ||
| 45 | +X-Real-Ip: 2001:db8::1 | ||
| 46 | +X-Request-Id: <uuid> | ||
| 47 | +``` | ||
| 48 | + | ||
| 49 | +Headers sent by the client: | ||
| 50 | + | ||
| 51 | +| Header | Behaviour | | ||
| 52 | +| --- | --- | | ||
| 53 | +| `X-Forwarded-For` | Client value prepended: `203.0.113.66,2001:db8::1, 100.96.2.180, 100.96.36.219` | | ||
| 54 | +| `X-Forwarded-Host`, `X-Forwarded-Port` | Passed through unchanged (forgeable) | | ||
| 55 | +| `Forwarded` | Client value replaces the platform one (forgeable) | | ||
| 56 | +| `X-Forwarded-Proto` | Overwritten with `https` | | ||
| 57 | +| `X-Real-Ip`, `X-Envoy-External-Address`, `X-Request-Id`, `K-Proxy-Request` | Overwritten by the platform | | ||
| 58 | +| `Host` | Not forwarded to the function (an unknown host routes to a 404) | | ||
| 59 | + | ||
| 60 | +## CRON Event | ||
| 61 | + | ||
| 62 | +```json | ||
| 63 | +{ | ||
| 64 | + "path": "/", | ||
| 65 | + "httpMethod": "POST", | ||
| 66 | + "headers": { | ||
| 67 | + "Content-Length": "40", | ||
| 68 | + "Content-Type": "application/json", | ||
| 69 | + "Forwarded": "for=100.96.2.180;proto=http", | ||
| 70 | + "K-Proxy-Request": "activator", | ||
| 71 | + "User-Agent": "Go-http-client/1.1", | ||
| 72 | + "X-Forwarded-For": "100.96.2.180, 100.96.36.219", | ||
| 73 | + "X-Forwarded-Proto": "http", | ||
| 74 | + "X-Request-Id": "<uuid>" | ||
| 75 | + }, | ||
| 76 | + "queryStringParameters": [], | ||
| 77 | + "body": "{\"probe\":\"cron\",\"nested\":{\"list\":[1,2]}}" | ||
| 78 | +} | ||
| 79 | +``` | ||
| 80 | + | ||
| 81 | +- The trigger `args` arrive as a JSON string in `body`, without `isBase64Encoded`. | ||
| 82 | +- CRON Events carry neither `X-Real-Ip` nor `X-Envoy-External-Address`, which the platform always sets (overwriting client values) on external HTTP calls. | ||
| 83 | + | ||
| 84 | +## Context | ||
| 85 | + | ||
| 86 | +An `array`: `{"memoryLimitInMb": 256, "functionName": "probe-php85", "functionVersion": ""}`. | ||
| 87 | + | ||
| 88 | +## Function Response | ||
| 89 | + | ||
| 90 | +- Array header values are sent as repeated headers (`Set-Cookie` included). | ||
| 91 | +- Binary bodies with `isBase64Encoded: true` are decoded by the platform. | ||
| 92 | +- Without `headers`, the response gets `Content-Type: text/plain; charset=utf-8`. | ||
| 93 | +- Custom status codes pass through (`418`). | ||
| 94 | +- `HEAD` responses carry `Content-Length` and no body. | ||
| 95 | +- The platform adds `Access-Control-Allow-Origin: *` and `Access-Control-Allow-Headers: Content-Type` to every response. | ||
| 96 | + | ||
| 97 | +## Terraform | ||
| 98 | + | ||
| 99 | +- Replacing a function (for example changing `runtime`) deletes its CRON triggers server side; Terraform recreates them only on the next apply. | ||
| 100 | + | ||
| 101 | +## Not measured | ||
| 102 | + | ||
| 103 | +- Cockpit logs (where stdout and uncaught exceptions are logged). | ||
| 104 | +- Whether a deployment with a failing Composer script serves the new code or keeps the previous version. | ||