Add to git.
[rws.git] / TODO
1 Support for SMP
2 ---------------
3
4 It's actually going to be quite easy to modify rws so that it supports
5 SMP - even though the underlying threading library is lightweight user
6 threads. The plan is as follows, I'm just waiting for the patch!
7
8 Support should probably go directly into pthrlib/src/pthr_server.c so
9 that it can benefit all pthrlib-based servers.
10
11 At start up, based on some command line flag and/or autodetection of
12 the number of CPUs, the server should fork N times where N is the
13 number of CPUs. This results in N+1 processes. Process 0 (the parent)
14 will have the listening socket. Processes 1-N will be connected by
15 Unix domain sockets back to process 0. Processes 1-N will have special
16 modified listen threads listening on their respective Unix domain
17 socket. (NB. Use the socketpair function to create each Unix domain
18 socket).
19
20 When process 0 receives a connection, based on some hashing function
21 of the peername, it should decide which of the 1-N processes will
22 handle the request. The important thing is that the hashing function
23 must always assign the same client to the same process, which is why
24 the hash should be based on the peername.
25
26 When a new client connection arrives at process 0, let's say it
27 decides to pass this to process n (1 <= n <= N). It should pass the
28 file descriptor over the corresponding Unix domain socket to process n
29 using the sendmsg(2) function (see cmsg(3) for details). Process n
30 will receive the file descriptor and can then continue to handle the
31 request.
32
33 This method should scale up over small numbers of processors (eg. up
34 to 8).