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

Add a debounce/throttle on document addition #399

Open
bidoubiwa opened this issue Apr 28, 2022 · 2 comments · May be fixed by #972
Open

Add a debounce/throttle on document addition #399

bidoubiwa opened this issue Apr 28, 2022 · 2 comments · May be fixed by #972
Labels
enhancement New feature or request

Comments

@bidoubiwa
Copy link
Contributor

Description
Strapi has not a lot of ways to add documents in batches. Most ways to achieve entry addition is one by one. While it is not a problem with a small number of document addition, if a user add's thousands of document at the time the web-server starts to reject new webserver calls, or abort new additions to its own database.

Error: aborted
262: aborted
Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?

Another issue is that Meilisearch does not like at all to have small batches. Meilisearch is more performant with one addition of 100Mo of document than it is with 10000 additions of 1 document.

To avoid this, we should create a debounce system or a throttle system that avoid an overload of calls to meilisearch.

@bidoubiwa bidoubiwa added the enhancement New feature or request label Apr 28, 2022
@Ra0R
Copy link

Ra0R commented Oct 23, 2024

We are having the same problem with our system. We sync around ~15k documents every day. Adding them to the index one-by-one takes a long time.

Here are the changes I would suggest:

Since Strapi v4.9.0, the createMany()-Lifecycle hook properly returns a count and a set of ids after creation:
e.g.

 { count: 2 , ids: [1,2]}

This should be properly handled in this part of the code:
https://github.com/meilisearch/strapi-plugin-meilisearch/blob/f47f50a86ee189ec36d1fc8b2a7a1140a847abba/server/services/lifecycle/lifecycle.js#L45C1-L49C11

Either check for Strapi Version or update package.json with "peerDependency": { "Strapi": "^4.9.0"}

Let me know if I can implement this.

@brunoocasali
Copy link
Member

That would be nice @Ra0R a PR would be very appreciated!

@Ra0R Ra0R linked a pull request Nov 4, 2024 that will close this issue
3 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
None yet
Development

Successfully merging a pull request may close this issue.

4 participants