App Replicas

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:

@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()])
```

Configuring the Number of Replicas

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:

  1. Go to your App Info at https://<your-dash-enterprise-server>/apps/<your-app-name>.
  2. Select the Scale tab.
  3. Select Edit Resources for the process for which you want to update replica numbers.
  4. Update the number of replicas.
    <img>
  5. Select Save.

Other Scaling Options

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.