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 common session storage for both servers.
Default PHP sessions use files, so the maximum performance possible is limited by disk I/O.
Default PHP sessions are blocking concurrent session storages. In this recipe, we will see how to use efficient storage for Yii sessions.
Getting ready
Create a new yii2-app-basic
application using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html, and install the Memcache server and the memcache
PHP extension.
How to do it…
We will stress-test the website using the Apache ab
tool. It is distributed with Apache binaries, so if you are using Apache, you will find it inside the bin
directory.
Run the following command replacing your website with the actual hostname...