You can horizontally scale your app by increasing the number of replicas it uses.
You can think of a replica as a copy of your Dash app. When you add a replica, Dash Enterprise creates an additional pod for the process and, when possible, schedules it on a different node than the original. Increasing the number of replicas for your app provides:
web
process, callbacks are run in parallel, meaning your app runs faster. For example, scaling an app with the following four callbacks, the callbacks would complete four times faster with four replicas than with one replica:@callback(Output(‘graph-1’, ‘figure’), Input(‘btn’, ‘n_clicks’))
def update(_):
time.sleep(2) # This simulates a long-running callback
now = datetime.datetime.now()
return px.bar(x=[now - datetime.timedelta(minutes=1), now], y=[random.random(), random.random()])
@callback(Output(‘graph-2’, ‘figure’), Input(‘btn’, ‘n_clicks’))
def update(_):
time.sleep(2) # This simulates a long-running callback
now = datetime.datetime.now()
return px.bar(x=[now - datetime.timedelta(minutes=1), now], y=[random.random(), random.random()])
@callback(Output(‘graph-3’, ‘figure’), Input(‘btn’, ‘n_clicks’))
def update(_):
time.sleep(2) # This simulates a long-running callback
now = datetime.datetime.now()
return px.bar(x=[now - datetime.timedelta(minutes=1), now], y=[random.random(), random.random()])
@callback(Output(‘graph-4’, ‘figure’), Input(‘btn’, ‘n_clicks’))
def update(_):
time.sleep(2) # This simulates a long-running callback
now = datetime.datetime.now()
return px.bar(x=[now - datetime.timedelta(minutes=1), now], y=[random.random(), random.random()])
```
Each replica added increases memory usage and the number of pods created on the Kubernetes cluster that Dash Enterprise is installed on.
By default, each app process type defined in your Procfile runs as one replica.
For example, with the following Procfile, the deployed app (the web
process) uses one replica:
web: gunicorn index:server --workers 4
To increase or decrease the number of replicas of an app process:
https://<your-dash-enterprise-server>/apps/<your-app-name>
.When you increase the number of replicas for your app, you horizontally scale your app. Horizontal scaling increases your app’s availability. You can also vertically scale your app by increasing the number of app processes within a single copy of your Dash app. To do this, increase the number of workers in your Procfile. See the
Procfile section of the App Structure page for more details. Increasing the number of replicas is more resource intensive than increasing the number of processes on a single copy of your Dash app. It uses more memory and increases the number of pods created on the Kubernetes cluster that Dash Enterprise is installed on.