Running PHP on Microsoft Azure with Peachpie

As announced in the last blog post, there has been some major progress in the development of the Peachpie platform over the last couple of weeks. Peachpie is now capable of running compiled PHP applications on IIS and on the Microsoft Azure cloud.

Introduction

Azure is Microsoft’s cloud computing platform and infrastructure - one of the leading IaaS products in the world. It offers an incredibly thorough and powerful UI in the form of a dashboard to build, deploy and manage applications and services on the Microsoft cloud.

While Azure is obviously capable of running PHP applications already, there is still room for improvement as the benchmarks below will clearly demonstrate. Peachpie compiler is a technology whose objective is to bridge the gap between the PHP and .NET platforms and to plug the leaks in the deployment of PHP apps on a web server.

Benefits of Peachpie

There are three key aspects that Peachpie focuses on in terms of the cloud: PerformanceSecurity and Throughput.

  1. Performance: if you have been following our blog posts, you can clearly register the impressive improvements in the performance of PHP 7 compared to PHP 5.6. All of our microbenchmarks have shown that PHP 7 has been optimized to the very edge of what the language’s architecture permits. By definition, however, there are many constructs and functionalities where .NET will always be more performant. Peachpie is there to allow PHP apps to get as close as possible to the performance level of .NET.
  2. Security: There are a few distinct advantages of the .NET framework, which Peachpie allows PHP applications to benefit from. The fact that the code is managed and safely compiled means no memory leaks, and the sourceless distribution implies that the web cannot be attacked the way a PHP site can. Administrators can specify the method-level security in .NET, and the extended administration section and statistics further allow the user to identify weak points at early stages.
  3. Throughput: Peachpie is running as a request handler in the context of the ASP.NET Integrated Pipeline and its worker processes. Requests are running as native threads instead of a Fast-CGI process pool. This model provides strict DDoS settings right in the Microsoft IIS console and allows for a maximum reuse of server resources.

Aside from Microsoft Azure, Peachpie will also work on any other web server with an ASP.NET Integrated Pipeline (Apache with mod_mono, IIS 7 and newer etc.).

Benchmarks

We have created a free One-CPU test web app on our Azure to demonstrate the difference between PHP and Peachpie. Therefore, the test configuration is one of the most basic server types Microsoft Azure offers, and just one instance was set up, one CPU and a 64bit worker process. Our Microsoft BizPark subscription comes with the Standard: 1 Small pricing tier:

Capture

We made use of the standard Performance Test within the Azure Web Applications Tools. We set up 1000 concurrent users constantly requesting our sample script for a period of one minute.

Sample script:

Results

We ran the benchmarks multiple times and PHP yielded different results each time. In some of the runs it started crashing frequently, resulting in 1 – 25 % of failed requests. We believe the failed requests can be attributed to server timeouts, at least in some instances. In any case, Peachpie had a 100% success rate across all attempts.

Performance test running Peachpie, 1000 concurrent users for period of one minute:

peach_dog_1000

Performance test running PHP7, 1000 concurrent users for period of one minute:

php7_dog_1000

Performance test results on Azure, for both PHP7 and Peachpie running, under concurrent 1000 users benchmark:

Performance test results on Azure, for both PHP7 and Peachpie running, under concurrent 1000 users benchmark.

Results Summary

As can be seen from the graphs above, the Peachpie-powered sample script was able to serve 2756 requests successfully as opposed to the 202 of PHP 7. The average response time was 16.94 seconds for a rate of 45.93 requests/second. PHP 7 yielded a response time of 30.73 seconds and a rate of 2.69 requests/second.

The chart below is interactive; you can hide a metric by clicking on the respective category at the top:


Want to try it out yourself?

You can easily replicate our benchmarks and try running Peachpie on Microsoft Azure yourself. Just check out our Getting Started section on GitHub and follow the four simple steps.

Stay informed about our progress on our GitHub repo by following us on Twitter or Facebook.