# Limit Resources and Idle Culler

**URL:** <https://discourse.jupyter.org/t/limit-resources-and-idle-culler/30023>\
**Category:** JupyterHub\
**Created:** [November 12, 2024, 12:22pm UTC](https://discourse.jupyter.org/t/limit-resources-and-idle-culler/30023 "2024-11-12T12:22:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Carvalho](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/david_carvalho/32/15861_2.png) [@David\_Carvalho](https://discourse.jupyter.org/u/David_Carvalho)\
**Post date:** [November 12, 2024, 12:22pm UTC](https://discourse.jupyter.org/t/limit-resources-and-idle-culler/30023/1 "2024-11-12T12:22:36Z")

</div>

Hello! Newbie here..  
I installed a not so powerfull Oracle Linux 9 VM with the available resources: 12GB RAM and 2 vCPUs. It is used in classes in a satisfactory way. With more than 25 users, things sometimes go bad.  
I already configured c.JupyterHub.shutdown\_on\_logout = True and this helps.  
I also set up Idle Culler, but it is not working, but the process is running:

# in jupyterhub\_config.py

import sys  
c.JupyterHub.services = [  
{  
“name”: “idle-culler”,  
“command”: [  
sys.executable, “-m”,  
“jupyterhub\_idle\_culler”,  
“–timeout=1200”  
],  
}  
]

c.JupyterHub.load\_roles = [  
{  
“name”: “idle-culler”,  
“description”: “Culls idle servers”,  
“scopes”: [“read:users:name”, “read:users:activity”, “servers”],  
“services”: [“idle-culler”],  
}  
]

what am I missing?  
Also, is there a way to limit user CPU and memory? Sometimes a loop made by a a student is enough to kill the server, sometimes it is not.

Versions:  
Selected Jupyter core packages…  
IPython : 8.18.1  
ipykernel : 6.29.5  
ipywidgets : 8.1.5  
jupyter\_client : 8.6.3  
jupyter\_core : 5.7.2  
jupyter\_server : 2.14.2  
jupyterlab : 4.2.5  
nbclient : 0.10.0  
nbconvert : 7.16.4  
nbformat : 5.10.4  
notebook : 7.2.2  
qtconsole : not installed  
traitlets : 5.14.3

system status jupyterhub:  
/opt/jupyterhub/bin/python3 /opt/jupyterhub/bin/jupyterhub -f /opt/jupyterhub/etc/jupyterhub/jupyterhub\_config.py  
node /usr/local/bin/configurable-http-proxy --ip “” --port 8000 --api-ip 127.0.0.1 --api-port 8001 --error-target [http://127.0.0.1:8081/hub/error](http://127.0.0.1:8081/hub/error) --log-level info --ssl-key /opt/jupyterhub/etc/certificado/\>  
/opt/jupyterhub/bin/python3 -m jupyterhub\_idle\_culler --timeout=1200

Thanks and regards.  
Dave

---

<div class="post-metadata">

**Author:** ![consideRatio](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/consideratio/32/1033_2.png) [@consideRatio](https://discourse.jupyter.org/u/consideRatio)\
**Post date:** [November 12, 2024, 12:34pm UTC](https://discourse.jupyter.org/t/limit-resources-and-idle-culler/30023/2 "2024-11-12T12:34:13Z")

</div>

> Also, is there a way to limit user CPU and memory?

Maybe, it depends on what spawner is used. What spawner is jupyterhub configured to use?

(Not sure about why culling fail, bug a full jupyterhub config and logs from jupyterhub itself are relevant to debug it)

---

<div class="post-metadata">

**Author:** ![David\_Carvalho](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/david_carvalho/32/15861_2.png) [@David\_Carvalho](https://discourse.jupyter.org/u/David_Carvalho)\
**Post date:** [November 12, 2024, 3:24pm UTC](https://discourse.jupyter.org/t/limit-resources-and-idle-culler/30023/3 "2024-11-12T15:24:06Z")

</div>

Thanks for the reply.  
I guess the spawner is the way each notebook is started. if yes, then:  
/opt/jupyterhub/bin/python3 -m ipykernel\_launcher -f /home/students/xxxx

By the way…any chance an admin can stop other user services from cmd?  
“jupyter notebook stop port\_number” stops user’s own server.  
Thanks.

---

<div class="post-metadata">

**Author:** ![David\_Carvalho](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/david_carvalho/32/15861_2.png) [@David\_Carvalho](https://discourse.jupyter.org/u/David_Carvalho)\
**Post date:** [November 27, 2024, 4:11pm UTC](https://discourse.jupyter.org/t/limit-resources-and-idle-culler/30023/4 "2024-11-27T16:11:22Z")

</div>

Hello again. Still could not find a way do cull idle servers.  
I also tried the following as in the official documentation:

shutdown the server after no activity for an hour  
c.ServerApp.shutdown\_no\_activity\_timeout = 40 \* 60

shutdown kernels after no activity for 10 minutes  
c.MappingKernelManager.cull\_idle\_timeout = 10 \* 60

Check every minute  
c.MappingKernelManager.cull\_interval = 60

cull connected (e.g. Browser tab open)  
c.MappingKernelManager.cull\_connected = True

This was supposed to allow better control, but I can still see running servers after the timeouts. The logs don’t show anything “stop”/“cull” related. What am I missing? Thanks!

---

<div class="post-metadata">

**Author:** ![David\_Carvalho](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/david_carvalho/32/15861_2.png) [@David\_Carvalho](https://discourse.jupyter.org/u/David_Carvalho)\
**Post date:** [December 13, 2024, 11:30am UTC](https://discourse.jupyter.org/t/limit-resources-and-idle-culler/30023/5 "2024-12-13T11:30:46Z")

</div>

Although there are still some fine tuning to do, I am now able to stop idle notebooks, either with or without open browser tabs.  
It seems to be working better with Edge browser, but I’ll keep investigating. What I have done was:  
c.JupyterHub.spawner\_class = ‘jupyterhub.spawner.LocalProcessSpawner’  
c.Spawner.args = [  
‘–NotebookApp.shutdown\_no\_activity\_timeout=600’,  
‘–MappingKernelManager.cull\_idle\_timeout=600’,  
‘–MappingKernelManager.cull\_interval=60’,  
‘–MappingKernelManager.cull\_connected=True’,  
]  
So basically, send the arguments to each individual spawner. I can then confirm that the process runs with these parameters, unlike when they were defined like in my previous post.
