The Passionate Craftsman

Ruby, PHP, MySql, Software engineering and more.

Saturday, 4 February 2012

G-WAN World's fastest web server for C scripts

UPDATE: The forum of the web site has been closed  few months ago. There is not any active community and actually there are very few people supporting the idea that G-WAN is very fast.

After my previous post on CGI, I continued to search for a FastCGI example written in C, for the Mac and nginx. There is a post about it, but it was not working. However I found an awesome project, G-WAN, a web server built in ANSI C, super fast, at least from the charts reported on the web site. Another fantastic feature that G-WAN has, is the possibility to write C scripts, yes scripts! You put your scripts in a directory and when the script is called from the browser it is compiled and served. G-WAN can serve hundreds of thousands of connections per second but the response time is much better than any other language and application server.

This is a Hello World! example, the code does not has to be compiled:

// ============================================================================
// C servlet sample for the G-WAN Web Application Server (http://trustleap.ch/)
// ----------------------------------------------------------------------------
// hello.c: just used with Lighty's Weighttp to benchmark a minimalist servlet
// ============================================================================
// imported functions:
//   get_reply(): get a pointer on the 'reply' dynamic buffer from the server
//    xbuf_cat(): like strcat(), but it works in the specified dynamic buffer
// ----------------------------------------------------------------------------
#include "gwan.h" // G-WAN exported functions

int main(int argc, char *argv[])
{
   xbuf_cat(get_reply(argv), "Hello World!");
   
   return 200; // return an HTTP code (200:'OK')
}
// ============================================================================
// End of Source Code
// ============================================================================


Now start the server:

sudo ./gwan

and enjoy: http://localhost:8080/csp?hello1.c

I wonder if, in a near future, we will have a super fast REST backend with a thick Javascript interface made with Backbone.js and JQuery.

Labels: ,

3 Comments:

At 23 February 2012 at 07:41 , Anonymous Pierre said...

G-WAN offers scripts in C, C++, Objective-C/C++ and Java.

And the G-WAN loan.java test goes at 500,000+ requests per second:

http://gwan.com/source/loan.java

That'makes Java almost as fast as G-WAN C scripts!

 
At 23 February 2012 at 07:52 , Blogger Riccardo Tacconi said...

This comment has been removed by the author.

 
At 23 February 2012 at 07:53 , Blogger Riccardo Tacconi said...

This comment has been removed by the author.

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home