This example builds on the basic server
and adds some of the more complex options that you might want to add to your server. You're not expected to add all of these to a server, this is just an example of the ways in which you can tune a server.
This example is shipped with all licensed versions of The Server Framework and it requires the core server framework libraries (see here
for licensing options). You can always download the latest version of this example from here
; and although you will need the correct libraries to be able to build it you can look at the example code and see how it works and perhaps get ideas from it. A compiled, unicode release, build of this example is available on request if you require it for performance analysis of the framework.
The following features are demonstrated:
Unique locks per socket - Although most of our examples show the use of shared locks to reduce resource usage it's possible, and sometimes desirable, to have each socket use a unique lock. If you pass 0 as the
-numberOfLocks argument then the server uses unqiue locks.
Setting the spin count of the per socket locks - pass the required value, e.g. 4000 on the command line with
Coming Soon!Buffer allocation strategies -
-pageSizedBuffers allow you to tune the buffer allocator so that it can use buffers which are created using
VirtualAlloc() and which are aligned on Operating System Page boundaries. This can help to reduce the number of 'locked pages' that your server has whilst running.
Support for "zero byte reads" - via
-asyncZero. If you have a server which expects to have a great many connections (10s of thousands) and you expect not to be receiving much data from the clients then it may be beneficial to operate with "zero byte reads" enabled. This reduces the number of "locked pages" that the server requires as pending zero byte reads lock less pages.
Send and Receive buffer sizing and TCP Receive window tuning - via
-sendBuffer allow you to specify the TCP buffer sizes when the server is created. Setting the Receieve buffer in this way can affect the TCP receieve window on some Operating Systems.