It's not the size of the dog in the fight, it's the size of the fight in the dog. Mark Twain

Upgrade: (a) overwrite your ./include, ./libraries files and the gwan executable with the new files and then (b) run G-WAN once without -d (daemon mode) to make sure that the maintenance, servlet and handler scripts compile.

Past years: 2013, 2012, 2011, 2010, 2009

Protocol Handlers, UDP, PH7, Java getEnv()



This version brings bug fixes and platform workarounds (AMD, kernel and libc versions, hypervisors), a much lower memory footprint, serves large files faster, disabled caches and minifying by default, support of UDP, and a protocol handler (websockets, SMTP, LDAP...) example, see gwan/.../handlers/PONG.c

The Reverse-Proxy its Elastic Load-Balancer were removed from the public distribution because, to say it politely, the "environment" is not welcoming new solutions.

Like "Connection handlers" and "Content-type handlers", "Protocol handlers" are stored under the gwan/listener/host directory, under a user-defined file name (i.e. PONG.c or PONG.cpp for the "PONG" protocol). Capital letters are mandatory for protocol handler file names.

If the listener directory structure specifies an existing protocol handler (see the example below) then the corresponding protocol handler script is loaded and executed instead of G-WAN's default HTTP protocol handler:

                          Protocol name                     Protocol handler
                           (uppercase)                         (uppercase)
               listener       +--+    host (IPv4/DNS)             +--+
          ------------------- |  |    --------------              |  |
   gwan / / # / handlers / PONG.c
          -------------- ----        |
            IP address   port       root host ($-prefixed hosts are virtual)

We have improved the way the G-WAN memory manager setups and schedules allocations: on Linux 64-bit, with 6 worker threads and after all scripts are loaded G-WAN has now a 2 MB footprint (from 8 MB) – even during an heavy server load. This makes (G-WAN + JVM) require a tiny 12 MB footprint (less on 32-bit), suitable for embedded Linux devices (routers, gateways, firewalls, smartphones, etc.).

Note that, in contrast with Nginx, G-WAN is not limited to a fixed amount of concurrent clients (set with worker_connections 4096; in nginx.conf). Instead, G-WAN allocates space on-the-fly, up to more than one million of concurrent clients (the extra space above 1m is for backend connections, log files, etc.).

For Java, we added the getStrEnv() and getIntEnv() G-WAN API calls, see the new /csp/ servlet example. As recent Linux distributions have removed the javac compiler from its corresponding jdk/bin directory (to put it under /usr/bin), G-WAN will use the JVM compiler found in the PATH when no jdk/bin/javac can be found. If you don't want that to happen (because you have several Java runtimes installed and want to pick a specific one) then create a jdk/bin/javac link pointing to the javac compiler you want to use.

The static and dynamic caches are now disabled by default. It is trivial to activate them again from the new init.c script with get_env(USE_WWW_CACHE) or get_env(USE_WWW_CACHE) (which are global settings). For a per-request choice, enable servlet caching and use the RC_NOCACHE return value should be used from servlets, or use the #pragma nocache compilation directive if the choice can be hard-coded.

For PHP, the automatic parsing of the POST entity as well as GET parameters are now passed as PHP environment variables ($_POST and $_GET) and G-WAN's SESSION_ID is passed as $COOKIE.

A more recent PHP runtime called PH7 can now be used from G-WAN. Written by Symisc for embedded devices, PH7 has a small-footprint and can be made thread-safe. As a result, G-WAN can load the PH7 VM like for Java, Scala or C#, rather than use a CGI/FastCGI/SCGI process (like for Zend PHP). PH7 scripts are therefore safer, lighter and faster than Zend scripts (hello.ph7 runs @ 580,000 RPS without caching). Having a problem with a PH7 API call that we misused, we also got a quick and helpful answer from the Symisc Team – yet another welcome surprise. Last but not least, Symisc said they would complete PHP v5 support (core and libs) if sponsored.

Regarding CGI, X_HTTP_HEADERS has been added to let all languages get the information without relying on framework-specific variables. For example, PHP creates the SCRIPT_FILENAME environment variable (G-WAN rather creates the CGI/1.1 RFC-compliant PATH_TRANSLATED value). For any reason, the SCRIPT_NAME value correctly created by G-WAN is replaced by the value of SCRIPT_FILENAME at the time PHP is listing it. Other programming languages relying on CGI environment variables are not affected and return the expected values.

Our ab.c open-source benchmark tool can now collect the CPU and RAM resources of web servers that were modifed to escape the previous pid search method. New features were added, like the ability to specify the URL, concurrency range, steps, etc. on the command line, new error messages, server location and version detection, system configuration...

