In the post we will focus on testing 6 operating systems as a web server. The axes are as follows: Debian, FreeBSD, CentOS, openSUSE, Ubuntu, and for the fun of Windows 2008 R2 Standard. Why such, I will explain below. Software - standard set: Apache2, MySQL5, PHP5 (hereinafter referred to as AMP).
I work in a web studio, we have several cloud servers on Selectel, they all work on Debian. But why him? I do not know, perhaps, this axis is more popular, and initially the experience was only with it. Now there is a need for another cloud server and a local server. This situation prompted me to test for speed and resource requirements. Maybe there is something better?
Description of tests. All operating systems were installed in VirtualBox, Firefox was used as a client on the host axis. All 32-bit operating systems installed the latest stable version of the "out of the box", without tuning. The versions of AMP are approximately the same, the latest versions were installed by standard package managers (linux), from ports (bsd) and win32 versions for Windows (it is x64 itself). I didn’t use all my own standard tests, I was interested in making them myself, I hope you will like them. Each test was performed 5 times, only average values are given.
')
I come back to the question why these axes were chosen. But because of the selected Linux Selectel has been offering them, I have been looking at FreeBSD for a long time, I can install it on a local server, and I added Windows just for comparison, nothing more. Can someone say that all Linux work the same way? But no, go to testing.
Comprehensive tests
The most interesting, in my opinion, tests. Wordpress is installed on the server, 5 standard windows-pictures are uploaded to the first post through admin panel.
Then the js-code is added to the page footer, which reloads the page by window.onload. The essence of the test is to calculate the load time of 50 pages. Rebooting occurs in 2 options: location.href = '/' and location.reload (true). When we set the forceGet parameter to true, the browser reloads all the resources on the page (pictures, styles, scripts). Test via file_get_contents: on the OS host, a php script is executed that loads 50 pages from the machine under test using the file_get_contents function.
Here and further on the histograms the unit of measurement is seconds, respectively, the smaller the better.
For all tests, I’ll give 2 histograms each: for the results with 128 MB of RAM, and with 256 MB. I did this because, as it turned out, not all operating systems had 128 MB for servicing 1 client. For example, CentOS generally hung at the option via file_fet_contents (the real figure is not 160 seconds, but infinity, I did not wait for the test to finish). In the appendage to the tests with 128 MB added the results of the work of the monster of the modern "integration" Windows 2008 R2. He made the size of RAM 512 MB and did not change.
As you can see, everything is roughly aligned, however, CentOS again failed in test with reload: 2 tests completed in 13-15 seconds, and the remaining 3 rolled down to 20-21.
In this test, the winners were FreeBSD and Ubuntu, easily coping with the load and at 128 MB.
Database Tests
In this section, 2 test: write and read.
Record. From a piece of text we form a random text (its length is constant) and write the text into the database. A wp_posts table was taken. Operations are repeated 5,000 times.
PHP test code$lib = "bla bla bla"; $q = "delete from wp_posts where id > 10"; mysql_query($q); for ($j = 0; $j < 5000; $j++) { $content = ""; for ($i = 0; $i < 100; $i++) { $start = rand(0, strlen($lib)); $content .= substr($lib, $start, 15); } $content = mysql_escape_string($content); $start = rand(0, strlen($lib)); $title = substr($lib, $start, 15); $title = mysql_escape_string($title); $q = " insert into wp_posts set post_content = '$content', post_title = '$title', … "; mysql_query($q); }
Reading. The wp_posts table contains 300 posts previously generated. The test is to sample 50 random posts. Each post is selected by a separate query to the database.
PHP test code for($i=0;$i<50;$i++){ $q = "select * from wp_posts where id = (select id from wp_posts t order by rand() limit 1)"; $r = mysql_query($q); $ar = mysql_fetch_assoc($r); }
Result with 128 mb. Check out openSUSE and Ubuntu: write speed is very slow. I tried to find out the reason: I compared MySQL configs on Debian and Ubuntu, they turned out to be absolutely identical. I decided to look at the file system: on Debian ext3, on Ubuntu ext4, but on CentOS again ext4. It's not about the file system. It turned out that MySQL 5.5.xx was installed on openSUSE and Ubuntu, and on all the rest 5.1.xx.
Almost everyone worked a little faster. I would like to note that the results are fairly accurate, the error is about 0.05 seconds. In these tests, the winner could not be identified, the results are about the same, not counting the results of the entries in MySQL 5.5. Nevertheless we will define nominal winners: Record CentOS, reading openSUSE.
Total
Summing up, I will give a table of rankings for each test.
So, in the 128MB version, Ubuntu won, although FreeBSD, judging by the relative numbers, also looked very good. In the 256MB version, FreeBSD wins, OpenSUSE and Ubuntu are also doing great.
PS
I made my choice: FreeBSD to the local server, Ubuntu to the cloud (although, probably, it is preferable to use the same OS and software everywhere). I hope I did not give birth to eternal holivars with my post, which is better, which is worse. I repeat, everything was set out of the box, as it is. Perhaps if you do tuning, the leaders will change.
Pps
I will say a few words about the features / convenience of the tested systems.
FreeBSD was not as difficult as it always seemed to me. After some experience with Linux, I had no problems. The big difference in the way software is installed is ports and compilation from source.
CentOS impressed me by not wanting to be installed on a machine with less than 512 MB of RAM, so I had to increase it for installation. In general, CentOS seemed to me very easy to use, like Ubuntu or Debian.
OpenSUSE - I did not immediately find the installation option as a server (without X). Speaking about this axis, it is impossible not to mention Yast. This is a cool utility, in addition to being a package manager, you can configure almost everything through it (I set up a firewall, opened port 80). Yast even in console mode is displayed as a graphical interface, with menus, buttons, lists, etc. Very interesting, I liked it.
Ubuntu is an example of ease of installation. I didn’t even have to install AMP, when installing, the system itself asks which software to install on the server: sshd, web server, smbd, I didn’t remember anything else.
By the way, as a result of the manipulations, I was born 5 manuals for installing and configuring AMP on all of the above systems (except Win). I can share.