A method and system for optimizing the startup speed of Jupyter development environment, electronic device, and storage medium
By pre-building container images in the Kubernetes cluster and using fuse technology to optimize container allocation, the problem of long waiting time during the startup of the Jupyter development environment is solved, significantly increasing the startup speed and improving the user experience.
Patent Information
- Application Number
- CN202111315793.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-08
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-11-08
AI Technical Summary
In the AI platform system based on the kubernetes container service environment, during the startup process of the Jupyter development environment, especially when system resources are insufficient, the waiting time will be too long, seriously affecting the user experience.
Build a kubernetes cluster and pre-build a specified version of the container image on the node host. Use fuse technology to optimize the allocation and mounting of containers. Set idle container thresholds to dynamically adjust the starting and stopping of containers to ensure a quick startup of the Jupyter environment.
By pre-building containers and using fuse technology, the startup speed of Jupyter containers is greatly improved and the user experience is improved.
Smart Images

Figure CN114296863B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular relates to a method and system for optimizing the startup speed of a Jupyter development environment, an electronic device, and a storage medium. Background Art
[0002] In the development and practice of machine learning, one of the headaches for developers is the preparation of the environment. Usually, machine learning or deep learning relies on many related software packages and hardware resources. With the AI-PaaS service in the cloud, the service provider provides all the required infrastructure, and developers can access it by connecting through a browser, which greatly alleviates the trouble of environment preparation. In the current AI platform service system based on the kubernetes container service environment, when a user opens a new jupyter development environment, the underlying layer has the following transactions to handle: Select the container host: completed within kubernetes; Check to pull the image: if the specified image does not exist on the host, it needs to be pulled first; Allocate volume space: used to save user data; Start the container process and mount the volume; The container process checks the installation of the jupyter environment: if jupyter is not installed in the selected image, it needs to be installed; The container process starts the jupyter process and monitors the process. In this series of processes, steps 1 / 2 / 3 / 5 may take a lot of time, especially when the system resources are insufficient, the first step will stagnate. In the actual user experience, the waiting time for the startup process is usually relatively long, which seriously deteriorates the experience effect. Summary of the invention
[0003] In view of the above problems, the present invention provides a method and system, electronic device, and storage medium for optimizing the startup speed of a Jupyter development environment. The method includes:
[0004] Build a kubernetes cluster and build containers containing the specified version of the image on the node hosts in the kubernetes cluster;
[0005] The user requests to open the Jupyter environment, and determines whether the node host of the user already has the allocated container. If so, the corresponding Jupyter container is directly opened; if not, an idle container is allocated to the node host of the user, and the user's storage space is mounted to the container using the fuse technology, and then the Jupyter process is started with the user directory as the main directory, and finally the URL address for accessing Jupyter is provided to the user;
[0006] Among them, a threshold value for the number of idle containers is set in advance based on the running business situation. If the number of idle containers in the Kubernetes cluster is greater than the threshold, the exceeding containers are stopped; if the number of idle containers is less than the threshold, a new container is allocated.
[0007] Preferably, the container containing the specified version image includes a container containing a Jupyter image.
[0008] Preferably, a threshold value of the number of containers in an idle state is set in advance based on the running business situation. If the number of containers in an idle state in the kubernetes cluster is greater than the threshold value, the exceeding containers are stopped; if the number of containers in an idle state is less than the threshold value, allocating a new container includes:
[0009] Check the number of containers in the idle state and determine whether the number is greater than the threshold; if so, select the container with the longest idle time, stop the Jupyter service process in the container, and use the fuse technology to unload the user directory;
[0010] If it is less, apply for a new container from the kubernetes cluster.
[0011] A system for optimizing the startup speed of a Jupyter development environment provided by an embodiment of the present invention includes:
[0012] A building module is used to build a kubernetes cluster and build containers containing a specified version of the image on each node host in the kubernetes cluster;
[0013] The allocation module is used for the user to request to open the Jupyter environment, determine whether the allocated container already exists on the user's node host, and directly open the corresponding Jupyter container if it does; if not, allocate an idle container to the user's node host, and mount the user's storage space to the container using the fuse technology, then start the Jupyter process with the user directory as the main directory, and finally provide the user with a URL address for accessing Jupyter;
[0014] Among them, a threshold value for the number of idle containers is set in advance based on the running business situation. If the number of idle containers in the Kubernetes cluster is greater than the threshold, the exceeding containers are stopped; if the number of idle containers is less than the threshold, a new container is allocated.
[0015] Preferably, a threshold value of the number of containers in an idle state is set in advance based on the running business situation. If the number of containers in an idle state in the kubernetes cluster is greater than the threshold value, the exceeding containers are stopped; if the number of containers in an idle state is less than the threshold value, allocating a new container includes:
[0016] Check the number of containers in the idle state and determine whether the number is greater than the threshold; if so, select the container with the longest idle time, stop the Jupyter service process in the container, and use the fuse technology to unload the user directory;
[0017] If it is less, apply for a new container from the kubernetes cluster.
[0018] An electronic device provided by an embodiment of the present invention includes at least one processing unit and at least one storage unit, wherein the storage unit stores a program, and when the program is executed by the processing unit, the processing unit executes the method described above.
[0019] An embodiment of the present invention provides a computer-readable storage medium, which stores a computer program executable by an electronic device. When the program runs on the electronic device, the electronic device executes the above-mentioned method.
[0020] Compared with the prior art, the present invention has the following beneficial effects:
[0021] The present invention utilizes pre-starting of the container and the use of the fuse technology in the container, thereby greatly improving the startup speed of the Jupyter container. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a flow chart of the method for optimizing the startup speed of the Jupyter development environment provided by the present invention. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0024] The basic technical framework of the technical cloud machine learning development environment in this application includes:
[0025] Kubernetes: is an open source platform for managing containerized applications on multiple hosts in a cloud platform. The goal of Kubernetes is to make the deployment of containerized applications simple and powerful. Kubernetes provides a mechanism for application deployment, planning, updating, and maintenance.
[0026] HDFS: As an implementation of Google File System (GFS), it is the core subproject of Hadoop project and the basis of data storage management in distributed computing. It is developed based on the need to access and process large files in streaming data mode and can run on cheap commercial servers. Its high fault tolerance, high reliability, high scalability, high availability, high throughput and other features provide fault-proof storage for massive data and bring a lot of convenience to the application processing of large data sets.
[0027] SFTP: SSH File Transfer Protocol (English: SSH File Transfer Protocol, also known as Secret File Transfer Protocol, Chinese: Secure File Transfer Protocol, English: Secure FTP or abbreviation: SFTP) is a network transmission protocol that provides file access, transfer and management functions through a data stream connection;
[0028] Jupyter: It is opened in the form of a web page. You can write and run the code directly on the web page, and the running results of the code will be directly displayed under the code block. If you need to write a description document during the programming process, you can write it directly on the same page, which is convenient for timely description and explanation;
[0029] FUSE: Filesystem in Userspace, as the name implies, is a file system in user space. File systems are generally implemented in the kernel, for example, common file systems such as Ext4, Fat32, and NTFS (Kernel native version) have their codes in the kernel, but the special thing about FUSE is that the core logic of its file system is implemented in user space.
[0030] Reference Figure 1 The present invention provides a method for optimizing the startup speed of a Jupyter development environment, the method comprising:
[0031] Build a kubernetes cluster and build containers with the specified version of the image on the node hosts in the kubernetes cluster. The containers with the specified version of the image include containers with the Jupyter image.
[0032] When a user requests to open the Jupyter environment, it is determined whether the user's node host already has an allocated container. If so, the corresponding Jupyter container is directly opened; if not, an idle container is allocated to the user's node host, and the user's storage space is mounted to the container using the fuse technology. Then, the Jupyter process is started with the user directory as the main directory, and finally the URL address for accessing Jupyter is provided to the user.
[0033] Among them, a threshold for the number of idle containers is set in advance based on the running business situation. If the number of idle containers in the Kubernetes cluster is greater than the threshold, the exceeding containers will be stopped; if the number of idle containers is less than the threshold, a new container will be allocated.
[0034] Furthermore, a threshold for the number of idle containers is set in advance based on the running business situation. If the number of idle containers in the kubernetes cluster is greater than the threshold, the exceeding containers are stopped; if the number of idle containers is less than the threshold, allocating new containers includes:
[0035] Check the number of containers in idle state to determine whether the number is greater than the threshold; if it is greater, select the container with the longest idle time, stop the Jupyter service process in the container, and use the fuse technology to unmount the user directory;
[0036] If it is less, apply for a new container from the kubernetes cluster.
[0037] In this embodiment, in actual applications, an sftp account and directory are allocated to each user, and user files and environment-related files are stored in this directory; when the user obtains a new container, the sshfs software and user account are used to mount the directory and store it in the process user's home directory in the container, and then the jupyter service process is started; in this way, the Jupyter environment accessed by the user, regardless of the different docker containers actually used, the files in its user directory are the same files on the sftp server, so that the user does not feel the change of the environment. Quotas can be set for user file storage on the sftp server to limit the number and size of stored files. This ensures that the file service is not overwhelmed by large files of individual users. Each user uses a different sftp account to achieve isolation between users.
[0038] A system for optimizing the startup speed of a Jupyter development environment provided by an embodiment of the present invention includes:
[0039] The build module is used to build a kubernetes cluster and build containers containing the specified version of the image on the node hosts in the kubernetes cluster;
[0040] The allocation module is used to determine whether the allocated container already exists on the user's node host when the user requests to open the Jupyter environment. If so, the corresponding Jupyter container is directly opened; if not, an idle container is allocated to the user's node host, and the user's storage space is mounted to the container using the fuse technology. The Jupyter process is then started with the user's directory as the main directory, and the URL address for accessing Jupyter is finally provided to the user.
[0041] Among them, a threshold for the number of idle containers is set in advance based on the running business situation. If the number of idle containers in the Kubernetes cluster is greater than the threshold, the exceeding containers will be stopped; if the number of idle containers is less than the threshold, a new container will be allocated.
[0042] Furthermore, a threshold for the number of idle containers is set in advance based on the running business situation. If the number of idle containers in the kubernetes cluster is greater than the threshold, the exceeding containers are stopped; if the number of idle containers is less than the threshold, allocating new containers includes:
[0043] Check the number of containers in idle state to determine whether the number is greater than the threshold; if it is greater, select the container with the longest idle time, stop the Jupyter service process in the container, and use the fuse technology to unmount the user directory;
[0044] If it is less, apply for a new container from the kubernetes cluster.
[0045] An electronic device provided by an embodiment of the present invention includes at least one processing unit and at least one storage unit, wherein the storage unit stores a program, and when the program is executed by the processing unit, the processing unit executes the above method.
[0046] An embodiment of the present invention provides a computer-readable storage medium, which stores a computer program executable by an electronic device. When the program runs on the electronic device, the electronic device executes the above method.
[0047] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for optimizing the startup speed of a Jupyter development environment, characterized in that: include: Build a kubernetes cluster and build containers containing the specified version of the image on the node hosts in the kubernetes cluster; The user requests to open the Jupyter environment, and determines whether the node host of the user already has the allocated container. If so, directly open the corresponding Jupyter container; if not, allocate an idle container to the node host of the user, and mount the user's storage space to the container using the fuse technology, then start the Jupyter process with the user directory as the main directory, and finally provide the user with a URL address to access Jupyter; Among them, a threshold value for the number of idle containers is set in advance based on the running business situation. If the number of idle containers in the Kubernetes cluster is greater than the threshold, the exceeding containers are stopped; if the number of idle containers is less than the threshold, a new container is allocated.
2. The method for optimizing the startup speed of the Jupyter development environment according to claim 1, characterized in that: The container containing the specified version image includes a container containing the Jupyter image.
3. The method for optimizing the startup speed of the Jupyter development environment according to claim 2, characterized in that: A threshold for the number of containers in an idle state is set in advance based on the running business situation. If the number of containers in an idle state in the kubernetes cluster is greater than the threshold, the exceeding containers are stopped; If the number of containers in the idle state is less than the threshold, allocating a new container includes: Checking the number of containers in an idle state, and determining whether the number is greater than the threshold; If it is greater, select the container with the longest idle time, stop the Jupyter service process in the container, and use the fuse technology to unmount the user directory; If it is less, apply for a new container from the kubernetes cluster.
4. A system for optimizing the startup speed of a Jupyter development environment, characterized in that: include: A building module is used to build a kubernetes cluster and build containers containing a specified version of the image on each node host in the kubernetes cluster; The allocation module is used for the user to request to open the Jupyter environment, determine whether the node host of the user already has the allocated container, and if so, directly open the corresponding Jupyter container; if not, allocate an idle container to the node host of the user, and mount the user's storage space to the container using the fuse technology, then start the Jupyter process with the user directory as the main directory, and finally provide the user with a URL address for accessing Jupyter; Among them, a threshold value for the number of idle containers is set in advance based on the running business situation. If the number of idle containers in the Kubernetes cluster is greater than the threshold, the exceeding containers are stopped; if the number of idle containers is less than the threshold, a new container is allocated.
5. The system for optimizing the startup speed of the Jupyter development environment according to claim 4, characterized in that: A threshold for the number of containers in an idle state is set in advance based on the running business situation. If the number of containers in an idle state in the kubernetes cluster is greater than the threshold, the exceeding containers are stopped; If the number of containers in the idle state is less than the threshold, allocating a new container includes: Checking the number of containers in an idle state, and determining whether the number is greater than the threshold; If it is greater, select the container with the longest idle time, stop the Jupyter service process in the container, and use the fuse technology to unmount the user directory; If it is less, apply for a new container from the kubernetes cluster.
6. An electronic device, characterized in that: The method comprises at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the program is executed by the processing unit, the processing unit executes the method according to any one of claims 1 to 3.
7. A storage medium, characterized in that: It stores a computer program executable by an electronic device. When the program runs on the electronic device, the electronic device executes the method described in any one of claims 1 to 3.
Citation Information
Patent Citations
Docker-based Jupyter Lab multi-user remote development method and system
CN112256399A
Kubernetes-based interactive modeling method and device, electronic equipment and storage medium
CN112988165A
Method and device for accessing linux container cluster using browser under multi-user environment
WO2018113443A1