We have modified G-WAN to make it serve empty files as fast as a 100-byte file: as Nginx caches file metadata, some people use this criteria to compare servers. Using the G-WAN embedded nop.gif "bacon" resource (a 43-byte transparent GIF pixel) is technically more relevant than empty files as the disk won't be used at all. Besides, Web "bacons" are heavily used in the advertising industry. To make this G-WAN GET /nop.gif URI also work with Nginx add this directive to your nginx.conf file:

 location = /nop.gif { empty_gif; }

To prevent users from running G-WAN as root, we have modified G-WAN to enforce using the www-data account if none is provided (like for sudo ./gwan or even for sudo ./gwan -d instead of sudo ./gwan -d:www-data). You may be the HTTP error "403: Access denied" for existing installation. Here is how to fix that.

We also have added a 'quit message' to inform users who press Ctrl+C in a terminal that G-WAN is exiting (a few "experts" reported that it looks like a server crash). Also, we log the last reboot time in gwan.log to help identifying the cause of downtimes (only a few hosting companies bother to tell you in advance when they will shut-down their racks).

The G-WAN license has been made even more permissive: now you can completely remove the "Server: G-WAN" HTTP response header – you just cannot modify the Server identification field to advertise a different server name.

G-WAN v5.1.27/Linux: Development Release


  • updated the ab.c benchmark tool
  • added SSL/TLS client-side (only) support
  • added PH7 (*.ph7) servlets support
  • added the init.c initialization script
  • added the REQUEST_URI CGI variable
  • added X_HTTP_HEADERS CGI variable
  • added CACHE_ALL_WWWfor get_env()
  • added USE_WWW_CACHEfor get_env()
  • added USE_CSP_CACHEfor get_env()
  • added USE_MINIFYINGfor get_env()
  • added checks for 32/64-bit library mismatch
  • added getStrEnv() for Java/Scala scripts
  • added getIntEnv() for Java/Scala scripts
  • added all HTTP status codes in gwan.h
  • enforced www-data to dump root privileges
  • added "Protocol Handler" example and manual
  • added the RC_NOCACHE return code for servlets
  • added SSL support to the xbuf_frulr() API call
  • added extra code for the detection of AMD CPU Cores
  • found workaround for the sleeping thread high CPU load
  • found workaround for the ghost 0:00 stop on some platforms
  • decorated G-WAN processes and threads with friendly names
  • added the HDL_BEFORE_CLOSE notification event for handlers
  • fixed the permissions of the newly created gwan/logs directory
  • fixed the count of the CPU Cores per CPU on multi-socket servers
  • fixed a Linux 32-bit ~100% CPU load raised for the sleeping thread
  • found workaround for the javac compiler removed from jdk/bin
  • fixed a misplaced #define blocking the download of files > 16 MiB
  • fixed two JS regex expression minifying issues (unquoted spaces and //)
  • fixed two other JS minifying issues ($-prefixed variables and C comments)
  • made the <code> tag act like the <pre> tag during daemon HTML minifying
  • fixed directory listings for folders with names containing dots and mime types
  • fixed a glitch appearing exclusively during huge file downloads (several gigabytes)

Thanks to Alain, Alberto, Akos, Aldo, Alex, Andre, Anders, Andy, Anja, Antoine, Antti, Arek, Aris, Badrus, Beat, Brennan, Bruno, Christian, Dan, Daniel, David, Dawid, Dorian, Dmitri, Eli, Ersun, Ervis, Erwan, Fatih, Ferhat, Fred, Garnet, Gerard, Gert, Griffin, Guy, Jay, Jerome, Jiri, Johannes, Johnnel, Ken, Kevin, Kin, Kiswono, Li, Leonardo, Marek, Matt, Maurits, Metin, Michael, Michal, Mohammed, Monica, Navin, Nikolai, Olivier, Paolo, Parth, Paul, Paulo, Peter, Petr, Philippe, Raymond, Remi, Reza, Richard, Rick, Rodney, Sam, Sahid, Shay, Simon, Stefan, Stephan, Steve, Steven, Tadeusz, Tao, Thomas, Tomas, Tim, Vuong, Whei and Zewei for their useful feedback.

Why so fewer releases in 2014?

We are often asked when the next G-WAN release will be published. We do our best at fixing platform issues (LIBC updates, etc.) to let people continue using G-WAN but G-WAN, as a freeware, will never represent a significant part of our revenues so, unless some users sponsor the features they are asking for (like they do for less-performing and security-issues-crippled open-source projects), our company has no choice but to focus on its own needs – the reason why we wrote G-WAN in the first place. And right now, this is our provably-secure G-WAN-based Cloud offer: