Repository navigation
Description
What happened:
The Dask Scheduler Dashboard CPU usage increases when the dashboard is used but it keeps being high after the user closes the dashboard. I think that this could be related with other issues like dask/dask#8493.
Steps to reproduce:
- Start dask-scheduler
- Open the browser at localhost:8787
- Reload several times.
You can expect the CPU usage to increase the more you reload.
What you expected to happen:
The CPU usage should be stable or at least decrease when the user closes the tab.
More information:
I've added logs to see the active Bokeh sessions
#dashboard/scheduler.py
...
def connect(application, http_server, scheduler, prefix=""):
bokeh_app = BokehApplication(
applications, scheduler, prefix=prefix, template_variables=template_variables
)
application.add_application(bokeh_app)
bokeh_app.initialize(IOLoop.current())
bokeh_app.add_handlers(
r".*",
[
(
r"/",
web.RedirectHandler,
{"url": urljoin((prefix or "").strip("/") + "/", r"status")},
)
],
)
import threading
threading.Thread(
target=run_stuff,
args=(bokeh_app,),
).start()
from time import sleep
def run_stuff(bokeh_app):
while True:
sleep(1)
sessions = bokeh_app.get_sessions("/status")
print('Total sessions', len(sessions))
for (c, session) in enumerate(sessions):
print('conn:', c, session.connection_count)Each time the browser reloads the number of sessions increases even though the connection count for all sessions but one is 0.
How to fix this? (I think)
The problem is that the cleaning callback loop is not started. To start one simply has to call bokeh_app.start() after the initialization.
#dashboard/scheduler.py
...
def connect(application, http_server, scheduler, prefix=""):
bokeh_app = BokehApplication(
applications, scheduler, prefix=prefix, template_variables=template_variables
)
application.add_application(bokeh_app)
bokeh_app.initialize(IOLoop.current())
bokeh_app.add_handlers(
r".*",
[
(
r"/",
web.RedirectHandler,
{"url": urljoin((prefix or "").strip("/") + "/", r"status")},
)
],
)
bokeh_app.start()Also setting the option unused_session_lifetime_milliseconds to 500 helps cleaning the sessions faster.
Environment:
- Dask version: 2022.6.1
- Python version: 3.10
- Operating System: Ubuntu 22.04
- Install method (conda, pip, source): pip
Activity
pavithraes commentedon Jul 6, 2022
@z4m0 Thank you for a well-explained report, and for including a possible solution!
z4m0 commentedon Jul 14, 2022
@pavithraes Any news on this? Do you need a PR?
gjoseph92 commentedon Jul 14, 2022
@z4m0 a PR would be welcome if you feel like opening one, thanks!
z4m0 commentedon Jul 19, 2022
@gjoseph92 I've opened a (one line) PR if somebody can review it. :)