2023-03-27 09:31:02 +02:00
|
|
|
(topic-idle-culler)=
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
# Culling idle notebook servers
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2019-06-14 14:18:39 +03:00
|
|
|
The idle culler automatically shuts down user notebook servers when they have
|
|
|
|
|
not been used for a certain time period, in order to reduce the total resource
|
|
|
|
|
usage on your JupyterHub.
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2022-05-05 14:42:57 +02:00
|
|
|
The notebook server monitors activity internally
|
|
|
|
|
and notifies JupyterHub of recent activity at certain time intervals (the activity interval).
|
|
|
|
|
If JupyterHub has not been notified of any activity after a certain period (the idle timeout),
|
2023-03-27 09:31:02 +02:00
|
|
|
the server is considered to be _inactive (idle)_ and will be culled (shutdown).
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
The [idle culler](https://github.com/jupyterhub/jupyterhub-idle-culler) is a JupyterHub service that is installed and enabled by default in TLJH.
|
2020-08-25 16:47:34 +02:00
|
|
|
It can be configured using tljh-config. For advanced use-cases, like purging old user data,
|
2022-05-05 14:42:57 +02:00
|
|
|
the idle culler configuration can be extended beyond tljh-config options, using custom
|
2023-03-27 09:31:02 +02:00
|
|
|
[jupyterhub_config.py snippets](https://tljh.jupyter.org/en/latest/topic/escape-hatch.html?highlight=escape-hatch#extending-jupyterhub-config-py).
|
2020-08-25 16:47:34 +02:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
## Default settings
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2025-05-15 11:30:19 +02:00
|
|
|
By default, JupyterHub will ping the user notebook servers every 10 min to check their
|
|
|
|
|
status. Every server found to be idle for more than 1 hour will be culled.
|
2019-06-14 14:18:39 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
```python
|
2025-05-15 11:30:19 +02:00
|
|
|
services.cull.every = 600
|
|
|
|
|
services.cull.timeout = 3600
|
2023-03-27 09:31:02 +02:00
|
|
|
```
|
2019-06-14 14:18:39 +03:00
|
|
|
|
|
|
|
|
Because the servers don't have a maximum age set, an active server will not be shut down
|
|
|
|
|
regardless of how long it has been up and running.
|
|
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
```python
|
|
|
|
|
services.cull.max_age = 0
|
|
|
|
|
```
|
2019-06-14 14:18:39 +03:00
|
|
|
|
|
|
|
|
If after the culling process, there are users with no active notebook servers, by default,
|
|
|
|
|
the users will not be culled alongside their notebooks and will continue to exist.
|
|
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
```python
|
|
|
|
|
services.cull.users = False
|
|
|
|
|
```
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-02-13 11:59:30 +00:00
|
|
|
If named servers are in use, they are not removed after being culled.
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
services.cull.remove_named_servers = False
|
|
|
|
|
```
|
|
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
## Configuring the idle culler
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2019-06-14 14:18:39 +03:00
|
|
|
The available configuration options are:
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
### Idle timeout
|
|
|
|
|
|
2019-06-14 14:18:39 +03:00
|
|
|
The idle timeout is the maximum time (in seconds) a server can be inactive before it
|
|
|
|
|
will be culled. The timeout can be configured using:
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
```bash
|
|
|
|
|
sudo tljh-config set services.cull.timeout <max-idle-sec-before-server-is-culled>
|
|
|
|
|
sudo tljh-config reload
|
|
|
|
|
```
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
### Idle check interval
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2019-06-14 14:18:39 +03:00
|
|
|
The idle check interval represents how frequent (in seconds) the Hub will
|
|
|
|
|
check if there are any idle servers to cull. It can be configured using:
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
```bash
|
|
|
|
|
sudo tljh-config set services.cull.every <number-of-sec-this-check-is-done>
|
|
|
|
|
sudo tljh-config reload
|
|
|
|
|
```
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
### Maximum age
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2019-06-14 14:18:39 +03:00
|
|
|
The maximum age sets the time (in seconds) a server should be running.
|
|
|
|
|
The servers that exceed the maximum age, will be culled even if they are active.
|
|
|
|
|
A maximum age of 0, will deactivate this option.
|
|
|
|
|
The maximum age can be configured using:
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
```bash
|
|
|
|
|
sudo tljh-config set services.cull.max_age <server-max-age>
|
|
|
|
|
sudo tljh-config reload
|
|
|
|
|
```
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-02-13 11:59:30 +00:00
|
|
|
### Remove Named Servers
|
|
|
|
|
|
|
|
|
|
Remove named servers after they are shutdown. Only applies if named servers are
|
|
|
|
|
enabled on the hub installation:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
sudo tljh-config set services.cull.remove_named_servers True
|
|
|
|
|
sudo tljh-config reload
|
|
|
|
|
```
|
|
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
### User culling
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2019-06-14 14:18:39 +03:00
|
|
|
In addition to servers, it is also possible to cull the users. This is usually
|
2023-03-27 09:31:02 +02:00
|
|
|
suited for temporary-user cases such as _tmpnb_.
|
2019-06-14 14:18:39 +03:00
|
|
|
User culling can be activated using the following command:
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
```bash
|
|
|
|
|
sudo tljh-config set services.cull.users True
|
|
|
|
|
sudo tljh-config reload
|
|
|
|
|
```
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
### Concurrency
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2019-06-14 14:18:39 +03:00
|
|
|
Deleting a lot of users at the same time can slow down the Hub.
|
|
|
|
|
The number of concurrent requests made to the Hub can be configured using:
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
```bash
|
|
|
|
|
sudo tljh-config set services.cull.concurrency <number-of-concurrent-hub-requests>
|
|
|
|
|
sudo tljh-config reload
|
|
|
|
|
```
|
2019-06-14 14:18:39 +03:00
|
|
|
|
|
|
|
|
Because TLJH it's used for a small number of users, the cases that may require to
|
|
|
|
|
modify the concurrency limit should be rare.
|
2019-06-13 14:54:51 +03:00
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
## Disabling the idle culler
|
2019-06-14 14:18:39 +03:00
|
|
|
|
|
|
|
|
The idle culling service is enabled by default. To disable it, use the following
|
|
|
|
|
command:
|
|
|
|
|
|
2023-03-27 09:31:02 +02:00
|
|
|
```bash
|
|
|
|
|
sudo tljh-config set services.cull.enabled False
|
|
|
|
|
sudo tljh-config reload
|
|
|
|
|
```
|