App Memory and CPU

This documentation is for Dash Enterprise.
Dash Enterprise is the fastest way to write & deploy Dash apps and
Jupyter notebooks.
10% of the Fortune 500 uses Dash Enterprise to productionize AI and
data science apps. Find out if your company is using Dash Enterprise.

User-created Dash apps and any attached workspaces or services consume memory (RAM) and CPU on the cluster nodes.

The Dash Enterprise Helm chart defines default memory and CPU requests and limits that are appropriate for most organizations. Under most circumstances, these defaults ensure that user-created resources and the cluster as a whole remain healthy.

Default requests and limits

Memory request Memory limit CPU request CPU limit
Dash apps 128 MiB 8192 MiB 100 millicores None
Workspaces 128 MiB 8192 MiB 200 millicores None
Services 128 MiB 128 MiB 100 millicores None

 

It is possible to override these defaults if they are not optimal for your infrastructure or business needs. This guide can help you rightsize memory and CPU for user-created resources.

Memory

When an app reaches its memory limit, Database Connections. When a workspace reaches its memory limit (usually because the development app is running), the development app is stopped and killed is printed in the workspace terminal.

Strategies for reducing Dash app memory usage

Here are a few strategies that Dash app developers can consider to reduce their apps’ memory usage.
* Using the --preload flag in their app’s Procfile. For example:
web: gunicorn app:server --workers 4 --preload

Do not use the --preload flag if shared database connection pools are used (see replicas). For more information on preloading, refer to the Gunicorn docs.
* Reducing the amount of workers defined in their app’s Procfile.
* Using a file type for their datasets that supports memory mapping, like Arrow, and reading it with libraries like Vaex.
* Performing data queries and aggregations within the query on a database layer instead of in memory with Python.

To manage memory, you can:

Setting a Custom Memory Limit for an App Process, Workspace, or Service

If your organization has deployed apps with a variety of memory usage levels and the default memory limit (8192 MiB unless overridden) is not appropriate for all of them, consider setting custom memory limits. You can safely set custom memory limits directly from the Dash Enterprise App Manager.

If an app process has multiple role, the custom memory limit applies to each replica. It is not shared between replicas.

When you save a custom memory limit, the resource is restarted. In the case of a service, both the service and the workspace (if one is attached) are restarted.

Prerequisites:

To set a custom memory limit on an app process, workspace, or service:

  1. In the App Manager, go to the App Info for the app whose process, workspace, or service you want to set a custom memory limit for.
  2. Go to the Scale tab.
  3. Find the process, workspace, or service whose memory limit you want to edit, and then select Edit Resources.
  4. In Memory Limit, enter the new custom memory limit in MiB. The memory limit cannot be lower than the memory request (128 MiB unless overridden).
  5. Select Save and Restart. The resource is restarted.

Overriding the Default Memory Requests or Limits

You can override the default memory requests or limits by making a configuration change to Dash Enterprise and applying it with helm upgrade.

Caution: Helm does not perform any validation when you override the default memory requests or limits. Memory limits (including any custom memory limits) must always be equal or greater than memory requests. Applying default requests that are equal to limits may impact the capacity of the cluster. We strongly recommend being familiar with Resource Management for Pods and Containers before following the steps below.

Important: Changing the default memory request affects the minimum custom memory limit that can be applied via the App Manager.

Prerequisites:

To override the default memory requests or limits:

  1. If you haven’t already, create a file that you’ll use for overriding the default Dash Enterprise configuration values. You can call it something like values-custom.yml.
  2. Add the following lines to your override file, editing values as needed:
    * For apps:
    yaml agents: worker: app: # -- Default memory request for dash app containers (MiB) defaultMemoryRequestMiB: 128 # -- Default memory limit for dash app containers (MiB) defaultMemoryLimitMiB: 8192
  1. Apply the configuration change:

sh helm upgrade $RELEASE_NAME -f values-custom.yaml \ --namespace $NAMESPACE \ --reset-then-reuse-values
changing the name of your custom values file if it’s different.

The --reset-then-reuse-values flag applies all the other configurations that were set during the original installation.

Updated default memory limits are applied to new and existing resources that do not have a custom memory limit.

CPU

Overriding the Default CPU Requests or Limits

You can override the default CPU requests or limits by making a configuration change to Dash Enterprise and applying it with helm upgrade.

Caution: Helm does not perform any validation when you override the default CPU requests or limits. CPU limits, when they exist, must always be equal or greater than CPU requests. We strongly recommend being familiar with Resource Management for Pods and Containers before following the steps below.

Prerequisites: