c10k-0.1.0: C10k server

Network.C10kServer

Description

Network server library to handle over 10,000 connections. Since GHC 6.10.4 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. To stop all server, send SIGTERM to the parent process. (e.g. kill `cat PIDFILE` where the PID file name is specified by pidFile)

Synopsis

Documentation

type C10kServer = Handle -> TCPInfo -> IO ()Source

The type of the first argument of runC10kServer.

data C10kConfig Source

The type of configuration given to runC10kServer as the second argument.

Constructors

C10kConfig 

Fields

initHook :: IO ()

A hook called initialization time. This is used topically to initialize syslog.

exitHook :: String -> IO ()

A hook called when the server exits due to an error.

parentStartedHook :: IO ()

A hook to be called in the parent process when all child process are preforked successfully.

startedHook :: IO ()

A hook to be called when each child process is started successfully.

sleepTimer :: Int

The time in seconds that a main thread of each child process to sleep when the number of connection reaches threadNumberPerProcess.

preforkProcessNumber :: Int

The number of child process.

threadNumberPerProcess :: Int

The number of thread which a process handle.

portName :: ServiceName

A port name. e.g. "http" or "80"

pidFile :: FilePath

A file where the process ID of the parent process is written.

user :: String

A user name. When the program linked with this library runs in the root privilege, set user to this value. Otherwise, this value is ignored.

group :: String

A group name. When the program linked with this library runs in the root privilege, set group to this value. Otherwise, this value is ignored.