As we are taking a short break from working on Peachpie due to other obligations, not much progress has been made on the project itself. We would, however, like to touch on a very important aspect of getting the maximum out of your applications: choosing the right web server.
What’s new with Peachpie
Before we get into the topic of this article, we would like to offer a quick update on Peachpie itself. The last three weeks have been rather slow on our GitHub repository, which is caused by a wide array of different obligations we had to attend to. Unfortunately, this means that our plans to run a basic version of WordPress as a compiled application on .NET shift back by about a month, but we are still perfectly on track to achieve this milestone before the year ends.
While there have not been many commits to our repository, there has been some new content about Peachpie compiler last week. After making two appearances on Microsoft’s livecast “On .NET” on Channel 9, we were invited to the legendary podcast .NET Rocks with Carl Franklin and Richard Campbell. In the more light-hearted interview, we went through some of the objectives of the project, recent performance benchmarks and shared our plans to run a compiled WordPress on .NET.
So what are our immediate plans? We will still have some obligations that prevent us from working on Peachpie in the next 10 days or so, but afterwards we can focus our energy on the project again. We will be plugging along our roadmap towards running WordPress on .NET.
The most popular web servers
When talking about web servers, one needs to distinguish between the physical or virtual server that hosts applications and the software that actually delivers the content to the user. The physical infrastructure can be quite complex and even a mix of physical and virtual servers, whereas the software one would use depends on the individual’s preference. Microsoft-oriented firms will still prefer the traditional Internet Information Server (IIS), while Linux distributions allow for a whole host of alternatives, such as Apache, Nginx and LiteSpeed. The global usage of web servers on websites as of October 2016 looks as follows:
- Apache: 51.7%
- Nginx: 31.0%
- IIS: 12.0%
- Litespeed: 2.3%
While IIS and Apache have traditionally been the big two, the emergence and rapid ascent of Nginx over the last years has been remarkable. While the somewhat dated IIS has been on the decline for quite some time now, the development over the last 5 years shows that even the highly popular Apache has been losing grounds to Nginx:
As the July 2016 web server survey by Netcraft shows, Nginx is closing in on the 30% market share, while Apache is down to 43%. With the growing popularity of Nginx and the options of IIS and Apache, let us take a look at how to decide which choice is best.
Choosing the right web server
Obviously, the choice is very specific to the application and its use, but there are a few criteria to consider. In general, we can group the options into the heavy-lifting web servers – IIS and Apache – and the lightweights, like Nginx or Litettpd.
Apache is the center of the so-called LAMP stack (Linux, Apache, MySQL, PHP/Python/Perl), which is one of the most popular server architectures. The IIS is still the top choice for many Fortune 1000 companies due to its long-standing tradition and reliability. Its Active Server Pages (ASP) enables developers to embed code into HTML pages, which are then parsed by the server, and Microsoft has been quite good about making PHP work on the IIS more effectively over the last years.
The open-source Nginx web server has been gaining momentum and is already used by many popular companies (e.g. Hulu) for its stability and simple configuration. The most compelling reason, however, is that Nginx has an outstandingly small memory footprint and low resource consumption.
The decision on which web server to use can be made base on the following criteria:
- Support options
Let us look at the performance in a little more detail. We didn’t make the benchmark ourselves, but used an existing comparison from this source. Using ApacheBench, 25,000 requests were made for a 5k PNG file. Two key metrics were examined: memory usage and requests per second.
As the results clearly indicate, it is no surprise that Nginx and Lighttpd use significantly less memory, but Nginx is also very performant.
We have previously talked about ASP.NET Core, which is essentially a lightweight version of ASP.NET. Together with the open-source Kestrel web server, ASP.NET Core can be a very efficient alternative to Nginx. We are looking to produce a number of benchmarks over the next couple of months for PHP applications running on ASP.NET Core thanks to Peachpie.
What does this mean for Peachpie?
Above all, Peachpie will work on any technology stack and any web server. We will not be limited by a particular technology and we can simply use whichever configuration suits a particular application best. Secondly, once Peachpie will run on a lightweight web server, the performance gains compared to the classic LAMP stack can be quite considerable. This, of course, does not mean that this will become an all-purpose stack for any use; there will still be plenty of applications that would be better suited for a different web server.