# Python using at least 25% CPU power when Dash is running, without any page reloads

**URL:** <https://community.plotly.com/t/python-using-at-least-25-cpu-power-when-dash-is-running-without-any-page-reloads/15366>\
**Category:** Dash Python\
**Created:** [November 6, 2018, 3:59pm UTC](https://community.plotly.com/t/python-using-at-least-25-cpu-power-when-dash-is-running-without-any-page-reloads/15366 "2018-11-06T15:59:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rStorms](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@rStorms](https://community.plotly.com/u/rStorms)\
**Post date:** [November 6, 2018, 3:59pm UTC](https://community.plotly.com/t/python-using-at-least-25-cpu-power-when-dash-is-running-without-any-page-reloads/15366/1 "2018-11-06T15:59:03Z")

</div>

Hi all,

I am trying out my first Dash app, which is based on a small sqlite database which is updated hourly with values. Therefore I want to update the data on every page reload. Regarding functionality everything works fine, however I got some problems with my CPU load. I just started the server with “python app.py” and without any reloads at all my cpu load of the python process remains at 25%.

Part of my code:  
import dash  
import dash\_core\_components as dcc  
import dash\_html\_components as html  
import pandas as pd  
from functions import \*  
import plotly.graph\_objs as go  
from dash.dependencies import Input, Output

```
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash( __name__ , external_stylesheets=external_stylesheets)

#Generate the Dash App
app.layout = html.Div([
    dcc.Dropdown(
        id='dropdown',
        options=[
            {'label': 'Gesamtportfolio', 'value': 'gesamtportfolio'},
            {'label': 'Kaufwert vs. Aktueller Wert', 'value': 'kaufwertVsAktuell'},
            {'label': 'Test', 'value': 'test'}
        ],
        value='gesamtportfolio'
    ),
    dcc.Graph(id='graph', style={'height': '94vh'})
    ]
)

@app.callback(
    dash.dependencies.Output('graph', 'figure'),
    [dash.dependencies.Input('dropdown', 'value')])
def update_figure(selected_graph):
    if selected_graph == 'gesamtportfolio':
        print(selected_graph)
        #Read in the entire depot
        depot = serve_df()

        depotNow = depot.pivot_table(index='date', columns='position', values='total_value')

        traces = []

        #Iterate through depot with current values and add them to the trace
        for position, values in depotNow.iteritems():
            traces.append(go.Scatter(x=values.index, y=values.values, name=position, stackgroup='A'))

        return {
            'data': traces,
            'layout': go.Layout(
                legend={'x': 0, 'y': 0, 'bgcolor': 'rgba(255,255,255,.65)'},
                margin=go.layout.Margin(
                    l=40,
                    r=10,
                    b=30,
                    t=10,
                    pad=4
                )
            )
        }

    if selected_graph == 'kaufwertVsAktuell':
        #anothergraph

    if selected_graph == 'test':
        #testing out new plots

if __name__ == ' __main__':
    app.run_server(debug=True, host='localhost', port=8050)

```

Any ideas why this is?

Bonus question: On first reload the y axis is showing a value which is twice as high as it should be. Imagine my portfolio with all stacked traces around 10. On first reload the y axis shows 20, although all the traces accumulate only to 10. When I select the plot again in the drop down and the plot reloads the y axis is correct, showing only 10.

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![Damian](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Damian](https://community.plotly.com/u/Damian)\
**Post date:** [November 6, 2018, 6:58pm UTC](https://community.plotly.com/t/python-using-at-least-25-cpu-power-when-dash-is-running-without-any-page-reloads/15366/2 "2018-11-06T18:58:08Z")

</div>

Try it with debug=False.

With debug=True it’s constantly re-scanning for any files that are modified + other stuff, I’ve noticed it use at least 7% CPU on my machine, so could be the same.

---

<div class="post-metadata">

**Author:** ![rStorms](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@rStorms](https://community.plotly.com/u/rStorms)\
**Post date:** [November 7, 2018, 9:18am UTC](https://community.plotly.com/t/python-using-at-least-25-cpu-power-when-dash-is-running-without-any-page-reloads/15366/3 "2018-11-07T09:18:56Z")

</div>

Thanks, that actually helped. Thought my code was just producing some background task, that was creating the load. Any idea regarding the “Bonus question”? Seems weird to me, that on first load the y axis is wrong, although the code is just using the same code for the initial load, as for the callback when changing to that chart…

---

<div class="post-metadata">

**Author:** ![Damian](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Damian](https://community.plotly.com/u/Damian)\
**Post date:** [November 7, 2018, 2:52pm UTC](https://community.plotly.com/t/python-using-at-least-25-cpu-power-when-dash-is-running-without-any-page-reloads/15366/4 "2018-11-07T14:52:57Z")

</div>

> [@rStorms](#):
>
> Any idea regarding the “Bonus question”? Seems weird to me, that on first load the y axis is wrong,

I’m not a Dash expert, and if I were you and couldn’t figure it out I would ask the specific question as a new thread with screenshots.

However my understanding is the layout gets called before any callbacks get fired, and in the layout your graph doesn’t have any data, perhaps you can set some initial conditions you want in your layout? Either by providing it some data or looking in the the properties of Graph, I’m sure there’s a way to set initial X and Y values.

---

<div class="post-metadata">

**Author:** ![olejorgenb](https://avatars.discourse-cdn.com/v4/letter/o/ccd318/32.png) [@olejorgenb](https://community.plotly.com/u/olejorgenb)\
**Post date:** [November 28, 2025, 10:55am UTC](https://community.plotly.com/t/python-using-at-least-25-cpu-power-when-dash-is-running-without-any-page-reloads/15366/5 "2025-11-28T10:55:24Z")

</div>

This is **really** bad on my machine (Linux). Both the app process and the “supervisor” process use close to 50% CPU when running using `debug=True`, saturating a full core - compared to a few percent without.

It can tuned by setting the `dev_tools_hot_reload_watch_interval` parameter (in seconds).

---

<div class="post-metadata">

**Author:** ![olejorgenb](https://avatars.discourse-cdn.com/v4/letter/o/ccd318/32.png) [@olejorgenb](https://community.plotly.com/u/olejorgenb)\
**Post date:** [November 28, 2025, 11:03am UTC](https://community.plotly.com/t/python-using-at-least-25-cpu-power-when-dash-is-running-without-any-page-reloads/15366/6 "2025-11-28T11:03:17Z")

</div>

> <https://github.com/plotly/dash/issues/2639>
>
> \*\*Describe your context\*\*
> 
> 
> \`\`\`
> dash 2.13.0
> 
> \`\`\`
> 
> … - OS: Arch Linux/Debian
> 
> \*\*Describe the bug\*\*
> 
> High CPU usage is observed when running the Dash server.
> 
> I traced the source of the issue to line 1720 in dash.py.
> 
> Dash is installed within a Python virtual environment located in a folder named "venv" at the root of the project package. The variable component\_packages\_dist (referenced at line 1720) also includes this root path. Subsequently, the entire content of the venv folder is watched by the \_watch.watch(\[self.config.assets\_folder\] + component\_packages\_dist, ...) function. Given the large number of files in the venv directory, this results in significant CPU usage.
> 
> 
> I suspect this is a bug because this behavior is only observed when inheriting from AIO components.
> 
> \*\*Hotfix\*\*
> 
> Relocate the source code to a "src" directory and retain the "venv" folder at the root level.
> 
> Minimal example to replicate the bug:
> 
> file: \\\_\\\_main\\\_\\\_.py:
> \`\`\`
> from dash import Dash
> from aio import MyAIO
> 
> Dash().run(
> debug=True,
> # regular cpu usage when dev\_tools\_hot\_reload=False 
> dev\_tools\_hot\_reload=True,
> )
> \`\`\`
> 
> file: aio.py
> \`\`\`
> from dash import html
> 
> class MyAIO(
> # regular cpu usage when "html.Div" is commented !
> html.Div
> ):
> pass
> \`\`\`
> 
> 
> \*\*Expected behavior\*\*
> 
> The server should not watch installed dependencies in the same manner when AIO components are not in use.

---

<div class="post-metadata">

**Author:** ![adamschroeder](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/adamschroeder/32/17280_2.png) [@adamschroeder](https://community.plotly.com/u/adamschroeder)\
**Post date:** [November 28, 2025, 3:54pm UTC](https://community.plotly.com/t/python-using-at-least-25-cpu-power-when-dash-is-running-without-any-page-reloads/15366/7 "2025-11-28T15:54:19Z")

</div>

Thanks for reporting this, @olejorgenb .  
This really depends on the user machine, but if you think you can improve the reload mechanism we would love to review a Pull Request for this.

---

<div class="post-metadata">

**Author:** ![olejorgenb](https://avatars.discourse-cdn.com/v4/letter/o/ccd318/32.png) [@olejorgenb](https://community.plotly.com/u/olejorgenb)\
**Post date:** [November 28, 2025, 6:37pm UTC](https://community.plotly.com/t/python-using-at-least-25-cpu-power-when-dash-is-running-without-any-page-reloads/15366/8 "2025-11-28T18:37:03Z")

</div>

For sure, but I do have a reasonably beefy machine (Ryzen 9 7900X). We do have a bunch of apps in a monorepo, so maybe the watcher end up watching unnecessary many files.

Anyways - as I noted in the linked issue (closed due to _staleness_) a very easy win would be to avoid running the hot reload stuff in the flask/werkzeug “supervisor” process.
