digitalmars.D - HTTP4D embedded http provider
- goughy (30/30) Apr 15 2012 Hi,
- Brad Anderson (12/40) Apr 16 2012 Neat. I like the integration with std.concurrency and the API in genera...
- goughy (16/86) Apr 16 2012 I had a look at the following and thought 23k seemed pretty
Hi, I have just finished the first cut of an HTTP library to provide application level support for HTTP (ie as a server, not a client). The library provide a very simple mechanism for processing HTTP requests both synchronously (via delegates) and asynchronously (via std.concurrency) using request/response objects. eg. import std.stdio; import protocol.http; int main( string[] args ) { httpServe( "127.0.0.1", 8888, (req) => req.getResponse(). status( 200 ). header( "Content-Type", "text/html" ). content( "<html><head></head><body>Processed ok</body></html>" ) ); return 0; } The code is available on github: https://github.com/goughy/d/tree/master/http4d Note that this is alpha quality code, so YMMV. I would appreciate some feedback, critiques, opinions etc. - particularly in the area of it being "idiomatic" as I'm still finding my feet in the D language. The good thing is without any real performance tuning, I can push through over 23,000 requests per second, and I'm sure there is plenty of room for improvement. Cheers.
Apr 15 2012
On Sun, Apr 15, 2012 at 6:27 AM, goughy <goughy gmail.com> wrote:Hi, I have just finished the first cut of an HTTP library to provide application level support for HTTP (ie as a server, not a client). The library provide a very simple mechanism for processing HTTP requests both synchronously (via delegates) and asynchronously (via std.concurrency) using request/response objects. eg. import std.stdio; import protocol.http; int main( string[] args ) { httpServe( "127.0.0.1", 8888, (req) => req.getResponse(). status( 200 ). header( "Content-Type", "text/html" ). content( "<html><head></head><body>**Processed ok</body></html>" ) ); return 0; } The code is available on github: https://github.com/goughy/d/** tree/master/http4d <https://github.com/goughy/d/tree/master/http4d> Note that this is alpha quality code, so YMMV. I would appreciate some feedback, critiques, opinions etc. - particularly in the area of it being "idiomatic" as I'm still finding my feet in the D language. The good thing is without any real performance tuning, I can push through over 23,000 requests per second, and I'm sure there is plenty of room for improvement. Cheers.Neat. I like the integration with std.concurrency and the API in general (though I too am still trying to get a feel for idiomatic D). How does 23,000 requests/sec compare to, say, nginx's performance (which seems to be the current performance king)? I just tried to look up some general performance figures but they are all over the place and don't correspond to your machine in any case. I just watched the Go talk from Lang.NEXT and he uses Go's standard HTTP library and it made me a little jealous. Perhaps this would be a good candidate for Phobo's HTTP library. Regards, Brad Anderson
Apr 16 2012
On Monday, 16 April 2012 at 07:46:11 UTC, Brad Anderson wrote:On Sun, Apr 15, 2012 at 6:27 AM, goughy <goughy gmail.com> wrote:I had a look at the following and thought 23k seemed pretty reasonable for a first cut: http://timyang.net/programming/c-erlang-java-performance/ But then I also saw http://nbonvin.wordpress.com/2011/03/14/apache-vs-nginx-vs-varnish-vs-gwan/, and G-WAN seems to be able to crack 120k, so this library is unlikely to hit that mark. But again there's benchmarks and benchmarks, and I haven't tuned any kernel params etc - just straight out of the box. There is some pretty naive code also that I'm sure could be better tuned, but it's currently more than enough for my planned uses, and I'm happy its in that range without, really, a huge amount of effort. I would be stoked if this was usable enough for Phobos, but the dependency on Zeromq might preclude that. Cheers.Hi, I have just finished the first cut of an HTTP library to provide application level support for HTTP (ie as a server, not a client). The library provide a very simple mechanism for processing HTTP requests both synchronously (via delegates) and asynchronously (via std.concurrency) using request/response objects. eg. import std.stdio; import protocol.http; int main( string[] args ) { httpServe( "127.0.0.1", 8888, (req) => req.getResponse(). status( 200 ). header( "Content-Type", "text/html" ). content( "<html><head></head><body>**Processed ok</body></html>" ) ); return 0; } The code is available on github: https://github.com/goughy/d/** tree/master/http4d <https://github.com/goughy/d/tree/master/http4d> Note that this is alpha quality code, so YMMV. I would appreciate some feedback, critiques, opinions etc. - particularly in the area of it being "idiomatic" as I'm still finding my feet in the D language. The good thing is without any real performance tuning, I can push through over 23,000 requests per second, and I'm sure there is plenty of room for improvement. Cheers.Neat. I like the integration with std.concurrency and the API in general (though I too am still trying to get a feel for idiomatic D). How does 23,000 requests/sec compare to, say, nginx's performance (which seems to be the current performance king)? I just tried to look up some general performance figures but they are all over the place and don't correspond to your machine in any case. I just watched the Go talk from Lang.NEXT and he uses Go's standard HTTP library and it made me a little jealous. Perhaps this would be a good candidate for Phobo's HTTP library. Regards, Brad Anderson
Apr 16 2012