Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are notebooks started from /services/ being culled ? #1622

Closed
sigurdurb opened this issue Jan 16, 2018 · 4 comments
Closed

Are notebooks started from /services/ being culled ? #1622

sigurdurb opened this issue Jan 16, 2018 · 4 comments
Labels

Comments

@sigurdurb
Copy link

"""script to monitor and cull idle single-user servers

I have this script running on my server where I also start /services to run nbgrader/Formgrader for teachers and TA's.

Starting the course yesterday and running netstat -lp this morning reveales a lot of python processess running that are not apart of that and probably are notebooks started by users accessing the /services and starting notebooks there.

Is this script managing to cull those notebooks as well as notebooks started on the /user side ?
Are notebooks started from /services/<service_name>/notebooks/<*.ipynb> being culled ?

From the looks of the script only HTTPRequest with methode DELETE seem to be going to the /users/ part.

@sigurdurb sigurdurb changed the title Are notebooks stated from /services/ being culled ? Are notebooks started from /services/ being culled ? Jan 16, 2018
@sigurdurb
Copy link
Author

@minrk It seems that culling notebooks in the /services/ path would require a Delete method. But according to http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyterhub/jupyterhub/master/docs/rest-api.yml#/default
.. there are only delete methods for the /users path but not the /services path. Also looks like it can only cull users that dont have a running server: according to the comment "Hub doesn't allow deleting users with running servers" so is it not possible to stop notebooks running with the /services path since they are always running?

Also a possible flaw, in line 75 the url seems to be deleting a user as per the rest api swagger docs??

@minrk
Copy link
Member

minrk commented Jan 30, 2018

Services don't get culled, since they are by definition meant to be always running. JupyterHub has no idea that some of its services might be notebook servers. As for culling individual kernels in the notebook server, that's a notebook feature, new in recent releases of the notebook. You can set

c. MappingKernelManager.cull_idle_timeout = 600

and kernels that have been idle for ten minutes will be shutdown.
ref

@sigurdurb
Copy link
Author

I see now that I was missing both

  • --MappingKernelManager.cull_idle_timeout = 600
  • '--MappingKernelManager.cull_interval=30'

from the managed services I was creating. (see example below)

Otherwise the notebooks would just keep running for days.

Example with 60 second and 30 second interval (only for test purposes)

{
        'name': 'reir20173',
        'url': 'http://127.0.0.1:9426',
        'command': [
            'jupyterhub-singleuser',
            '--group=reir20173_kenn',
            '--debug',
            '--MappingKernelManager.cull_idle_timeout=60',
            '--MappingKernelManager.cull_interval=30',
        ],
        'user': 'reir20173',
        'cwd': '/home/reir20173'
},

Then starting a random notebook in the /service/reir20173 and leaving it idle for 60 seconds.

[D 2018-04-17 12:25:52.997 SingleUserNotebookApp kernelmanager:410] Polling every 30 seconds for kernels idle > 60 seconds...
[D 2018-04-17 12:25:52.998 SingleUserNotebookApp kernelmanager:421] kernel_id=84d36d23-717f-482d-882f-edf6dae1bec5, kernel_name=xeus-cling-cpp11, last_activity=2018-04-17 12:24:25.783265+00:00
[W 2018-04-17 12:25:52.998 SingleUserNotebookApp kernelmanager:434] Culling 'idle' kernel 'xeus-cling-cpp11' (84d36d23-717f-482d-882f-edf6dae1bec5) with 0 connections due to 87 seconds of inactivity.
[D 2018-04-17 12:25:52.999 SingleUserNotebookApp kernelmanager:242] Clearing buffer for 84d36d23-717f-482d-882f-edf6dae1bec5
[I 2018-04-17 12:25:53.101 SingleUserNotebookApp multikernelmanager:127] Kernel shutdown: 84d36d23-717f-482d-882f-edf6dae1bec5

@willingc
Copy link
Contributor

Closing this issue since it appears to be resolved. Thanks to all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants