Network server library to handle over 10,000 connections. Since
GHC 6.12 or earlier uses select(), it cannot handle connections over
1,024. This library uses the "prefork" technique to get over the
barrier. Each process handles threadNumberPerProcess
connections.
preforkProcessNumber
child server processes are preforked. So, this
server can handle preforkProcessNumber
* threadNumberPerProcess
connections.
Programs complied by GHC 6.10 or earlier with the -threaded option kill the IO thread when forkProcess is used. So, don't specify the -threaded option to use this library.
Even if GHC 6.14 supports kqueue or epoll(), it is difficult for RTS to balance over multi-cores. So, this library can be used to make a process for each core and to set limitation of the number to accept connections.
To stop all server, send SIGTERM to the parent process.
(e.g. kill `cat PIDFILE`
where the PID file name is
specified by pidFile
)
- data C10kConfig = C10kConfig {
- initHook :: IO ()
- exitHook :: String -> IO ()
- parentStartedHook :: IO ()
- startedHook :: IO ()
- sleepTimer :: Int
- preforkProcessNumber :: Int
- threadNumberPerProcess :: Int
- portName :: ServiceName
- ipAddr :: Maybe HostName
- pidFile :: FilePath
- user :: String
- group :: String
- type C10kServer = Socket -> IO ()
- runC10kServer :: C10kServer -> C10kConfig -> IO ()
- type C10kServerH = Handle -> TCPInfo -> IO ()
- runC10kServerH :: C10kServerH -> C10kConfig -> IO ()
Documentation
data C10kConfig Source
The type of configuration given to runC10kServer
as the second
argument.
C10kConfig | |
|
type C10kServer = Socket -> IO ()Source
The type of the first argument of runC10kServer
.
runC10kServer :: C10kServer -> C10kConfig -> IO ()Source
Run C10kServer
with C10kConfig
.
type C10kServerH = Handle -> TCPInfo -> IO ()Source
The type of the first argument of runC10kServerH
.
runC10kServerH :: C10kServerH -> C10kConfig -> IO ()Source
Run C10kServerH
with C10kConfig
.