-
-
Notifications
You must be signed in to change notification settings - Fork 198
feat: add pg_egress_collect service #486
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
Merged
Merged
Conversation
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
@burmecia have you collected data on performance overhead for this across a few projects with different utilizations? |
I tried several projects including my personal projects and RevOps project, not much overhead I can see. CPU usage is unnoticeable, memory is about 10M and only write one line to a tmp file per minute. |
Tested its performance on my project, below are the setups:
And the test result is:
|
darora
reviewed
Jan 20, 2023
michelp
approved these changes
Jan 23, 2023
darora
approved these changes
Jan 25, 2023
This was referenced Jan 25, 2023
Merged
damonrand
pushed a commit
to cepro/postgres
that referenced
this pull request
Jun 15, 2025
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.
What kind of change does this PR introduce?
This PR is to add service for postgres egress metric collection. See more context: https://www.notion.so/supabase/Fix-DB-egress-metric-190164a5c4e5444cbbe20c726cea241d
What is the current behavior?
Currently there is no reliable way to gather accurate database-only egress, so the whole server egress is used instead.
What is the new behavior?
The solution is using
tcpdump
to capture outgoing TCP packets on port 5432 and 6543, and a perl script extract packet length and sum up to one minute interval. The result is saved to text file at/tmp/pg_egress_collect.txt
by default. Admin API then can read metric from that file and expose it to Victoria Metrics.By using this approach, we can collect accurate network egress for postgres and expose it in admin api so Victoria Metrics can gather for downstream pipeline.
Additional context
This metric will also be as data source for admin api, see more details: https://github.com/supabase/supabase-admin-api/pull/130