About Streamlit in Snowflake

This topic describes how to use Streamlit in Snowflake to develop and run Streamlit applications.

About Streamlit in Snowflake

Streamlit is an open-source Python library that makes it easy to create and share custom web apps for machine learning and data science. By using Streamlit you can quickly build and deploy powerful data applications. For more information about the open-source library, see the Streamlit Library documentation.

Streamlit in Snowflake helps developers securely build, deploy, and share Streamlit apps on Snowflake’s data cloud. Using Streamlit in Snowflake, you can build applications that process and use data in Snowflake without moving data or application code to an external system.

Prerequisites for using Streamlit in Snowflake

To use Streamlit in Snowflake ensure that you have met the following prerequisites:

Privileges required to create and use a Streamlit app

Within Streamlit in Snowflake, a Streamlit app is a securable object that adheres to the Snowflake access control framework. Streamlit apps use a permission model that is based on owner’s rights. See Understanding owner’s rights and Streamlit in Snowflake apps for details.

The following sections describe the privileges required to create and view a Streamlit app in Snowflake.

Privileges required to create a Streamlit app

Streamlit apps are schema-level objects. To create and edit a Streamlit app by using Streamlit in Snowflake, you must use a role that has the following privileges granted on the schema and database that contain the Streamlit app:




Use the GRANT <privileges> command to grant these privileges to a role, as shown in the following examples:

GRANT USAGE ON SCHEMA mydb.myschema TO ROLE myrole;

Privileges required to view a Streamlit app

To view a Streamlit app, you must have a Snowflake account and be signed in. Additionally, your account must be granted the following privileges:

  • The CREATE STREAMLIT global privilege must be granted to the user’s account.

  • The USAGE object-level privilege must be granted on the database and schema containing the application to the user’s account.

An app editor and the owner of the schema containing the Streamlit app can determine which roles have permission to use the app. Users can interact with the app and can see anything displayed by the Streamlit app. Users have the same view of the app as the owner does.

Refer to Share a Streamlit app for more information.

Supported versions of the Streamlit libraries

Streamlit in Snowflake supports v1.22.0 of the Streamlit libraries. Support for later versions of the Streamlit libraries will be included as they are released.

Supported external packages

By default, Streamlit in Snowflake includes the python, streamlit, and snowflake-snowpark-python packages pre-installed in your environment. The environment also has access to the dependencies required by these packages.

You can install additional packages in your Streamlit app. See the Snowflake Anaconda Channel for a list of supported packages.

See the following topics for information about including a supported package in your Streamlilt app:

Concurrency considerations for Streamlit in Snowflake

Streamlit in Snowflake provides session throttling and autoscaling within Snowflake to handle periods of increased demand for a Streamlit app. Streamlit in Snowflake uses a combination of cloud services instances and virtual warehouse instances. See Key Concepts & Architecture for more information.

To maintain the integrity of Snowflake, Streamlit in Snowflake imposes per-instance, per-account, and per-user limits on the number of concurrent Streamlit sessions that a Cloud Services instance can handle. Streamlit sessions are load-balanced between these instances until all instances reach their concurrent session limit. When a limit is reached, the instance is auto-scaled to support additional sessions.


Requests from Streamlit app users might be throttled temporarily. Users might see a “Please Wait” message when autoscaling is initiated.

Billing considerations for Streamlit in Snowflake

Streamlit in Snowflake requires a virtual warehouse to run a Streamlit app and to perform SQL queries. To run a Streamlit app, you must select a single virtual warehouse to run both the app itself and its queries. This warehouse remains active while the app’s web-socket connection is active. The web-socket connection, which keeps the Streamlit app’s virtual warehouse active, expires approximately 15 minutes after the app’s last use.

To conserve credits, you can suspend the virtual warehouse. Alternatively, you can close the webpage running the app, which allows the virtual warehouse that is running to auto-suspend.

Guidelines for selecting a warehouse in Streamlit in Snowflake

When you run a Streamlit app in Streamlit in Snowflake, multiple factors may affect performance, including the complexity of the Streamlit app, availability of warehouses, latency, and cost. The following sections provide general guidelines for using virtual warehouses in Streamlit in Snowflake.

Use smaller warehouses

When you run a Streamlit app in Streamlit in Snowflake you should select the smallest warehouse possible.

When running, a warehouse maintains a cache of the Python packages used by a Streamlit app. Caching Python packages improves the performance for later app loads by using the cached version of a package instead of downloading the packages again. The cache is removed when the warehouse is suspended, which may result in a slower loading of the app initially after the warehouse is resumed. As the resumed warehouse runs and runs more apps, the package cache is rebuilt, and apps that are able to take advantage of the cache will experience improved app loading performance.

Note that per-second credit billing and auto-suspend provide flexibility to start with smaller warehouses, then adjust the size of the warehouse to match the workload of the Streamlit app. You can increase the size of a warehouse at any time. See Change the warehouse of a Streamlit app for more information.

Use dedicated warehouses

When you use Streamlit in Snowflake, Snowflake recommends using a dedicated warehouses for running Streamlit apps. This enables you to isolate the costs of running a Streamlit apps. A dedicated warehouse may also improve the load time of the app since the warehouse does not have to manage other workloads.

See Warehouse Considerations for more information.