You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/basics/listening-port.md
+19-1Lines changed: 19 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,8 +86,26 @@ q)\p myhost:2000/2010 / use a free port between 2000 and 2010, using given h
86
86
87
87
## Multi-threaded port
88
88
89
-
A negative port sets a [multi-threaded](../kb/multithreaded-input.md) port and if used it must be the initial and only mode of operation, i.e. do not dynamically switch between positive port and negative port.
89
+
A negative port sets a [multi-threaded](../kb/multithreaded-input.md) port and if used it must be the initial and only mode of operation,
90
+
i.e. do not dynamically switch between positive port and negative port.
90
91
92
+
Note that there are a number of restrictions in multithreaded mode:
93
+
94
+
* queries are unable to update globals
95
+
*[.z.po](../ref/dotz.md#zpo-open) is not called on connect
96
+
*[.z.pc](../ref/dotz.md#zpc-close) is not called on disconnect
97
+
*[.z.W](../ref/dotz.md#zw-handles) has a view on main thread sockets only
98
+
* Cannot send async message
99
+
* Views can be recalculated from the main thread only
100
+
101
+
Multithreaded input mode supports WebSockets and HTTP (but not TLS) since 4.1t 2021.03.30.
102
+
TLS support available since 4.1t 2023.12.14. A custom [.z.ph](../ref/dotz.md#zph-http-get) which does not update global state should be used with HTTP.
103
+
104
+
The use of sockets from within those threads is allowed only for the one-shot sync request and HTTP client request (TLS/SSL support added in 4.1t 2023.11.10).
105
+
These can be inefficient, as it opens, queries and closes each time. Erroneous socket usage is blocked and signals a nosocket error.
106
+
107
+
In multithreaded input mode, the seed for the random-number generator used for threads other than the main thread is based on the socket descriptor for that connection;
108
+
these threads are transient – destroyed when the socket is closed, and no context is carried over for new threads/connections.
By default, kdb+ is single-threaded, and processes incoming queries sequentially.
12
9
13
10
An additional mode exists, designed for serving in-memory static data to an externally constrained number of clients only; it is not intended for use as a gateway, or serving mutable data, or data from disk. Each incoming connection is executed in its own thread, and is unable to update globals – it is purely functional in the sense that the execution of a query should not have side-effects.
@@ -18,27 +15,8 @@ Updates to globals are allowed only if they occur from within [`.z.ts`](../ref/d
18
15
19
16
The switching in and out of this mode now checks to avoid the situation where the main thread could have a socket open, and sockets being processed in other threads simultaneously.
20
17
21
-
Multithreaded input queue mode is active when the port for incoming connections is specified as negative, e.g. for startup
18
+
Multithreaded input queue mode is active when the port for incoming connections is specified as [negative](../basics/listening-port.md#negative-ports), e.g. for startup
22
19
23
20
```bash
24
21
$ q -p -5000
25
22
```
26
-
27
-
Multithreaded input mode supports WebSockets and HTTP (but not TLS) since 4.1t 2021.03.30. TLS support available since 4.1t 2023.12.14.
28
-
A custom [`.z.ph`](../ref/dotz.md#zph-http-get) which does not update global state should be used with HTTP.
29
-
30
-
31
-
## Restrictions
32
-
33
-
Some of the restrictions are:
34
-
35
-
1. queries are unable to update globals
36
-
2.[`.z.po`](../ref/dotz.md#zpo-open) is not called on connect
37
-
3.[`.z.pc`](../ref/dotz.md#zpc-close) is not called on disconnect
38
-
4.[`.z.W`](../ref/dotz.md#zw-handles) has a view on main thread sockets only
39
-
5. cannot send async messages
40
-
6. views can be recalculated from the main thread only
41
-
42
-
The use of sockets from within those threads is allowed only for the [one-shot sync request](../ref/hopen.md#one-shot-request) and HTTP client request (TLS/SSL support added in 4.1t 2023.11.10). These can be inefficient, as it opens, queries and closes each time. Erroneous socket usage is blocked and signals a `nosocket` error.
43
-
44
-
In multithreaded input mode, the seed for the random-number generator used for threads other than the main thread is based on the socket descriptor for that connection; these threads are transient – destroyed when the socket is closed, and no context is carried over for new threads/connections.
Copy file name to clipboardExpand all lines: docs/wp/ipc/index.md
+1-11Lines changed: 1 addition & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -222,7 +222,7 @@ The TLS protocol is used to communicate across a network in a way designed to pr
222
222
223
223
### Negative ports
224
224
225
-
A kdb+ process can be started in multithreaded input mode by setting a negative port number. A multithreaded process will use separate threads for every process that connects, which means that each client request can be executed on a separate CPU.
225
+
A kdb+ process can be started in multithreaded input mode by setting a [negative port number](../../basics/listening-port.md#multi-threaded-port). A multithreaded process will use separate threads for every process that connects, which means that each client request can be executed on a separate CPU.
226
226
227
227
Although secondary processes are used to farm queries out to multiple processes, they still have a single-threaded input queue. By using a negative port number, it is possible to multithread that queue too.
228
228
@@ -237,15 +237,6 @@ q)\p
237
237
238
238
Connections can be opened to this process in the same way as described previously for positive port numbers.
239
239
240
-
Note that there are a number of restrictions in multithreaded mode:
241
-
242
-
- Queries cannot update globals
243
-
-`.z.pc` is not called on disconnect
244
-
-`.z.W` has a view of main thread sockets only
245
-
- Cannot send async messages
246
-
- Cannot serve HTTP requests
247
-
- Views can be recalculated from the main thread only
0 commit comments