Performance tuning your Apps

Domino Applications

The following guidelines apply to all Domino Apps, regardless of framework:

  • Apps run until you explicitly stop them. If your app isn’t used anymore, stop it to minimize your compute spend.

  • Unlike a job or a workspace, Domino Apps never commit (or sync) file changes from the local disk to the Domino project’s file store. To persist data, your app’s logic must write it to an external data source.

  • The performance of your app depends on the design of the application.

Launching an app in Domino works the same as any other Domino run. Domino assigns hosting of your app to an executor machine in the hardware tier your App is configured to use. That executor then retrieves the default Domino environment configured for your project, and creates a container based on that image. Domino then loads your project files onto the machine and executes the app file that you have selected, at which point your application will be running in its container.

Depending on which hardware tier you select, the container running your application may share a host machine with other containers or run on a dedicated host.

Size and scale an App

Two deployment settings control how much traffic an App serves: the hardware tier and autoscaling. Changing either one restarts the App without creating a new version.

  • The hardware tier sets the CPU, memory, and GPU for each pod that runs the App.

  • Autoscaling scales the number of pods with load. Domino adds pods within seconds when demand spikes and removes them when it falls, so you don’t size the App for peak traffic or weigh cost against performance.

Turn on autoscaling and pick a lightweight hardware tier. Extra pods run only while demand needs them, and scaling happens without a restart or republish. Without autoscaling, size the pod for the viewers you expect and make the App use every core on its pod, as described below for each framework.

Run heavy or long-running computation as its own execution: start a Job or call an endpoint from the App and show the result when it’s ready. The App stays responsive, the work runs on its own hardware tier, and each run has its own logs and record.

The following sections describe configuring web applications to make full use of their hardware tier for several popular frameworks.

Flask and Dash (Python)

Flask’s built-in server, which Dash also uses, is for development. For production traffic, serve the App through a production server with worker processes sized for the pod. The Flask documentation describes several production servers.

For example, you can serve a Flask application through gunicorn. To do this in Domino, change the project’s app file. See Gunicorn commands for details. You can change:

export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export FLASK_APP=app-flask.py
export FLASK_DEBUG=1
python -m flask run --host=0.0.0.0 --port=8888

to

gunicorn -w 4 -b 0.0.0.0:8888 app-flask:app

This will start serving the Flask application on four processes. Apps published in Domino must serve traffic on port 8888.

To estimate capacity, start from what one pod serves. If a command in your application uses 100MB RAM and 20% of a standard VM CPU, then a pod with 1 core and 1 GB RAM serves 5 concurrent users running that command at once. With autoscaling on, capacity is pods times users per pod, so 40 such pods serve 200 concurrent users on small, low-cost hardware tiers. Without autoscaling, pick a hardware tier with enough cores for the users you expect; in this example CPU is the limit, not memory. Keep session affinity disabled for Flask and Dash Apps so that scale-up and scale-down stay responsive.

Shiny (R)

Like Python Apps, your Shiny Apps' performance will depend on design of the underlying application. Each viewer gets an isolated session, and Shiny serves one request per R process, so Domino scales a Shiny App by adding pods rather than cores. Autoscale a Shiny App to serve any number of viewers:

  • Turn on autoscaling when you publish or launch the App.

  • Turn on Enable session affinity so every request from a viewer’s session reaches the same pod.

  • Pick a small, low-CPU hardware tier and a high Maximum Pods.

These settings support arbitrarily high user counts. Within a session, keep the App responsive by doing as little work per request as possible. See Make Shiny fast by doing as little work as possible.