@@ -14,7 +14,7 @@ open source tool to edit the png file.
14
14
Jupyter Server Architecture
15
15
---------------------------
16
16
17
- The Jupyter Server system can be seen in figure below:
17
+ The Jupyter Server system can be seen in the figure below:
18
18
19
19
.. image :: ../images/jupyter-server-architecture.drawio.png
20
20
:alt: Jupyter Server Architecture
@@ -36,38 +36,145 @@ Jupyter Server contains the following components:
36
36
ServerApp with extra request handlers.
37
37
38
38
- **Gateway Server ** is a web server that, when configured, provides access to
39
- Jupyter Kernels running on other hosts. There are different ways to create a
40
- gateway server. If your ServerApp needs to communicate with remote Kernels
39
+ Jupyter kernels running on other hosts. There are different ways to create a
40
+ gateway server. If your ServerApp needs to communicate with remote kernels
41
41
residing within resource-managed clusters, you can use
42
42
`Enterprise Gateway <https://github.com/jupyter-server/enterprise_gateway >`_,
43
43
otherwise, you can use
44
44
`Kernel Gateway <https://github.com/jupyter-server/kernel_gateway >`_, where
45
- Kernels run locally to the gateway server.
45
+ kernels run locally to the gateway server.
46
46
47
47
- **Contents Manager and File Contents Manager ** are responsible for serving
48
48
Notebook on the file system. Session Manager uses Contents Manager to receive
49
- Kernel path. Follow :ref: `the Contents API guide <contents_api >` to learn
49
+ kernel path. Follow :ref: `the Contents API guide <contents_api >` to learn
50
50
about Contents Manager.
51
51
52
- - **Session Manager ** processes users' Sessions. When a user starts a new Kernel ,
53
- Session Manager starts a process to provision Kernel for the user and generates
52
+ - **Session Manager ** processes users' Sessions. When a user starts a new kernel ,
53
+ Session Manager starts a process to provision kernel for the user and generates
54
54
a new Session ID. Each opened Notebook has a separate Session, but different
55
- Notebook Kernels can use the same Session. That is useful if the user wants to
55
+ Notebook kernels can use the same Session. That is useful if the user wants to
56
56
share data across various opened Notebooks. Session Manager uses SQLite3
57
- DataBase to store the Session information. The database is stored in memory by
57
+ database to store the Session information. The database is stored in memory by
58
58
default, but can be configured to save to disk.
59
59
60
60
- **Mapping Kernel Manager ** is responsible for managing the lifecycles of the
61
- Kernels running within the ServerApp. It starts a new Kernel for a user's Session
62
- and facilitates interrupt, restart, and shutdown operations against the Kernel .
61
+ kernels running within the ServerApp. It starts a new kernel for a user's Session
62
+ and facilitates interrupt, restart, and shutdown operations against the kernel .
63
63
64
64
- **Jupyter Client ** library is used by Jupyter Server to work with the Notebook
65
- Kernels .
65
+ kernels .
66
66
67
- - **Kernel Manager ** manages a single Kernel for the Notebook. To know more about
67
+ - **Kernel Manager ** manages a single kernel for the Notebook. To know more about
68
68
Kernel Manager, follow
69
69
`the Jupyter Client APIs documentation <https://jupyter-client.readthedocs.io/en/latest/api/manager.html#jupyter_client.KernelManager >`_.
70
70
71
- - **Kernel Spec Manager ** parses files with JSON specification for a Kernels,
72
- and provides a list of available Kernel configurations. To learn about
73
- Kernel Spec, check `the Jupyter Client guide <https://jupyter-client.readthedocs.io/en/stable/kernels.html#kernel-specs >`_.
71
+ - **Kernel Spec Manager ** parses files with JSON specification for a kernels,
72
+ and provides a list of available kernel configurations. To learn about
73
+ Kernel Spec Manager, check `the Jupyter Client guide <https://jupyter-client.readthedocs.io/en/stable/kernels.html#kernel-specs >`_.
74
+
75
+ Create Session Workflow
76
+ -----------------------
77
+
78
+ The create Session workflow can be seen in the figure below:
79
+
80
+ .. image :: ../images/session-create.drawio.png
81
+ :alt: Create Session Workflow
82
+ :width: 90%
83
+ :align: center
84
+
85
+ When a user starts a new kernel, the following steps occur:
86
+
87
+ #. The Notebook client sends |create_session |_ request to Jupyter Server. This
88
+ request has all necessary data, such as Notebook name, type, path, and kernel
89
+ name.
90
+
91
+ #. **Session Manager ** asks **Contents Manager ** for the kernel file system path
92
+ based on the input data.
93
+
94
+ #. **Session Manager ** sends kernel path to **Mapping Kernel Manager **.
95
+
96
+ #. **Mapping Kernel Manager ** starts the kernel create process by using
97
+ **Multi Kernel Manager ** and **Kernel Manager **. You can learn more about
98
+ **Multi Kernel Manager ** in
99
+ `the Jupyter Client APIs <https://jupyter-client.readthedocs.io/en/latest/api/manager.html#multikernelmanager-controlling-multiple-kernels >`_.
100
+
101
+ #. **Kernel Manager ** uses the provisioner layer to launch a new kernel.
102
+
103
+ #. **Kernel Provisioner ** is responsible for launching kernels based on the
104
+ kernel specification. If the kernel specification doesn't define a provisioner,
105
+ it uses `Local Provisioner <https://jupyter-client.readthedocs.io/en/latest/api/provisioners.html#jupyter_client.provisioning.local_provisioner.LocalProvisioner >`_
106
+ to launch the kernel. You can use
107
+ `Kernel Provisioner Base <https://jupyter-client.readthedocs.io/en/latest/api/provisioners.html#jupyter_client.provisioning.provisioner_base.KernelProvisionerBase >`_
108
+ and
109
+ `Kernel Provisioner Factory <https://jupyter-client.readthedocs.io/en/latest/api/provisioners.html#jupyter_client.provisioning.factory.KernelProvisionerFactory >`_
110
+ to create custom provisioners.
111
+
112
+ #. **Kernel Spec Manager ** gets the kernel specification from the JSON file.
113
+ The specification is located in ``kernel.json `` file.
114
+
115
+ #. Once **Kernel Provisioner ** launches the kernel,
116
+ **Kernel Manager ** generates the new kernel ID for **Session Manager **.
117
+
118
+ #. **Session Manager ** saves the new Session data to the SQLite3 database
119
+ (Session ID, Notebook path, Notebook name, Notebook type, and kernel ID).
120
+
121
+ #. Notebook client receives the created Session data.
122
+
123
+ .. _create_session : https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter_server/master/jupyter_server/services/api/api.yaml#/sessions/post_api_sessions
124
+
125
+ .. |create_session | replace :: the *POST /api/sessions *
126
+
127
+ Delete Session Workflow
128
+ -----------------------
129
+
130
+ The delete Session workflow can be seen in the figure below:
131
+
132
+ .. image :: ../images/session-delete.drawio.png
133
+ :alt: Delete Session Workflow
134
+ :width: 80%
135
+ :align: center
136
+
137
+ When a user stops a kernel, the following steps occur:
138
+
139
+ #. The Notebook client sends |delete_session |_ request to Jupyter Server. This
140
+ request has the Session ID that kernel is currently using.
141
+
142
+ #. **Session Manager ** gets the Session data from the SQLite3 database and sends
143
+ the kernel ID to **Mapping Kernel Manager **.
144
+
145
+ #. **Mapping Kernel Manager ** starts the kernel shutdown process by using
146
+ **Multi Kernel Manager ** and **Kernel Manager **.
147
+
148
+ #. **Kernel Manager ** determines the mode of interrupt from the
149
+ **Kernel Spec Manager **. It supports ``Signal `` and ``Message ``
150
+ interrupt modes. By default, the ``Signal `` interrupt mode is being used.
151
+
152
+ - When the interrupt mode is ``Signal ``, the **Kernel Provisioner **
153
+ interrupts the kernel with the ``SIGINT `` operating system signal
154
+ (although other provisioner implementations may use a different approach).
155
+
156
+ - When interrupt mode is ``Message ``, Session sends
157
+ the `"interrupt_request" <https://jupyter-client.readthedocs.io/en/latest/messaging.html#msging-interrupt >`_
158
+ message on the control channel.
159
+
160
+ #. After interrupting kernel, Session sends the `"shutdown_request" <https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-shutdown >`_
161
+ message on the control channel.
162
+
163
+ #. **Kernel Manager ** waits for the kernel shutdown. After the timeout, and if
164
+ it detects the kernel process is still running, the **Kernel Manager **
165
+ terminates the kernel sending a ``SIGTERM `` operating system signal
166
+ (or provisioner equivalent). If it finds the kernel process has
167
+ not terminated, the **Kernel Manager ** will follow up with a ``SIGKILL ``
168
+ operating system signal (or provisioner equivalent) to ensure the kernel's
169
+ termination.
170
+
171
+ #. **Kernel Manager ** cleans up the kernel resources. It removes kernel's interprocess
172
+ communication ports, closes control socket, and releases Shell, IOPub, StdIn,
173
+ Control, and Heartbeat ports.
174
+
175
+ #. When shutdown is finished, **Session Manager ** deletes the Session data from
176
+ the SQLite3 database and responses 204 status code to the Notebook client.
177
+
178
+ .. _delete_session : https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter_server/master/jupyter_server/services/api/api.yaml#/sessions/delete_api_sessions__session_
179
+
180
+ .. |delete_session | replace :: the *DELETE /api/sessions/{session_id} *
0 commit comments