How to Configure JupyterHub Idle Culler on JupyterHub
In this article, we will show you how to install the JupyterHub idle culler on the JupyterHub virtual environment and configure JupyterHub to use it.
NOTE: If you don’t have JupyterHub installed on your computer, you can read one of the articles depending on the Linux distribution you’re using:
1. How to Install the Latest Version of JupyterHub on Ubuntu 22.04 LTS/ Debian 12/Linux Mint 21
2. How to Install the Latest Version of JupyterHub on Fedora 38+/RHEL 9/Rocky Linux 9
Topic of Contents:
- Installing JupyterHub Idle Culler
- Configuring JupyterHub Idle Culler
- Restarting the JupyterHub Service
- Testing If JupyterHub IDLE Culler Is Working Correctly
If you followed our JupyterHub Installation Guide to install JupyterHub on your favorite Linux distributions (Debian-based and RPM-based), you can install the JupyterHub idle culler in the JupyterHub virtual environment with the following command:
The JupyterHub idle culler should now be installed in the JupyterHub virtual environment.
To configure the JupyterHub idle culler, open the JupyterHub configuration file with the nano text editor as follows:
Add the following lines of codes in the “jupyterhub_config.py” file:
Here, SESSION_TIMEOUT is the number of seconds after a JupyterHub user session becomes idle and the IDLE culler stops/closes the session. We set it to 3600 seconds or 1 hour. You can change it depending on your requirements.
Once you’re done, press <Ctrl> + X followed by “Y” and <Enter> to save the “jupyterhub_config.py” file.
For the JupyterHub configuration changes to take effect, restart the JupyterHub “systemd” service with the following command:
If the JupyterHub configuration file is error-free, the JupyterHub “systemd” service should be running and the JupyterHub IDLE Culler service should also be running as you can see in the following screenshot:
To verify whether the JupyterHub idle culler is stopping the idle use sessions, log in to JupyterHub as any user and don’t refresh the page for an hour (as we configured JupyterHub to stop the user sessions that are idle for 3600 seconds/60 minutes/1 hour). As you can see, the user session is running.
After an hour, refresh the page and you should see that the user session is stopped automatically. It means that the JupyterHub idle culler is working as expected.
In this article, we showed you how to install the JupyterHub idle culler service on the JupyterHub virtual environment. We also showed you how to configure the JupyterHub idle culler so that the JupyterHub idle user sessions are stopped automatically to free the system resources for other JupyterHub active users.