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

Handling of overloaded backend #21

Open
martinpopel opened this issue Mar 17, 2022 · 2 comments
Open

Handling of overloaded backend #21

martinpopel opened this issue Mar 17, 2022 · 2 comments

Comments

@martinpopel
Copy link
Member

A request for translation is sent each time when the input text has changed (after some delay from the last key press), am I right?
Or do we wait until the last request is processed (translation returned and shown to the user) before we send a new request?

To prevent overloading of the backend, we should increase the delay from the last key press in case the previous request was not processed yet. Once all sent requests are processed, the delay would be reset to its default value. One extreme would be to increase the delay to infinity, i.e. never send a second request, but that seems too fragile (the request could got lost).
The motivation is that when the backend is under a heavy load and a user is editing a very long text, we should not send new request each second.

@martinpopel martinpopel added the question Further information is requested label Mar 17, 2022
@EbrithilNogare
Copy link
Collaborator

I tried make debounce more flexible (e.g. wait more time, if text is long) but is was not that easy.
Now it waits 500 ms, maybe changing it to 1000 or 1500 could be still responsive enought for user.

@martinpopel
Copy link
Member Author

I don't think we should try to estimate the translation time based on the text length. (Moreover, if a user pastes a long text from the clipboard, we should not wait longer than the default 500 ms.)
What I am suggesting is that a new request for translation should be sent if the following two conditions are met:

  • The last key press was at least 500 ms ago (this is already implemented using debounce).
  • The last request for translation was already processed (i.e. the translation is shown to the user) or if the last request was sent at least N seconds ago (this needs to be implemented).

We can either set N to e.g. 10 seconds for simplicity, or double the value with each request sent (and set back to 10 once the last request is processed).

@martinpopel martinpopel added low-priority and removed question Further information is requested labels May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants