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

Firestore replication: parallel writes instead batch #6743

Open
imcvampire opened this issue Jan 7, 2025 · 6 comments
Open

Firestore replication: parallel writes instead batch #6743

imcvampire opened this issue Jan 7, 2025 · 6 comments
Labels

Comments

@imcvampire
Copy link

Currently, firestore replication uses batch for insert and update. One drawback is that if there is an error from any doc, no doc will be committed to Firestore. Moreover, batch isn't faster than parallel writes.

I propose to change from batch write to parallel write, the change is small and doesn't break the compatibility.

So what do you think? Is it a good approach?

@pubkey
Copy link
Owner

pubkey commented Jan 8, 2025

Did you do performance tests for this? I do not see a reason why parallel writes should be faster.
In my opinion if the batch writes errors, you should fix that and not work around it.

@imcvampire
Copy link
Author

imcvampire commented Jan 8, 2025

About the performance, you can check one test here https://stackoverflow.com/a/58897275/5328683. And even Firestore recommend that.
Screenshot 2025-01-08 at 6 35 22 PM

In my opinion if the batch writes errors, you should fix that and not work around it.

Currently, I'm having an issue with attachment if the attachment is big enough, Firestore will reject it because of 1MB limit of a single object. I know it's better to fix the error and not workaround, but it's confusing at the same time that 1 error doc can break the whole app (no write is applied because all writes are put into single batch request)

@pubkey
Copy link
Owner

pubkey commented Jan 8, 2025

Ah I see. So we should set the batch-size to 1 by default on the firestore-replication plugin and allow users to still set the value to something else if they want to. PR is welcomed.

EDIT: Setting batch-size to 1 would mean we do serialized writes, not parallel writes. So this must be changed in the push-handler, not the batchSize option.

@imcvampire
Copy link
Author

So what is your call? Do you like the idea? I can start drafting a PR and we can continue discussing on that

@pubkey
Copy link
Owner

pubkey commented Jan 9, 2025

Yes you can make a PR for single parallel writes.

Copy link

stale bot commented Jan 16, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon. Please update it or it may be closed to keep our repository organized. The best way is to add some more information or make a pull request with a test case. Also you might get help in fixing it at the RxDB Community Chat If you know you will continue working on this, just write any message to the issue (like "ping") to remove the stale tag.

@stale stale bot added the stale label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants