Skip to content

[MongoDB] Track bytes, transactions and chunks replicated#575

Merged
rkistner merged 7 commits intomainfrom
tweak-mongodb-metrics
Mar 19, 2026
Merged

[MongoDB] Track bytes, transactions and chunks replicated#575
rkistner merged 7 commits intomainfrom
tweak-mongodb-metrics

Conversation

@rkistner
Copy link
Copy Markdown
Contributor

@rkistner rkistner commented Mar 19, 2026

These replication metrics are being tracked for the various source databases:

Metric PostgreSQL MySQL SQL Server MongoDB
powersync_data_replicated_bytes_total 🆕
powersync_rows_replicated_total
powersync_transactions_replicated_total 🆕
powersync_chunks_replicated_total 🆕
powersync_replication_lag_seconds

This PR adds tracking of powersync_data_replicated_bytes_total and powersync_transactions_replicated_total.

Transactions replicated is informational only - it has no direct effect on performance and is not a good measurement of replication performance. It is however easy to track, and may give an indication of the write patterns on the source database.

Data replicated bytes can be a good indication of replication performance. If this metric is low while replication lag is building up, it gives an indication of a replication throughput issue, such as #573. Note that this is slightly different from bytes transferred over the network - the metric here is after decompression, and without TLS and other protocol overhead.

Chunks replicated is an internal metric in how the database batches the data. We don't directly replicate according to these chunks at the moment, but it could give useful info in some cases.

Unfortunately the byte tracking relies on internals in the MongoDB driver. We do test it properly, and gracefully handle cases where the properties are not present - for metrics it may be better to not have the metrics rather than have a hard failure. If we go with an approach such as #309 in the future, we should be able to remove these hacks.

@rkistner rkistner requested a review from stevensJourney March 19, 2026 09:26
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 19, 2026

🦋 Changeset detected

Latest commit: 1477026

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@powersync/service-module-mongodb Patch
@powersync/service-schema Patch
@powersync/service-image Patch
@powersync/service-core Patch
@powersync/service-core-tests Patch
@powersync/service-module-core Patch
@powersync/service-module-mongodb-storage Patch
@powersync/service-module-mssql Patch
@powersync/service-module-mysql Patch
@powersync/service-module-postgres-storage Patch
@powersync/service-module-postgres Patch
test-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rkistner rkistner changed the title [MongoDB] Track bytes replicated and transactions replicated [MongoDB] Track bytes, transactions and chunks replicated Mar 19, 2026
@rkistner rkistner merged commit c546708 into main Mar 19, 2026
103 of 106 checks passed
@rkistner rkistner deleted the tweak-mongodb-metrics branch March 19, 2026 10:47
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.

3 participants