Repository navigation
fix: don't let a slow log endpoint hold every Lambda invocation - #977
Merged
Merged
Conversation
…outstanding Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Enclave skipped this draft pull request. It will run automatically when you mark the PR as Ready for review. |
Member
Author
|
@greptileai review |
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
@greptileai review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
#970 made the Lambda
wait_untilextension 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 sforce_flushtimeout.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):
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
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
SimpleLogProcessorexports inside the request path.Proof
an_unanswered_log_endpoint_does_not_hold_every_invocation: an exporter that blocks until released, driven through the real extension INVOKE handler. First invocation is held ≥500 ms and <1 s, the second <100 ms, and after release a third invocation exports all three lines in order. With fix: export Lambda application logs before the environment freezes #970's behavior restored:first invocation held for 5.001s, fails.the_log_export_wait_is_bounded_and_stops_short_of_the_deadlinefails on fix: export Lambda application logs before the environment freezes #970's wait (9.75svs500ms).cargo test -p alien-worker-runtime: all pass.ALIEN_LAMBDA_MODE=streaming,RESPONSE_STREAMURL, 1 s body, log line written just before the body closes): TTFB ~100 ms, Duration ~1008 ms, every line delivered by the end of the response with fix: export Lambda application logs before the environment freezes #970 and with this PR, so the invocation ends when the body ends. With an unreachable endpoint, fix: export Lambda application logs before the environment freezes #970: Duration 6.0 s and 28/120 throttled at 2 rps; this PR: 0 throttled.Rollout
Ships in the worker base image with the next release. Without this, #970 should not be released.
ALIEN-1366
🤖 Generated with Claude Code