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 Callback Throttling #1311

Open
chriddyp opened this issue Jun 25, 2020 · 2 comments
Open

add Callback Throttling #1311

chriddyp opened this issue Jun 25, 2020 · 2 comments
Labels
feature something new P3 backlog

Comments

@chriddyp
Copy link
Member

chriddyp commented Jun 25, 2020

Throttling!

If your UI enables rapid user interaction & updates, then how do you prevent the server or the clientside JS from getting overloaded?

This has come up here and there over the years and we've solved pieces of this puzzle in different ways:

  1. When typing into a dcc.Input, users can prevent every single keypress from updating the callback by using buttons with State or on blur (tabbing or entering) with n_blur & n_submit
  2. In serverside callbacks, if many requests are made at the same time for the same callback, then we'll prune out redundant requests while they're in the queue - Callback chain refactoring and performance improvements #1254

This still laves some use cases:

  1. What if you want to allow keypress updates, but just less frequently?
  2. What about clientside callbacks that don't get the same network request pruning in Callback chain refactoring and performance improvements #1254?
  3. What about components that don't have an equivalent of "blur" or "enter" and aren't well suited for buttons & State? Like hoverData in dcc.Graph

One idea is to solve this in the framework level with:

@app.callback(Output(...), [Input(...)], throttle=500)

This would be the second keyword argument into app.callback. The first was introduced in 1.12.0 with prevent_initial_call=True, see #1228


If any community member is interested in exploring this idea, then see:

  1. Prevent initial call #1228 for an example of how to wire callback keyword arguments from the backend up to the frontend
  2. https://github.com/plotly/dash/blob/dev/dash-renderer/src/observers/requestedCallbacks.ts for where callbacks are queued up for requests. Some throttling logic might go in here. See Callback chain refactoring and performance improvements #1254 for some context on the State Machine refactoring
  3. Contributing guide: https://github.com/plotly/dash/blob/dev/CONTRIBUTING.md
  4. After you've made a little progress, please submit a PR early to let us know that you are working on this

Alternatively, this work (and the rest of our work) can be funded by directly by organizations: https://plotly.com/products/consulting-and-oem or prioritized by Dash Enterprise customers.

@alexrblohm
Copy link

I am interested in this!

@brenoingwersen
Copy link

Just came up to the need. Would be a really cool feature.

@gvwilson gvwilson self-assigned this Jul 25, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added the P3 backlog label Aug 13, 2024
@gvwilson gvwilson changed the title Callback Throttling add Callback Throttling Aug 13, 2024
@gvwilson gvwilson added the feature something new label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 backlog
Projects
None yet
Development

No branches or pull requests

4 participants