So now that we have concluded that it's easy to setup distribution of files on a separate subdomain, what about using a completely other web server (or in this case an application server)? Will it blend?
In the last post I wrote a little bit about subdomains and how to create cookieless requests headers. Now I will write a little bit about using an extra application for serving the static files. Varnish is known and is well documented online, so I have done some testing instead on a product called G-WAN.
G-WAN is not a web server (like Nginx) or a reverse-proxy/http accelerator (like Varnish/Squid), but rather a application server that also is know for serving static files increndibly fast.
First off G-WAN is not open-source, but it is freeware, so you are free to use it for free as it comes. The problem I and many have with this is that it does not live up to the thought that many-eyes fixes bugs. They have an answer on their website for this specific question that you can read here.
Secondly, be aware that for these test I have a long experience working with Nginx, while this is the first time working with G-WAN. On the other hand G-WAN is configless so how it's not much of the setup I can mess up :)
It's really a walk in the park to setup. Unzip a file, run a shell file. That's it.
There does not exist a configuration file, the configuration is done by the file structure. With this you can control virtual hosts, host aliases, ports etc. It's a really strange solution (for me), but on the other hand very simple.
I setup the files as an soft symlink pointing from my Drupal installation towards the directory structure of G-WAN.
For the test I will use the same server, so I will put the files on another port - in this case 8080. I set that up with the CDN module and with that done it works!
There are still some problems that exists that I will have to think about and that is static files that are run through a reverse proxy when they do not exists. Examples of this is imagestyle images or advagg JS and CSS. As far as I know and according to an answer here reverse-proxying or something like try_files in Nginx does not exist.
So if you want to use G-WAN you have to think things through what can be an can't be cached and set that up correctly in the CDN module. With imagestyle for instnace you can use ImageInfo Cache to solve that problem. Another solution of course is to set for instance Nginx as a reverse-proxy in front of G-WAN, but that does not really make sense since it will spawn workers etc.
So I will do this benchmark to measure a Nginx setup with all the goodies (sendfile, tcp_nodelay, tcp_nopush, mixing with some buttons) against G-WAN with all it's reputation. I will do two tests. The machine is a 1 core, 2 GB Podnix Cloud Server.
The first test will be to run AB with 1000 requests externally against the same file to check speed, the other test will be to run JMeter against the first page with all it's JS/CSS/Images with 300 concurrent users during during a 1 minute warmup to see how it scales (The local test machine could not handle more). The base html page is always served via Nginx and Memcache.
In no way do I claim that these test will be similar to a real-life website, but it will at least give some knowledge as to if any of the two solutions totally outperforms the other. If I understand correctly as well G-WAN handles better with more cores, such a test might happen later.
The client running the test is on a 100 Mbit line so it should handle the network traffic without any problem, the same for the server that is on a 1 Gbit line. Note though that things like slower network would occur in real-life examples, and since they can for instance eat workers on a persistant connection (stay-alive), this is something that will not be seen in this test.
The AB test is made with Gzip compression and with or without keep-alive.
I also reran all these test at three different times of day to minimize the effects of sudden network lag. But all three tests gave similar results.
Nginx serves both the fastest files faster and the slowest files faster.
They seems to follow the same pattern except for the last 10% where Nginx is much slower.
Average: 61.703 s
Min: 2.894 s
Max: 131.234 s
Error: Premature end of Content-Length delimited message body on one image file.
Average: 8.487 s
Min: 1.886 s
Max: 42.084 s
I reran this multiple times with the same results and at one test G-WAN gave over 30% error rate with images timing out. Nginx always had 0% error rate and was always giving back average to good results.
To be honest I will not make too much of this test - as I wrote I have no earlier knowledge of working with G-WAN.
I will retest this at a later time on Podnix largest machines when I have read more about G-WAN as well to see if I can improve the scores for G-WAN.
From what I have read about G-WAN it should give much better results then what can be found in my test, so do not read in too much into it. I at least proved that you can use G-WAN as a static file server for Drupal, but I pretty much knew that beforehand.
The photo above is taken from the awesome show Will it Blend.