The sys admin's daily grind – Gatling
Apache Under Fire
Western aficionados and sys admin Charly are about to set up a Gatling in a field that is normally home to Apache. Read on to discover why blogger Fefe is to blame.
I admit to watching (too) many westerns as a child; in other words, I'm fully aware of what a Gatling gun is: an automatic weapon with multiple rotating barrels. In old movies, soldiers used its infernal din to send the horses of attacking Apaches galloping mad. And, this always worked until an Apache warrior crept up from behind and torched the ammunition chest.
As a rapid fire weapon, the Gatling lends its name to the web server I will be looking at today. The server's binary file is a lightweight compared with its name giver, weighing in at just 100KB. Its RAM requirements are minimal, too, because Gatling [1] does not fork. On an old PC, Gatling is just as fast as on my Raspberry Pi. The daemon is even included with the plain vanilla Raspbian distribution.
The server is designed for delivering static web pages as quickly as possible. To allow this to happen, its programmer, Felix "Fefe" von Leitner, whose widely read blog [2] naturally also runs on Gatling, gave the server just as many features as the number of shells you could slot into a revolver (IPv6, TLS/SSL, simply equipped virtual hosts, login via the .htaccess
mechanism).
If you want this tool, you need to build it from the source code, but before doing so, remember to install the IO-API library [3], which was also implemented by Fefe. Launched without any parameters, Gatling serves up the data from the current directory, but you can home in on a target like this:
gatling -u nobody -c /var/www
After Gatling has shot its way out of port 80, it drops its root privileges and continues running with the "nobody" account – which is also the name of a character played by actor Terence Hill 42 years ago [4]. The chroot
parameter -c /var/www
helps the sheriff bundle off the data into the county jail. And, -A number
fends off mass attacks by telling Gatling to restrict the number of HTTP requests per minute and client.
This Is the End of the Line, Django!
The log format is exotic (Figure 1), but it does help you understand the timing. An HTTP connection times out after a nerdy 23 seconds (last line). I tend to change this timeout value to 10 or fewer seconds using the -T seconds
paragraph, to release the sockets as quickly as possible. The reason for this change is that I tend to run Gatling on the front line, where access attempts are like a heavy barrage. The web server responds with static HTML, for example, when a server farm enters a maintenance window ("Please try again later") or in the case of blogs that are churned out by static site generators.
Gatling even offers a simple FTP server (which you can disable with the -F
switch). And, if you allow general access to the FTP directory, users can upload files. Conversely, you can only download files that you are allowed to read.
Backed up by a Gatling, "Nobody" can relax and coolly ride off into the sunset as the closing credits roll by.
Infos
- Gatling: http://www.fefe.de/gatling/
- Fefe's blog: http://blog.fefe.de (in German)
- Libowfat: http://www.fefe.de/libowfat/
- My Name is Nobody: https://en.wikipedia.org/wiki/My_Name_Is_Nobody
Buy this article as PDF
(incl. VAT)