Writing a very scalable and specialized server
Posted on 2004-09-30
I've got the task of creating a server that simply recieves a connection and ~500 bytes of data immediately, then sends a few bytes of data and closes the connection. So I'm dealing with very short-lived connections, but I need to handle as many as possible.
I'm using winsock, and the server is a XP Pro machine with 2GB of memory and dual CPUs.
There seems several strategies for writing such a server, blocking, asynchronous, multi-threaded, single threaded, 2 threads per CPU, overlapped IO, and using IO completion ports.
AcceptEx() seems like a handy function (works with overlapped IO using either windows events or completion ports), in that it accepts a connection and recieves the first bit of data (which is all the data in my case) I then only need to send the response (simply a minimal http 404 response) and then close the connection. The processing on the data simply involves a hash table lookup and appending the buffer as is to a linked list. A seperate worker thread traverses the hash table at intervals looking for stale data and saving it to a database.
What kind of server model would suit me best?
Thanks for any information on the subject,