Performance of Yii

Yii is a high-performance framework. The graph and table below show how efficient Yii is when compared with other popular PHP frameworks. In the graph, RPS stands for "request per second" which describes how many requests an application written in a framework can process per second; and APC is a widely used PHP extension that caches intermediate PHP code and thus eliminates the loading and parsing time for PHP code. The comparison aims to reveal the maximum RPS that each framework can obtain. The higher the number, the less overhead a framework has.

As we can see that Yii outperforms all other frameworks in the comparison. The advantage is especially significant when yiilite.php is used as the Yii bootstrap file. Yiilite is an optimized bootstrap file that is included in the Yii framework mainly for production use.

Performance alone is not the whole story (otherwise we should all use plain HTML as it is the fastest). With such a superior performance, Yii still provides an easy-to-use and highly extensible feature set that is richer than most other frameworks.

Performance Comparison Among PHP Frameworks

Benchmark Setup

The RPS numbers were obtained using the ApacheBench tool with the command "ab -t 30 -c 10 URL" (i.e., at currency level 10 running the test for 30 seconds). To get each number, we first stop and then start the Apache Web server to avoid interference.

The testing environment is as follows:

The APC ini settings are as follows:

apc.enabled=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=32
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1
apc.cache_by_default=1

Benchmark Applications

A benchmark application is written for each framework. Each application simply tries to display a string "hello world". Any additional framework features are disabled to ensure fairness of the comparison. You may check out the complete benchmark applications to verify.

The goal of this benchmarking is to reveal the RPS upper limit (or the minimal overhead) of each framework without using any additional server caching techniques. Therefore, each application is written such that a single die('hello world'); statement is placed in the default controller action of each application. We do not invoke the complete view rendering logic of each framework because that will be slower and will not give us the RPS upper limit. As a matter of fact, for actions responding to AJAX requests, complete view rendering logic is seldom used.