Speeding up session handling
Native session handling in PHP is fine in most cases. There are at least two possible reasons why you will want to change the way sessions are handled:
When using multiple servers, you need to have a common session storage for both servers.
Default PHP sessions use files, so the maximum performance possible is limited by disk I/O.
By default PHP sessions are locking files. That results in blocking concurrent requests.
In this recipe, we will see how to use an efficient storage for Yii sessions.
Getting ready
Generate a fresh Yii application using
yiic webapp.You should have the
php_apcandphp_memcacheextensions installed, as well asmemcacheditself to follow this recipe.
How to do it...
We will stress test the website by using the Apache
abtool. It is being distributed with Apache binaries, so if you are using Apache, you will find it inside thebindirectory. Run the following command, replacingyour.websitewith the actual hostname you are using:ab -n 1000 -c...