The first step in deploying your app to Dash Enterprise is to prepare the files required for deployment, and, in some cases, make updates to the app code.
This guide is aimed at users who already have apps running locally. If you haven’t already created an app, we recommend choosing an app from the App Catalog. All apps in the App Catalog are deploy-ready and are a great starting point for your first app.
Using FastAPI or Quart? Dash Enterprise supports these backends. See Server Backends for deployment instructions with
uvicorn.
Consider the following items to ensure that your app will be successfully deployed to Dash Enterprise:
Procfile: Ensure that your project folder has a Procfile. See App Structure for details. This is often:web: gunicorn app:server --workers 4requirements.txt: Ensure that your project folder has a requirements.txt file with the Python dependencies and versions. Don’t forget gunicorn! See App Structure for details.server = app.server: If your app uses Dash 3.0.4 or earlier, declare the underlying server variable to be referenced by the web command in your Procfile. See App Structure for details.predeploy script and an Aptfile file. See App Structure.There are often differences between your local environment and
the containerized environment Dash Enterprise runs your app in.
These differences may include:
The Python version that you use locally may be different from the default version configured by your administrator for Dash Enterprise.
For details on how to override the default version for your app, see the Deployed App Environment page.
Ensure that your local environment is using the same Python package versions as the deployed app by
providing version numbers in your requirements.txt file. See App Structure
for details.
If your app can read directly from data files (rather than a database or an API), then you have three options for reading these files in a deployed app:
postdeploy command, or in a background schedule with Celery while mapping the directories between containers (see “Ephemeral File Systems” below).Dash Enterprise enables you to create and link Redis and Postgres databases to your app.
via the App Manager user interface.
Once linked, these databases are accessible within your code via:
REDIS_URL environment variable for the Redis databaseDATABASE_URL environment variable for the Postgres databaseIf your app depends on private dependencies, see our
Private Packages Doc
for details.
Each command listed in your Procfile is executed in a separate
container and containers have isolated file systems.
When you deploy a Dash app, it is run in a set of new containers.
Data that is written to the file system won’t necessarily be available
during the next deployment, nor will it be available between processes (like between the web process and the worker process).
To work around this limitation, you have three options:
Apps deployed on Dash Enterprise can access the username of the currently logged-in visitor of the Dash app
via the dash-enterprise-auth (dea) package:
```python
from dash_enterprise_libraries import dea
@callback(…)
def update(…):
username = dea.get_username() # only available within callbacks
user_data = dea.get_user_data() # only available within callbacks
```
This data can be used to create row-level-security logic where the username is used within the Python logic
or the database query to display data associated with that particular user.
Apps deployed to Dash Enterprise have a 30-second request timeout by default.
This is to prevent long-running or stuck requests from preventing further requests.
If you have callbacks that take longer than 30 seconds to complete, your app users will encounter request timeouts.
To avoid this, you have a few options:
dcc.Store orgunicorn app:server --timeout 120.Be aware of this method’s performance limitations: more CPU processes and workers will be utilized while
handling long-running requests, and it will be more likely that your app will “run out” of the
available CPU processes and workers while multiple users interact with your app. You will likely need to increase
the number of workers with gunicorn’s --workers argument.
gunicorn is used to run your app on deployments. gunicorn has a default worker startup timeout of 30 seconds.
If your app takes longer than 30 seconds to boot-up (that is, to be ready to handle new requests), then the workers will timeout and restart.
To get around this, increase the boot-up timeout with the --timeout argument in your Procfile:
web: gunicorn app:server --timeout 60
Apps deployed to Dash Enterprise are accessible under a different path. That is, instead of accessing the app on localhost, you access the app at https://<your-dash-enterprise>.com/<your-dash-app-name>.
When dealing with anything to do with URLs and paths, we recommend using built-in functions instead of constructing the /<your-dash-app-name> path manually.
These functions account for the differences between path-less URLs in local environments and path-aware URLs in the Dash API reference.
These functions include:
- dash.get_relative_path() or app.get_relative_path() for creating paths used in links or assets.
- dash.strip_relative_path() or app.strip_relative_path() for stripping the relative path out of the path name (useful for multi-page app callbacks that respond to dcc.Location).
See the Dash Dev Tools Callback Graph for more information.
After deploying your app to Dash Enterprise, you may notice your app feels slower than when running it locally.
Dash apps deployed on Dash Enterprise are on a different network than Dash apps running locally.
This can affect the performance of callbacks and the performance of any data fetching being done within your callback.
Callback Performance
The input, output, and state of a callback are transferred over the network.
When working locally, this data transfer is very fast.
When the app is deployed on a server, it takes longer to
transfer the data from the user’s browser to your callback and from your
callback to the user’s browser.
This is usually not noticeable unless your callbacks have large data structures as inputs (e.g. a dataframe stored in dcc.Store or the contents of a dcc.Upload component) or as outputs (e.g. large figure properties of dcc.Graph or large data properties of DataTable).
Diagnosing Callback Network Performance Issues
To investigate whether the performance issues are related to the network, we recommend:
- Viewing the data transfer (avg bytes) and time - network of callbacks via the Dash with Datashader. You can turn this on for your deployed app with:
python
app.enable_dev_tools(
dev_tools_ui=True,
dev_tools_serve_dev_bundles=True,
)
- Using the Network panel of your browser’s Development Tools to view the network transfer speed of the requests. Each callback will correspond to a POST /_dash-update-component. The contents of the request will indicate the inputs and, therefore which callback the request is associated with.
Improving Callback Network Transfer Performance
There are two ways to improve callback network transfer performance:
Reduce the size of the inputs, outputs and state of a callback. This can be done with strategies like:
dcc.Graph or dash_table.DataTable.dcc.Store or hidden divs with a server-side cache via the State.Reduce the number of times a callback is fired. This can be done with strategies like:
dcc.Input, update the UI when the user clicks a button and pass the value of the dcc.Input via test this by using a Dash Enterprise workspace.dcc.Store or hidden divs with a server-side cache via the Consider the following items to ensure that your app will be successfully deployed on Dash Enterprise:
Procfile - Ensure that your project folder has a Procfile. See App Structure for details. This is often:web: streamlit run app.pyrequirements.txt: Ensure that your project folder has a requirements.txt file with the Python dependencies and versions. See App Structure for details.predeploy script and an Aptfile file. See App Structure.The Python version that you use locally may be different from the Python version used by Dash Enterprise.
For details on how to override the default version for your app, see the Deployed App Environment page.
Ensure that your local environment is using the same Python package versions as the deployed app by
providing version numbers in your requirements.txt file. See App Structure
for details.
Consider the following items to ensure that your app will be successfully deployed on Dash Enterprise:
Procfile - Ensure that your project folder has a Procfile. See App Structure for details. This is often:bash
web: gunicorn <your-django-app>.wsgirequirements.txt: Ensure that your project folder has a requirements.txt file with the Python dependencies and versions. Don’t forget to add gunicorn. See App Structure for details.urls.py: Remove Django Admin urls from your project’s urls.py file. For example. path('admin/', admin.site.urls). The Django Admin site is not currently supported on Dash Enterprisesettings.py: Add your Dash Enterprise hostname to ALLOWED_HOSTS, remove unsupported apps and middleware from INSTALLED_APPS and MIDDLEWARE, and turn off DEBUG for production apps. See App Structure for more details.predeploy script and an Aptfile file. See App Structure.The Python version that you use locally may be different from the Python version used by Dash Enterprise.
For details on how to override the default version for your app, see the Deployed App Environment page.
Ensure that your local environment is using the same Python package versions as the deployed app by
providing version numbers in your requirements.txt file. See App Structure
for details.
Workspaces run on the Dash Enterprise server with a build system that is nearly identical to
how Dash apps are built and deployed. This means that workspaces can help you identify issues caused by the differences in local and deployed app environments.
You can test or troubleshoot your app in a workspace by:
Next, learn about initializing or deploying your app.