1
+ /*
2
+ The code here is run when conatSocketioCount > 1 (i.e., env var CONAT_SOCKETIO_COUNT).
3
+ This does NOT use the socketio cluster adapter or the nodejs cluster module.
4
+ Every worker process this spawns runs independently after it starts and there is
5
+ no single node coordinating communications like with the socketio cluster adapter,
6
+ and traffic across the cluster is minimal. This will thus *scale* much better,
7
+ though this is also just using normal TCP networking for communication instead of
8
+ IPC (like socketios cluster adapter). Also, the traffic between nodes is precisely
9
+ what is needed for Conat, so it's really solving a differnet problem than socketio's
10
+ cluster adapter, and under the hood what this actually does is much more sophisticated,
11
+ with each node maintaining and serving sqlite backed streams of data about their state.
12
+
13
+ This code exists mainly for testing and potentially also for scaling cocalc to
14
+ more traffic when running on a single machine without Kubernetes.
15
+
16
+ One cpu support several hundred simultaneous active connections -- if you want to
17
+ have 500 active users all using projects (that also means additional connections) --
18
+ you will definitely need more than one node.
19
+ */
20
+
1
21
import "@cocalc/backend/conat/persist" ;
2
22
import { init , type Options } from "@cocalc/conat/core/server" ;
3
23
import { getUser , isAllowed } from "./auth" ;
@@ -6,7 +26,7 @@ import { loadConatConfiguration } from "../configuration";
6
26
import { getLogger } from "@cocalc/backend/logger" ;
7
27
8
28
async function main ( ) {
9
- console . log ( "main " ) ;
29
+ console . log ( "conat server: starting a cluster node " ) ;
10
30
11
31
addErrorListeners ( ) ;
12
32
const configDone = loadConatConfiguration ( ) ;
0 commit comments