==========================
Project session management
==========================

Effective project session management is essential for optimizing resource utilization and ensuring fair access to compute resources in Workbench. As an administrator, you can set thresholds on the number of active sessions a user is allowed to have open simultaneously, preventing any single user from monopolizing resources. Additionally, you can define thresholds for how long sessions are allowed to remain idle—in days and hours—before being automatically terminated by the system. You can also terminate active sessions manually, if necessary. 

Viewing project session settings
================================

To view a list of currently open sessions:

#. Open the |circle-user| **My Account** dropdown menu and select *Admin Console*. 
#. Select |gear-code| **Sessions** from the left-hand navigation. 
#. Select the **Settings** tab. 

.. note:: 

    Project session settings cannot be configured from the application UI.

Configuring project session thresholds
======================================

Workbench includes either a ``values.k3s.yaml`` or a ``values.byok.*.yaml`` (depending on your implementation) file that overrides the default values in the top-level Helm chart. If you are performing your initial configurations, use the example below to add the ``idleSessionControl:`` and ``activeSessionLimit:`` sections to the bottom of your file, then continue your environment preparation and installation. 

Otherwise, follow the steps for :doc:`Setting platform configurations using the Helm chart <advanced/settings>` to add or update the ``idleSessionControl:`` and ``activeSessionLimit:`` configurations to the bottom of the ``helm_values.yaml`` file, as needed for your system setup:

    .. dropdown:: Session threshold example
      :color: primary
      :animate: fade-in

        .. code-block:: none

            # Idle session termination control
            idleSessionControl:
              # -- The granularity of the idle time (measured in integer hours).
              # @section -- Idle Session Control
              # -- Idle session expiration threshold (measured in days).
              # @section -- Idle Session Control
              cleanupThreshold: '5 days'

            # -- The maximum number of sessions a user may run concurrently.
            # @section -- Active Session Control
            activeSessionLimit: 15

        .. note::
            
            By default, the system is globally configured to limit users to *20 active sessions*, which are allowed to idle for up to *seven days* before being terminated. 

Session management can also be customized per :ref:`workload resource profile <resoucre_profile_examples>`, meaning that you can apply different thresholds to each resource profile if necessary. For example, because GPU resources generally cost more than CPU resources, applying a shorter idle time threshold to the GPU-associated resource profiles can lead to significant cost savings while also ensuring that these resources are available for the users who require them. For more information, see the ``GPU with limited idle time threshold example`` provided in the resource profile examples.

Viewing active sessions
=======================

To view a list of currently open sessions:

#. Open the |circle-user| **My Account** dropdown menu and select *Admin Console*. 
#. Select |gear-code| **Sessions** from the left-hand navigation. 

Filtering active sessions
=========================

Search for projects by name, or use the filter categories efficiently locate project sessions.

.. note::

    * Click on the table headers to sort the displayed sessions.
    * Reselect any filter or click |circle-x| **Clear Filters** to remove them and reset the table. 

.. thumbnail:: ../images/filtering_sessions.png

.. _stop_sessions: 

Stopping sessions
=================

Stopping a project session terminates the pod running that session, releasing its compute resources back to the cluster. Select the sessions you would like to terminate, then click |circle-stop| **Stop Selected Sessions**.  

.. thumbnail:: ../images/stopping_sessions.gif
    :align: center

.. warning:: 

    If you stop an active project session, anyone using that project will receive a ``Directory not found`` error and lose all in-progress work.

.. |circle-user| raw:: html
   
   <svg height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 496c-54 0-103.9-17.9-144-48v0c0-61.9 50.1-112 112-112h64c61.9 0 112 50.1 112 112v0c5.3-4 10.4-8.2 15.4-12.6C409.1 370.6 354.5 320 288 320H224c-66.5 0-121.1 50.6-127.4 115.4C47.2 391.5 16 327.4 16 256C16 123.5 123.5 16 256 16s240 107.5 240 240s-107.5 240-240 240zm0 16A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm80-304a80 80 0 1 0 -160 0 80 80 0 1 0 160 0zm-80-64a64 64 0 1 1 0 128 64 64 0 1 1 0-128z"/></svg>

.. |gear-code| raw:: html

    <svg height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M225.7 34c-1.1 1-1.9 2.3-2.4 3.8L209.6 85.5c-3.5 12.1-12.2 21.1-22.5 26.1c-7.6 3.6-14.8 7.8-21.7 12.5c-9.4 6.5-21.7 9.5-33.9 6.5l-48.2-12c-1.5-.4-3-.3-4.4 .2c-5.4 6.9-10.4 14.2-15 21.8l-4.2 7.3c-4.2 7.5-7.9 15.3-11.2 23.4c.3 1.5 1 2.9 2.1 4L85.2 211c8.7 9 12.2 21.1 11.3 32.5c-.3 4.1-.5 8.3-.5 12.5s.2 8.4 .5 12.5c.9 11.4-2.6 23.5-11.3 32.5L50.7 336.8c-1.1 1.1-1.8 2.5-2.1 4c3.3 8 7 15.8 11.2 23.4l4.2 7.3c4.6 7.6 9.6 14.8 15 21.8c1.4 .5 2.9 .5 4.4 .2l48.2-12c12.2-3 24.4 0 33.9 6.5c6.9 4.7 14.1 8.9 21.7 12.5c10.3 4.9 19.1 14 22.5 26.1l13.7 47.7c.4 1.5 1.3 2.8 2.4 3.8c9.9 1.3 20 2 30.3 2s20.4-.7 30.3-2c1.1-1 1.9-2.3 2.4-3.8l13.7-47.7c3.5-12.1 12.2-21.1 22.5-26.1c7.6-3.6 14.8-7.8 21.7-12.5c9.4-6.5 21.7-9.5 33.9-6.5l48.2 12c1.5 .4 3 .3 4.4-.2c5.4-6.9 10.4-14.2 14.9-21.8l4.2-7.3c4.2-7.5 7.9-15.3 11.2-23.4c-.3-1.5-1-2.9-2.1-4L426.8 301c-8.7-9-12.2-21.1-11.3-32.5c.3-4.1 .5-8.3 .5-12.5s-.2-8.4-.5-12.5c-.9-11.4 2.6-23.5 11.3-32.5l34.5-35.7c1.1-1.1 1.8-2.5 2.1-4c-3.3-8-7-15.8-11.2-23.3l-4.3-7.4c-4.6-7.6-9.5-14.8-14.9-21.8c-1.4-.5-2.9-.5-4.4-.2l-48.2 12c-12.2 3-24.4 0-33.9-6.5c-6.9-4.7-14.1-8.9-21.7-12.5c-10.3-4.9-19.1-14-22.5-26.1L288.7 37.8c-.4-1.5-1.3-2.8-2.4-3.8c-9.9-1.3-20-2-30.3-2s-20.4 .7-30.3 2zM217.6 2.9C230.1 1 243 0 256 0s25.9 1 38.4 2.9c1.7 .3 3.4 .8 5 1.6c9.5 4.9 16.9 13.6 20 24.5l13.7 47.7c.6 2.2 2.5 4.5 5.6 6c9.1 4.3 17.8 9.4 26 15c2.8 1.9 5.8 2.4 8 1.8l48.2-12c10.9-2.7 22.1-.7 31.1 5.1c1.5 .9 2.8 2.1 3.9 3.5c7.1 8.9 13.6 18.2 19.5 28l.1 .3L480 132l.1 .3c5.4 9.7 10.2 19.9 14.3 30.4c.6 1.6 1 3.3 1.1 5c.5 10.8-3.3 21.6-11.2 29.8l-34.5 35.7c-1.6 1.7-2.7 4.4-2.4 7.8c.4 5 .6 10 .6 15s-.2 10.1-.6 15c-.3 3.4 .8 6.2 2.4 7.8l34.5 35.7c7.9 8.2 11.7 19 11.2 29.8c-.1 1.7-.5 3.4-1.1 5c-4.1 10.5-8.9 20.6-14.3 30.4l-.1 .3-4.4 7.6-.1 .3c-5.9 9.8-12.4 19.2-19.5 28c-1.1 1.4-2.4 2.6-3.9 3.5c-9 5.7-20.2 7.8-31.1 5.1l-48.2-12c-2.2-.6-5.2-.1-8 1.8c-8.2 5.7-16.9 10.7-26 15c-3.1 1.5-4.9 3.8-5.6 6L319.4 483c-3.1 10.8-10.5 19.5-20 24.5c-1.6 .8-3.2 1.4-5 1.6C281.9 511 269 512 256 512s-25.9-1-38.4-2.9c-1.7-.3-3.4-.8-5-1.6c-9.5-4.9-16.9-13.6-20-24.5l-13.7-47.7c-.6-2.2-2.5-4.5-5.6-6c-9.1-4.3-17.8-9.4-26-15c-2.8-1.9-5.8-2.4-8-1.8l-48.2 12c-10.9 2.7-22.1 .7-31.1-5.1c-1.5-.9-2.8-2.1-3.9-3.5C49 407 42.4 397.6 36.5 387.8l-.1-.3L32 380l-.1-.3c-5.4-9.8-10.2-19.9-14.3-30.4c-.6-1.6-1-3.3-1.1-5c-.5-10.8 3.3-21.6 11.2-29.8l34.5-35.7c1.6-1.7 2.7-4.4 2.4-7.8c-.4-5-.6-10-.6-15s.2-10.1 .6-15c.3-3.4-.8-6.2-2.4-7.8L27.7 197.4c-7.9-8.2-11.7-19-11.2-29.8c.1-1.7 .5-3.4 1.1-5c4.1-10.5 8.9-20.6 14.3-30.4l.1-.3 4.4-7.6 .1-.3C42.4 114.3 49 105 56.1 96.1c1.1-1.4 2.4-2.6 3.9-3.5c9-5.7 20.2-7.8 31.1-5.1l48.2 12c2.2 .6 5.2 .1 8-1.8c8.2-5.7 16.9-10.7 26-15c3.1-1.5 4.9-3.8 5.6-6L192.6 29c3.1-10.8 10.5-19.5 20-24.5c1.6-.8 3.2-1.4 5-1.6zm70.2 159.8l-32 192c-1.5 8.7-9.7 14.6-18.4 13.2s-14.6-9.7-13.2-18.4l32-192c1.5-8.7 9.7-14.6 18.4-13.2s14.6 9.7 13.2 18.4zM187.3 227.3L158.6 256l28.7 28.7c6.2 6.2 6.2 16.4 0 22.6s-16.4 6.2-22.6 0l-40-40c-6.2-6.2-6.2-16.4 0-22.6l40-40c6.2-6.2 16.4-6.2 22.6 0s6.2 16.4 0 22.6zm160-22.6l40 40c6.2 6.2 6.2 16.4 0 22.6l-40 40c-6.2 6.2-16.4 6.2-22.6 0s-6.2-16.4 0-22.6L353.4 256l-28.7-28.7c-6.2-6.2-6.2-16.4 0-22.6s16.4-6.2 22.6 0z"/></svg>

.. |command| raw:: html

    <svg height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M0 88C0 39.4 39.4 0 88 0s88 39.4 88 88v56H336V88c0-48.6 39.4-88 88-88s88 39.4 88 88s-39.4 88-88 88H368V336h56c48.6 0 88 39.4 88 88s-39.4 88-88 88s-88-39.4-88-88V368H176v56c0 48.6-39.4 88-88 88s-88-39.4-88-88s39.4-88 88-88h56V176H88C39.4 176 0 136.6 0 88zm144 56V88c0-30.9-25.1-56-56-56S32 57.1 32 88s25.1 56 56 56h56zm32 192H336V176H176V336zm-32 32H88c-30.9 0-56 25.1-56 56s25.1 56 56 56s56-25.1 56-56V368zm224 0v56c0 30.9 25.1 56 56 56s56-25.1 56-56s-25.1-56-56-56H368zm0-224h56c30.9 0 56-25.1 56-56s-25.1-56-56-56s-56 25.1-56 56v56z"/></svg>

.. |circle-x| raw:: html

    <svg height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM186.3 136.5c-8.6-10.1-23.7-11.4-33.8-2.8s-11.4 23.7-2.8 33.8L224.6 256l-74.9 88.5c-8.6 10.1-7.3 25.3 2.8 33.8s25.3 7.3 33.8-2.8L256 293.2l69.7 82.3c8.6 10.1 23.7 11.4 33.8 2.8s11.4-23.7 2.8-33.8L287.4 256l74.9-88.5c8.6-10.1 7.3-25.3-2.8-33.8s-25.3-7.3-33.8 2.8L256 218.8l-69.7-82.3z"/></svg>


.. |circle-stop| raw:: html

    <svg height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm192-96H320c17.7 0 32 14.3 32 32V320c0 17.7-14.3 32-32 32H192c-17.7 0-32-14.3-32-32V192c0-17.7 14.3-32 32-32z"/></svg>