Final Replace: Dec 31, 2022
So final week I confirmed tips on how to arrange an internet server on the Raspberry Pi. Many individuals identified that Apache in all probability isn’t the best choice for the Pi. So I made a decision to do some pace check to see which server could be the quickest in the event you have been going to construct a Raspberry Pi Webserver. It is a good method to evaluate how every server will run on low powered {hardware}.
The Check
For the check surroundings, I setup my Pi on a non-public community related solely to laptop computer by a router. There isn’t any different site visitors on this community so I knew connection points wouldn’t play a component in it. I attempted to remove as many variables as I may together with rebooting the pi and letting it quiet down between runs.
One other factor to notice: these are all default installations so we’re testing it proper out of the field.
For the check I used Siege 2.68 as it’s a useful gizmo for any such testing. For my check I solely needed to give attention to static content material, corresponding to textual content and pictures. I’ll do a check with PHP sooner or later however I didn’t wish to introduce that variable simply but and stick to what the net server is meant to do, which is serve content material.
Check Content material
For this experiment I actually needed to swamp this factor. So I created 4 completely different pages for exams.
- Small Textual content Check – html web page 177 bytes (small, fast transactions)
- Giant Textual content Check – html web page 95,881 bytes (massive, lengthy transactions)
- Small Picture Check – Small PNG load (849 bytes)
- Giant Picture Check – Giant JPG load (179,000)
I then ran these exams with 200 concurrent connections for 2 minutes at full blast utilizing the next check:
siege -b -t2m -c200 192.168.1.100 [filename]
I examined the next software program:
- Apache
- Nginx
- Monkey HTTP
- Lighttpd
I ran all of them out of the field from the default settings, put in from apt-get, apart from Monkey HTTP which was compiled from supply.
Let’s see which server is the quickest!
Small Textual content Transactions
The primary check reveals what number of transactions came about throughout our 2 minute check. It is a good indicator of pace as a result of if the server is struggling, it received’t course of requests. I ran each 100 concurrent connections and one other set of exams at 200.
Server | ||
---|---|---|
Apache | 26724 | 26624 |
Lighttpd | 32963 | 31807 |
Monkey | 39423 | 39310 |
Nginx | 40391 | 39449 |
As you possibly can see, Monkey and Nginx are just about neck and neck, and significantly above Apache. Those that appear to deal with the bounce in connections greatest are Monkey and Apache.
Winner: Nginx, however Monkey may be very shut and appears to scale higher.
Giant Textual content Transactions
Right here now we have a pretty big HTML file filled with textual content, so the numbers change drastically. Listed here are our outcomes:
Server | ||
---|---|---|
Apache | 698 | 152 |
Lighttpd | 625 | 563 |
Monkey | 2060 | 2007 |
Nginx | 3912 | 3886 |
We count on these numbers to be a bit decrease however what’s most stunning is the hit that Apache and Lighttpd take. Nginx is the clear winner right here, however Monkey at the least makes a very good effort.
At 152 transactions, it’s clear to see Apache is choking at this level. Some additional configuration would change this, however out of the field it actually struggles with this check.
Winner: Nginx
###Small PNG Transfers
This check was created to see how every server would deal with very tiny recordsdata. For this check we use a tiny PNG file (849 bytes). Listed here are the outcomes:
Server | ||
---|---|---|
Apache | 32275 | 32840 |
Lighttpd | 40838 | 41497 |
Monkey | 51130 | 51065 |
Nginx | 44461 | 45010 |
Monkey is the clear winner right here in each throughput and scalability. The distinction between 100 and 200 concurrent connections is subsequent to nothing. What does that let you know about the way it’s scaling?
Winner: Monkey
Giant JPG Transfers
This check makes use of a big JPG (178k) and these outcomes present a drastic distinction when extra connections are added.
Server | ||
---|---|---|
Apache | 1467 | 1390 |
Lighttpd | 1503 | 1357 |
Monkey | 1442 | 1338 |
Nginx | 1451 | 1396 |
Right here we see Apache beginning to pull forward extra, however Lighttpd wins the spherical at 100 concurrent whereas Nginx ekes out a marginal victory at 200.
Winner – Lighttpd @ 100, Nginx @ 200
Availability
This check is an excellent indicator of general efficiency. If the net server is actively refusing connections it’s a transparent signal it’s overloaded.
At 100 concurrent connections, all of them do pretty properly:
small textual content | massive textual content | small png | massive jpg | |
---|---|---|---|---|
Apache | 100 | 100 | 100 | 98.39 |
Lighttpd | 100 | 100 | 100 | 99.93 |
Monkey | 100 | 99.95 | 100 | 99.65 |
Nginx | 100 | 100 | 100 | 97.55 |
The values listed here are percentages out there. All of them do pretty properly although Nginx takes a noticeable drop when dealing with the big JPG file.
That very same check with 200 concurrent connections reveals a bit extra variance.
small textual content | massive textual content | small png | massive jpg | |
---|---|---|---|---|
Apache | 99.98 | 21.53 | 100 | 98.39 |
Lighttpd | 99.95 | 100 | 99.93 | 99.41 |
Monkey | 99.88 | 98.87 | 99.97 | 98.60 |
Nginx | 99.89 | 98.38 | 99.92 | 97.55 |
It’s a bit onerous to see the variations as a result of Apache takes a nostril dive with the big textual content. This isn’t a fluke, I attempted a number of completely different runs and Apache refused connections fairly incessantly. I think a easy config change (extra servers) will repair this.
Winner: Lighttpd
Knowledge Transferred
As I acknowledged earlier the possibilities of your web site getting 200 connections is fairly uncommon for many websites and in the event you have been working at that stage you actually wouldn’t be utilizing a Raspberry Pi as your server. That is merely a hacking train to point out how these servers deal with the load on this smaller {hardware}.
This check will present how a lot knowledge was transferred throughout our testing. These outcomes are fairly attention-grabbing:
The winner within the small textual content enviornment is fairly shut, however within the massive textual content, you see Monkey actually takes it away:
Monkey actually shines in terms of pushing out massive quantities of textual content. One thing to remember.
Right here we present massive JPG switch knowledge. The small PNG throughput was not picked up by Siege, so we aren’t capable of finding something from that.
This one was a bit stunning. At 100 concurrent connections Lighttpd takes it by an extended shot, however at 200 concurrent connections Apache actually pulls by. The rationale that is stunning is as a result of in previous exams we’ve seen the place Apache chokes, so the truth that it nonetheless delivers a lot knowledge when it’s related is an effective signal.
Winner: Monkey for Textual content, Apache for Photographs
Response Time: Textual content
It is a essential check, as a result of it reveals how properly the server is responding to requests. A sluggish response time means it’s getting overloaded so this reveals how properly the servers carry out underneath stress.
Listed here are outcomes we’ve come to count on at this level. Nginx and Monkey do very properly, particularly at 100 concurrent customers. However even underneath a heavy load they maintain their instances low whereas Apache chokes.
Utilizing some bigger textual content, we verify what we already know:
Nginx and Monkey each love massive quantities of textual content.
Winner: Nginx
Response Time: Small Photographs
The response time on this check is fairly necessary as a result of the servers have been being bombarded with requests for small photographs. If this appears like one thing that occurs quite a bit, you’d be proper. Often if you’re coping with massive photographs it’s just a few, however many small picture requests are an on a regular basis factor to your web site.
Right here we see Monkey as soon as once more doing nice, and Nginx not far behind. That is in keeping with lots of our different exams. However how about massive photographs?
That is the primary time we actually see all of the servers so shut to one another. Clearly all of them wrestle with quick responses with massive photographs, however on this case lighttpd appears to do one of the best.
Winner: I’m going to say Monkey, as a result of smaller photographs are extra incessantly discovered and it does pretty properly with massive photographs anyway.
Concurrency
This check reveals what number of concurrent customers we have been truly capable of obtain. The outcomes aren’t stunning:
All of them appear to deal with small quantities of textual content simply advantageous, however at massive quantities, as soon as once more Apache chokes.
The identical check for photographs tells a distinct story:
Right here we see that general Apache outperforms the others in each small and huge photographs. It will appear that for stability and consistency Apache does properly with photographs.
Winner: Apache
Failed Transactions
This is a vital metric;we wish to know what number of instances the server failed throughout our check. Right here’s a pattern for our massive HTML and JPG exams:
Ouch. I re-ran this check a number of instances and it all the time got here out like this. Merely put: Apache in it’s default state doesn’t like massive chunks of textual content. The opposite servers just do advantageous.
Winner: Lighttpd
Abstract
Winner: Nginx
Total I feel the quickest and most dependable answer is Nginx. I solely say this as a result of it’s extra mature than Monkey and has some stability going for it. Monkey nonetheless is catching up quick. There appears to be loads of enthusiasm for the venture and as you possibly can see by these exams it does very properly particularly with textual content.
Within the picture enviornment Apache nonetheless appears to dominate. I’m unsure why that’s, nevertheless it clearly handles this perform very properly. With some tuning you can also make Apache deal with textual content properly too, however I nonetheless assume it’s a product that’s previous its prime. If I needed to advocate something it could be Nginx, however quickly I could also be altering that relying on how Monkey progresses.
I might love to listen to your suggestions on these exams, and in the event you’d prefer to attempt exams of your individual, seize a duplicate of siege and get going. For the following venture like this I’ll possible be performing some tuning on every of those servers to see what sort of numbers we get then. When you’ve got any concepts, ship them my manner!
Wish to be taught extra concerning the Raspberry Pi? Take a look at the Raspberry Pi for Builders course!
GIPHY App Key not set. Please check settings