Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Add Stateful Buffering to LambdaSink #5353

Open
srikanthjg opened this issue Jan 24, 2025 · 0 comments · May be fixed by #5354
Open

[Enhancement] Add Stateful Buffering to LambdaSink #5353

srikanthjg opened this issue Jan 24, 2025 · 0 comments · May be fixed by #5354
Assignees
Labels
enhancement New feature or request

Comments

@srikanthjg
Copy link
Collaborator

srikanthjg commented Jan 24, 2025

Summary

Currently, the LambdaSink sends all incoming records immediately to AWS Lambda, causing multiple small invocations if thresholds are not met. We want to keep a stateful (persistent) buffer in the sink so it only flushes full batches immediately (when thresholds are exceeded) and persists any partial (incomplete) batch until more events arrive or until the sink shuts down. This ensures fewer, larger Lambda invocations and avoids prematurely flushing partial data.

Persisting the last incomplete batch should meet the following conditions
(a) becomes full or
(b) the sink shuts down.

Details

Persistent Buffer

A single buffer (persistentBuffer) accumulates events across multiple doOutput() calls.
Only when size or event-count thresholds are reached do we treat that batch as “full” and flush it to Lambda.
The partial batch remains in memory until it either becomes full or the sink shuts down.

N-1 “full” buffers get flushed immediately,
The Nth (partial) buffer remains in memory until the next doOutput() call or shutdown().

Ensure Thread-Safety

When using persistent buffer, make sure we dont hit race conditions when multiple threads might write to buffer.

@srikanthjg srikanthjg self-assigned this Jan 24, 2025
@srikanthjg srikanthjg added enhancement New feature or request and removed untriaged labels Jan 24, 2025
@srikanthjg srikanthjg linked a pull request Jan 24, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

1 participant