Snowflake, a cloud-based data warehousing platform, facilitates handling and analyzing large datasets with ease. One of its features is the concept of Snowflake Sessions, which are crucial for managing user interactions and ensuring the seamless operation of various tasks.
This blog post delves into the intricacies of Snowflake sessions, elaborating on how to initiate and maintain them, and under what circumstances they are suspended.
Sessions in Snowflake commence once a user successfully authenticates using any client like Snowsight, the Classic Console, or programmatic interfaces.
These sessions, which are distinct from your identity provider (IdP) sessions, are maintained indefinitely with user activity but do have a default idle session timeout of four hours.
It's important to note that passive actions like scrolling through query results don't reset the session's idle timer.
The CLIENT_SESSION_KEEP_ALIVE option helps maintain the session indefinitely, though its excessive use can lead to resource strain. Snowflake suggests keeping sessions alive as long as they're needed and responsibly closing them afterward to optimize resource utilization.
Snowflake creates a new session for each worksheet in Snowsight. A worksheet session enforces the session policy that applies to the user that creates the worksheet.
There are two types of sessions that are initiated when creating a new worksheet:
As long as you interact with one of the sheets, user session is constantly refreshed.
Available from the Enterprise Edition onwards, session policies let you define and manage idle timeout periods, enhancing control over user session behavior and helping meet compliance requirements.
Key properties of these policies include:
If a session policy isn’t explicitly set, Snowflake defaults to a 240-minute timeout. However, the minimum configurable timeout is 5 minutes.
You can use the SESSION_POLICIES view and POLICY_REFERENCES function to monitor and apply policies.