appserver

tech2022-09-02  119

appserver

After the release of the first part of our Appserver series, it was clear through the ensuing discussions on both SitePoint and Reddit that we had touched a nerve for a good number of PHP channel’s devoted readers. I also quickly realized this new (for PHP) technology had a good number of serious doubters. One of the most poignant responses in the discussions was something along the lines of,

在发布Appserver系列的第一部分之后 ,通过随后在SitePoint和Reddit上的讨论,很明显,我们已经为大量PHP渠道的忠实读者感到紧张 。 我也很快意识到,这种新的(用于PHP的)技术引起了很多严重的疑问。 讨论中最严厉的回应之一是,

“with the way pthreads works internally with PHP, appserver can never be as fast as a regular LEMP or even LAMP stack.”

“通过pthreads在PHP内部使用的方式,appserver永远不会像常规的LEMP甚至LAMP堆栈那样快。”

挑战 (The Challenge)

Needless to say, those doubtful and critical comments sounded like a real challenge. I was also very interested in finding out where appserver would land, if it were to be benchmarked against another well known PHP framework.

不用说,那些令人怀疑和批评的评论听起来像是一个真正的挑战。 我还非常想知道如果将应用服务器与另一个著名PHP框架进行基准测试,那么它将在哪里着陆。

I decided to use my favorite framework, Symfony, to make the comparison. This is because appserver, as a stock PHP application server, also offers a good bit of important application functionality similar to Symfony. These functions include a dependency injection container, a request and response object, a method for persistence, etc. In other words, it gives the developer the basics to build an MVC application, just like Symfony does.

我决定使用我最喜欢的框架Symfony进行比较。 这是因为appserver作为库存PHP应用程序服务器,还提供了许多与Symfony类似的重要应用程序功能。 这些功能包括依赖项注入容器,请求和响应对象,持久性方法等。换句话说,就像Symfony一样,它为开发人员提供了构建MVC应用程序的基础知识。

For those of you wondering what pthreads is, it is a PHP extension used in the core of appserver, which allows PHP to build a multi-threaded PHP server environment. If you aren’t sure what that means, or why it is at all relevant, please read the previous post.

对于那些想知道pthreads是什么的人, 它是 appserver核心中使用PHP扩展 ,它使PHP可以构建多线程PHP服务器环境。 如果您不确定这意味着什么,或者为什么根本不相关,请阅读上一篇文章 。

LEMP or LAMP stacks are the usual way PHP applications are served with Linux.

LEMP或LAMP堆栈是Linux上使用PHP应用程序的常用方法。

Linux, Nginx (EngineX), MySql and PHP -> LEMP

L inux,Nginx( E ngineX), M ySql和P HP-> LEMP

Linux, Apache, MySQL and PHP -> LAMP

L inux, A pache, M ySQL和P HP-> LAMP

该方法 (The Approach)

The basic idea of this post is to try to dispel the criticism about appserver performing poorly, or at least much worse than a framework like Symfony.

这篇文章的基本思想是试图消除对应用服务器性能差的批评,或者至少比像Symfony这样的框架差得多的批评。

The tests were run with simple programs, so we can see the overhead we’d find with standard programs built on top of a larger framework. I consider the overhead typical for any enterprise-grade, professional PHP application.

测试是通过简单的程序运行的,因此我们可以看到在大型框架之上构建的标准程序的开销。 我认为对于任何企业级专业PHP应用程序来说,这些开销都是典型的。

We will be testing for 3 types of responses.

我们将测试3种类型的响应。

A straight “Hello World” response. (Hello World page)

