Skip to content

fix: don't let a slow log endpoint hold every Lambda invocation - #977

Merged
alongubkin merged 2 commits into
mainfrom
alon/alien-1366-lambda-log-export-wait
Oct 10, 2026
Merged

alongubkin merged 2 commits into
mainfrom
alon/alien-1366-lambda-log-export-wait

Conversation

@alongubkin

Copy link
Copy Markdown
Member

Problem

#970 made the Lambda wait_until extension flush application logs after every invocation, waiting up to the invocation deadline minus 250 ms. Lambda doesn't give an environment its next invocation until the extension returns, so each invocation now holds its environment for as long as the OTLP export takes. With the default 180 s timeout the wait is bounded only by the SDK's 5 s force_flush timeout.

Load test, 20 rps for 3 minutes against a function URL, simple worker that logs one line per request (arm64, 512 MB, 180 s timeout; test account with a 10-concurrent-execution limit):

log endpoint runtime ok / sent Lambda Duration p50 billed avg logs delivered
healthy before #970 3600 / 3600 3.3 ms 5.3 ms 3571 / 3600
healthy #970 3600 / 3600 4.5 ms 6.8 ms 3600 / 3600
healthy this PR 3600 / 3600 4.0 ms 5.5 ms 3600 / 3600
+1.5 s latency before #970 3600 / 3600 2.7 ms 4.4 ms 3506 / 3600
+1.5 s latency #970 1152 / 3600 (2448 × 429) 1506 ms 1518 ms 1152 / 1152
+1.5 s latency this PR 3500 / 3600 (100 × 429) 3.1 ms (p95 505) 135 ms 3492 / 3500
unreachable (SYN dropped) before #970 3597 / 3600 2.9 ms 6.9 ms 0
unreachable #970 360 / 3600 (3240 × 429) 5003 ms 5028 ms 0
unreachable this PR 3578 / 3600 (22 × 429) 2.6 ms (p95 504) 50 ms 0

Client latency of successful requests is unchanged in every row (p50 55-57 ms). The cost shows up as concurrency: with #970 each environment serves at most one request per export time, so an unreachable endpoint needs ~1000x the environments, and a slow one ~350x the billed time. In an account with a normal concurrency limit that is a large bill; at the limit it throttles callers.

Fix

  • An invocation waits at most 500 ms for its export (still never past the deadline minus 250 ms). A healthy endpoint answers well inside that.
  • If an earlier export hasn't finished, the invocation doesn't start or wait for another. Its records stay in the batch and go out with the next export. An unreachable endpoint then holds one invocation per stuck export instead of every invocation.
  • Failures are still logged, never returned to the caller.

Alternatives: a shorter fixed cap alone still holds every invocation during an outage (500 ms each); skipping alone still holds every other invocation for the SDK's 5 s flush timeout; a SimpleLogProcessor exports inside the request path.

Proof

Rollout

Ships in the worker base image with the next release. Without this, #970 should not be released.

ALIEN-1366

🤖 Generated with Claude Code

…outstanding

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@enclave-ai

enclave-ai Bot commented Oct 10, 2026

Copy link
Copy Markdown

Enclave skipped this draft pull request. It will run automatically when you mark the PR as Ready for review.

@alongubkin

Copy link
Copy Markdown
Member Author

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High impact] The PR appears safe to merge; the latest change fixes the blocked-exporter cleanup issue.

Summary

The PR caps each invocation’s log-export wait at 500 ms and skips another export while an earlier one is still running.

  • Lambda log exports no longer hold every invocation for a slow endpoint.

Reviews (3) · Last reviewed commit: "test: release the unanswered endpoint ev..." · Reviewed by Greptile

Comment thread crates/alien-worker-runtime/src/transports/lambda.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alongubkin

Copy link
Copy Markdown
Member Author

@greptileai review

@alongubkin
alongubkin marked this pull request as ready for review October 10, 2026 04:56
@alongubkin
alongubkin merged commit 45c9fe3 into main Oct 10, 2026
24 checks passed
@alongubkin
alongubkin deleted the alon/alien-1366-lambda-log-export-wait branch October 10, 2026 04:59
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