Plack server with threads
There was no non-single threaded Plack server for Windows. It is because current implementations use preforking which is completly broken on this system. But wait, Perl already has threads which works better on Windows.
So I wrote Thrall: multithreaded Plack server for Windows. To be strict - it is hacked Starlet server with preforking removed, so now works with Perl on Windows correctly.
Well, I've noticed that threads are really stable and useful and its API is very nice. It is only one thing that breaks everything: threads::shared. It is horribly unstable and broken on Windows, so I avoided it as far as simple server might not to need it. Spawning new threads is very slow, so it is suggested to use large value for --max-reqs-per-child option.
It is interesting, that Thrall can be converted automagically to preforking server when it is started with -Mforks option/
Just hammered it a bit with ab and everything seems to be fine. No big leaks (i saw a 2mb increase in a 350 mb process over 10000 requests, might've been my app) and fairly fast.
However this worries me a bit:
Complete requests: 10000
Failed requests: 9982
(Connect: 0, Receive: 0, Length: 9982, Exceptions: 0)
Are you maybe not opening file handles in binary mode, leading to newline munging?
Otherwise, really good work. Thank you. :)
Sometimes I get errors like
Thread 88 terminated abnormally: failed to set socket to nonblocking mode:An operation was attempted on something that is not a socket. at C:/strawberry/perl/site/lib/Thrall/Server.pm line 113.
and a few requests are failed. Perl on Windows still sucks...
Oh, perhaps Perl on Windows XP/7 on VirtualBox sucks because native Windows 8 works without harm. No errors, no missing requests. Everything was fine.
> It is only one thing that breaks everything: threads::shared.
That really shouldn't happen. Either you're not using it correctly, or something really weird is going on.