直接的“ Hello World”回应。 (Hello World页面) A response with no database access, but with dynamic templating (Login page) (Note: to make the test fair, I took out all the content on the login page of the Symfony demo login page, so the document lengths would be similar.

没有数据库访问权但具有动态模板的响应(“登录”页面)(注意:为了使测试公平,我取出了Symfony演示登录页面的登录页面上的所有内容,因此文档长度将相似。 A page with database access and templating (Content page) – Note: to also make this part a fair comparison, I added the content from the first page of Symfony’s blog list to the items list of the appserver demo app.

具有数据库访问权限和模板的页面(内容页面)–注意:为了使本部分更加合理,我将Symfony博客列表第一页的内容添加到了appserver演示应用程序的项目列表中。

Comparing it to Symfony was relatively easy, since Symfony can also be installed with a demo application. The appserver demo app isn’t a blog like Symfony’s, but rather a sort of to-do list kind of application. Again, I added the same content from the Symfony Blog posts index page into the “to-do” list index page, so the page sizes were approximately the same.

将它与Symfony进行比较相对容易,因为Symfony也可以与演示应用程序一起安装。 appserver演示应用程序不是Symfony的博客,而是一种待办事项列表应用程序。 再次,我将Symfony Blog帖子索引页面中的相同内容添加到“待办事项”列表索引页面中,因此页面大小大致相同。

Although I’ve read one shouldn’t use the Symfony demo for benchmarking, I see no real reason not to in this case. Both “demos” aren’t made for benchmarking really, so they both have the same disadvantages. And, in this little exercise, we want to see how appserver compares in relation to similar kinds of responses, be it dynamic content, hello world or a login page.

尽管我读过不应该使用Symfony演示进行基准测试,但我认为没有真正的理由不这样做。 这两个“演示”并非真正用于基准测试,因此它们都有相同的缺点。 并且,在这个小练习中,我们希望了解appserver如何与类似的响应(无论是动态内容,hello world还是登录页面)进行比较。

Funny enough, they both use Sqlite as the database and doctrine for database abstraction for their demo applications. So, as systems, they are very similar in this respect too.

有趣的是,他们都使用Sqlite作为数据库,并使用其理论为演示应用程序进行数据库抽象。 因此,作为系统,它们在这方面也非常相似。

设置 (The Setup)

I ran the tests on a 1GB standard VM on Rackspace, so the tests would be as neutral as possible.

我在Rackspace上的1GB标准VM上运行了测试,因此测试将尽可能保持中立。

The VM was created through Puphpet to build a Debian Wheezy LESP stack (LESP because we are using SQLite). I later installed Symfony and appserver manually. Since appserver’s webserver initially accepts requests through port 9080, it was easy to run both systems in parallel. Symfony is using php-fpm version 5.6.16 and appserver is using its own installed version of php-fpm version 5.6.15. I used PHP5.6 and not PHP7 with Symfony to keep the comparison fair between the two systems and for a proper apples to apples comparison. Appserver only comes with PHP5.6 currently; version 1.2.0 will be arriving with PHP7 some time towards the middle to end of this year.

该虚拟机是通过Puphpet创建的,用于构建Debian Wheezy LESP堆栈(LESP,因为我们使用的是SQLite)。 后来我手动安装了Symfony和appserver。 由于appserver的网络服务器最初通过端口9080接受请求,因此并行运行两个系统很容易。 Symfony使用php-fpm版本5.6.16,而appserver使用自己安装的php-fpm版本5.6.15。 我使用PHP5.6而非SymfonyPHP7来保持两个系统之间的比较公平,并进行正确的苹果与苹果比较。 目前,Appserver仅随附PHP5.6。 1.2.0版本将在今年中旬左右随PHP 7一起发布。

To test the two systems, I used Apache Bench, similar to the tests done in this PHP framework benchmark repository. I also ran a three second test with 10 concurrent users with only one difference. I used the “-k” keepalive option, which is a standard used for HTTP connections in all web browsers.

为了测试这两个系统,我使用了Apache Bench,类似于在此PHP框架基准测试资料库中进行的测试。 我还对10个并发用户进行了三秒钟的测试,但只有一个不同。 我使用了“ -k” keepalive选项,该选项是所有Web浏览器中用于HTTP连接的标准。

The main goal of the tests was to get the number of requests per second.

测试的主要目标是获得每秒的请求数。

I did not measure memory usage, as this measurement is not really comparable between Symfony’s standard PHP “shared nothing” and appserver’s threaded environments. That would be an apples to oranges comparison.

我没有测量内存使用情况,因为这种测量在Symfony的标准PHP“不共享任何内容”和appserver的线程环境之间没有真正的可比性。 那将是苹果与桔子的比较。

The only thing I did for optimization for both systems was carry out the official steps for deploying to a production environment.

我对两个系统进行优化的唯一方法是执行正式步骤以部署到生产环境。

结果 (The Results)

I’ve broken down the results into the three sets of responses, as mentioned above.

如上所述,我已将结果分为三组响应。

Symfony的Hello World页面 (Symfony’s Hello World page)

Symfony的登录页面 (Symfony’s Login page)

Symfony的内容页面 (Symfony’s Content page)

appserver的“ Hello World”页面 (appserver’s Hello World page)

appserver的登录页面 (appserver’s Login Page)

appserver的“内容”页面 (appserver’s Content page)

结果图 (Results Graph)

在Appserver上的Symfony (Symfony on appserver)

Just to see what would happen, I also installed Symfony onto appserver. Here are the results compared to the LESP (LEMP in the graphic) stack.

为了看看会发生什么,我还将Symfony安装到了appserver上。 这是与LESP(图中的LEMP)堆栈进行比较的结果。

结论 (Conclusion)

Looking at the appserver/Symfony vs. LEMP/Symfony results, I’d say the PHP webserver in appserver has additional overhead compared to Nginx. That is pretty much understandable. To be honest though, I would have also guessed a PHP based web server would do a whole lot worse compared to Nginx. So, with these results, I’d give a thumbs up to the dev team for doing a pretty good job with their pure PHP web server implementation.

查看appserver / Symfony与LEMP / Symfony的结果,我想说与Nginx相比,appserver中PHP Web服务器具有额外的开销。 这几乎是可以理解的。 不过,老实说,我还猜想与Nginx相比,基于PHP的Web服务器的性能要差得多。 因此,有了这些结果,我会向开发团队表示赞许,因为他们在纯PHP Web服务器实现方面做得很好。

As one can also see, once a SQLite database gets into the picture, it is certainly the bottleneck. Both slow down considerably when database requests to SQLite come up.

还可以看到,一旦SQLite数据库进入画面,那肯定是瓶颈。 当对SQLite的数据库请求出现时,两者都大大降低了速度。

For the login page, appserver wins out. To render the page, it uses dhtml templates. I’d say this might show the overhead Twig puts on Symfony, despite Twig’s caching of the templates.

对于登录页面,appserver胜出。 要渲染页面,它使用dhtml模板。 我想说,尽管Twig缓存了模板,但这可能显示Twig放在Symfony上的开销。

I would also venture to say that appserver’s slightly poorer hello world result lies within the PHP web server overhead, even though the results are actually quite similar, with Symfony only approximately 16% faster. Compared to Symfony on appserver, the results show appserver’s web server and application server combination do a good job overall in combination, to speed up processing.

我还要冒昧地说,尽管结果实际上非常相似,但appserver的hello world结果稍差于PHP Web服务器开销,而Symfony仅提高了约16%。 与appserver上的Symfony相比,结果显示appserver的Web服务器和应用程序服务器的组合在整体组合方面做得很好,可以加快处理速度。

I hope this short post will dispel some of the mistrust some people may have about the possible performance one can get out of their applications on appserver. The technology is quite new, but still very interesting, and as we can see, not really all that bad in terms of performance.

我希望这篇简短的文章可以消除一些人可能对人们无法从应用服务器上的应用程序获得的性能抱有的不信任感。 这项技术是相当新的,但仍然非常有趣,而且正如我们所看到的,就性能而言,并不是真的那么糟糕。

An important note: with these tests, we are not testing the real advantages or strengths of appserver. Once an application starts to get much larger, where a larger number of classes/ services needs to be constantly (re)loaded in the standard PHP environment, I believe appserver would start to do considerably better than Symfony. I’ll work on testing this aspect at a later date, as it is actually the real selling point for a threaded PHP environment.

重要说明:通过这些测试,我们并未测试Appserver的真正优势或优势。 一旦应用程序开始变得很大,需要在标准PHP环境中不断地(重新)加载大量的类/服务,我相信appserver的性能将比Symfony更好。 我将在稍后的日期进行测试,因为它实际上是线程化PHP环境的真正卖点。

Hopefully, some of you will be motivated to at least give appserver a spin. The results above should dispel any bad performance concerns, and the appserver platform can only improve over time, especially if a good number of developers use it and put it through its paces.

希望你们中的一些人至少能激励一下appserver。 上面的结果应该消除任何不良的性能问题,并且appserver平台只能随着时间的推移而改善,尤其是如果有大量的开发人员使用它并逐步进行开发的话。

In the next two posts, we’ll start to get our hands dirty and actually develop an appsever application. Stay tuned for more!

在接下来的两篇文章中,我们将开始动手,并实际开发一个appsever应用程序。 敬请期待更多!

翻译自: https://www.sitepoint.com/benchmarking-can-appserver-beat-symfonys-performance/

appserver

最新回复(0)