Sunday, January 27, 2013

php performace with memecache

Another setting that you can tweak for optimization is to use a different storage
mechanism for session data; in this case memcached. Memcached is a memorybased,
cluster-friendly key-value store. If you enable the memcache extension
(ext/memcache), you’ll be able to automatically use memcached for session storage
instead of the disk:


Install
$ pecl install memcache # Install ext/memcache
$ memcached –d –m 128 # Start memcached

Settings

session.save_handler = "memcache"
session.save_path = "tcp://localhost:11211"Table 6.1. Performance Figures with and without Memcached

StorageType               AverageResponse  MinimumResponse Maximum Response  Requests per Second
File-based                    836                             98                       7106                        23
MySQL-based             798                            103                      1848                          24
Memcached-based        771                            86                        1473                        25



Memcached is a networked daemon that can easily be spread across multiple servers.
In this case, multiple web servers can use it as a central store for their sessions. This
makes load balancing much easier; all sessions can easily be accessed from all web
servers in a cluster, without the overhead of a central RDBMS (relational database
management system).
As the number of sessions grows, memcached will scale far better.

No comments:

Post a Comment