-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Potential memory leak on Jupyter Notebooks ZMQChannelHandler code #6244
Comments
adding on to description: we are trying to understand the following:
|
Hi @rahul26goyal - I'm sorry for the delayed response. I believe this particular window really doesn't surface in normal operations (i.e., those not configured with a Gateway). EG introduces additional scenarios in which the notebook server's kernel management "loses track" of its kernels launched from another (potentially remote) server, into potentially other remote servers. That is, it introduces more layers where these kinds of issues can occur. As noted in the referenced issue, I agree that it makes sense, particularly from a transactional perspective, that the kernel's existence be checked prior to session creation. Would you like to provide a pull request to address this? |
thanks @kevin-bates ..I totally agree with you that EG introduces additional hops which might be causing this issue on JEG server. |
Hello @kevin-bates I have raised a PR for this issue. The fix will add a new session only after validation of the kernel. Let us know your views about this. |
Closed via #6251 |
Description
We are using Jupyter Enterprise Gateway (v2.1.0) which uses Jupyter Notebook library as a dependency to handle the various API exposed by JEG. When a kernel is started, the Notebook UI tries to establish a Websocket connection to the kernel via JEG using the API
/api/kernels/<kernel_id>/channels
. The API handler for this on JEG is inherited from the Jupyter Notebook package (ZMQChannelHandler).In case the kernel id passed in the above request URI is an invalid kernel (i.e. it is not being recognised by the JEG) and the
ZMQChannelHandler::pre_get tries to populate the
_open_sessions
hashmap with aself
object before checking if the kernel actually exists_register_session
This seems to create a memory leak if large number of such requests are made to the incorrect kernel and because the Websocket connection was never made the_open_sessions
hashmap never gets cleaned up for the stale entries.Upon debugging we found that, before checking if a kernel is valid or not, a session is being created and if the kernel is invalid that allocated memory is never released.
Steps followed
Current behavior and Memory consumption
Current Code (/notebook/services/kernels/handlers.py):
Memory for JEG server (at start)
After running the script for 60 seconds
Memory for JEG server (after 60 seconds)
Proposed Solution and Memory Consumption
If we check whether a kernel is valid or not before creating a session, the extra memory that is allocated and un-utilised can be avoided.
Proposed Change (/notebook/services/kernels/handlers.py):
Memory for JEG server (at start)
After running the script for 60 seconds
Memory for JEG server (after 60 seconds)
Observations
Questions
Environment
Thanks & Regards
Vishwajeet
The text was updated successfully, but these errors were encountered: