Skip to content

source-*: Dynamic memory limits for Go connectors#4065

Merged
willdonnelly merged 1 commit intomainfrom
wgd/2026-03-23-memory-scaling
Mar 24, 2026
Merged

source-*: Dynamic memory limits for Go connectors#4065
willdonnelly merged 1 commit intomainfrom
wgd/2026-03-23-memory-scaling

Conversation

@willdonnelly
Copy link
Member

@willdonnelly willdonnelly commented Mar 24, 2026

Description:

Previously all Go connectors hard-coded an assumption that they're running with a 1GiB memory allocation and so we should attempt to keep Go heap size below 90% of that 1GiB to avoid OOMing.

After this change we instead read /sys/fs/cgroup/memory.max at runtime to see how much memory we're working with and set the Go heap limit to 90% of that.

In addition source-postgres has been updated to use half of that value as the maximum CDC event receive buffer size, in keeping with the previous hard-coded 512MiB.

Workflow steps:

No user action required. No behavior change expected on data planes with the default 1GiB connector memory allocation. Data planes with >1GB of connector RAM available should be able to make better use of that extra memory where necessary.

Notes for reviewers:

This should obviously have no effect in data planes with the default 1GB limits because the dynamic value will still be based on that 1GB limit. In data planes with >1GB available I think that this should still not increase steady-state memory usage, and if it does that suggests that the current 1GiB assumption is probably also doing the same thing and we should think about how to encourage connectors to release memory more proactively when they can get by with less.

Previously all Go connectors hard-coded an assumption that they're
running with a 1GiB memory allocation and so we should attempt to
keep Go heap size below 90% of available RAM to avoid OOMing.

After this change we instead read `/sys/fs/cgroup/memory.max` at
runtime to see how much memory we're working with and set the Go
heap limit to 90% of that.

In addition `source-postgres` has been updated to use half of that
value as the maximum CDC event receive buffer size, in keeping with
the previous hard-coded 512MiB.
@willdonnelly willdonnelly requested a review from a team March 24, 2026 01:06
@willdonnelly willdonnelly added the change:unplanned Unplanned change, useful for things like doc updates label Mar 24, 2026
Copy link
Member

@Alex-Bair Alex-Bair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@willdonnelly willdonnelly merged commit db0b5a6 into main Mar 24, 2026
66 of 69 checks passed
@willdonnelly willdonnelly deleted the wgd/2026-03-23-memory-scaling branch March 24, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:unplanned Unplanned change, useful for things like doc updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants