kludge - trivial test httpd for Windows

Download

Download: kludge 0.1 (use 7-zip or p7zip to unpack).

In case someone also wants the dltar, here it is (it is a tar extractor with built-in zlib that can download via http, too, as a .exe for Windows). Warning: it's a really gross hack, use at your own risk and only on friendly tarballs from friendly web servers during a benchmark!

Compile like this (with mingw, I used a cross compiler under Linux):

i686-mingw-gcc -O -s -o test.exe test.cpp -lws2_32 -lwsock32

Description

This is the kludgy httpd I used to run my benchmarks against Windows. I tried porting libowfat and gatling, but couldn't get it to work in time. This httpd has WAY less features than gatling, but it is enough to just download a file, and I just added directory listing support, too.

This httpd tries to use the most scalable way to serve files, namely overlapped I/O and completion ports. It is normally run with just one thread, but you can give it the number of threads you want as a a command line argument. Then it will create that many threads.

Please note that this code is fatally flawed because it uses AcceptEx. This is meant to be the best way to do it, that's why I used it in the first place, but it turns out that you can DoS this server by connecting and not doing anything. As long as you don't send any data, AcceptEx won't signal the connection. This is a general flaw with AcceptEx in the "high performance" mode where you pass a bigger buffer so it only returns after the connection also sent some data. Apparently I'm the first one to notice this.

Also, this server has not been audited or hardened and should not be used on the Internet. It may be useful if you need example code, or if you want to quickly export some files on your Windows box in your LAN. Don't use this in untrusted networks. If you find bugs, please report them to felix-kludge (at) fefe.de.

Performance

Although I use TransmitFile to send the files as efficiently as possible under Windows, you will probably get really crappy performance. There is nothing I can do about it. When sending a 700 MB ISO out via HTTP via my gigabit ethernet network, I get about 16 MB/sec. I am sending this to my notebook. Both machines have an Intel gigabit Ethernet NIC. Downloading the very same file again (so it's in the buffer cache, supposedly) yields about 30 MB/sec. I am downloading with wget -O /dev/null, so nothing is actually written to disk on the notebook side.

Doing the same test on the same file (on the same NTFS filesystem) under Linux 2.19, I get 60 MB/sec and 102.58 MB/sec, respectively.

As far as I can tell, Windows XP really is that slow. Microsoft intentionally slowed it down so people doing "server work" would buy the server version. I don't have a server license right now, but you are welcome to benchmark this on one and tell me the result. :-)

See also