Server Side DATA Caching

WITH REDIS ( PHPREDIS ) 

Benefits of Caching

  • will improve the performance of the web site with much more speed in loading
What caching basically does is reduces the file I/O the number of roundtrips to the database
Note : You can only see a huge difference in load time when you have more requests 

Requests vs Response time


CPU UTILIZATION VS TIME


WhEN to CachE Data ?

  • You can always cache your when you have a dataset which is not updated or changed .
  • you can cache you data when you have a dataset which is not frequently updated or changed . 

Caching METHODS USED with PHP

  • Shared Memory
  • MemCached
  • MYSQL Memory Engine(if using mysql)
  • REDIS




PICKING A CACHING SOLUTION

Shared Memory


Shared memory - Shmop is an easy to use set of functions that allows PHP to read, write, create and delete Unix shared memory segments
Note : if you do a Google search it will always says that shared memory is faster than every other .But on my benchmarks it wasn't the case (I'm still trying to figure it out)

MemCACHED

Memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
This extension uses the libmemcached library to provide an API for communicating with memcached servers. It also provides a session handler (memcached).

MYSQL MEMORY ENGine

This is your usual mysql table except it has memory engine which stores your data in memory not in database(file). 

Note : this is not fast as shared memory or redis .

Redis

wiki says
Redis is an open-source, networked, in-memory, key-value data store with optional durability


REdis clients

Redis has clients written for many programming languages such as  C# , PHP ,JAVA , PERL , NODE JS  ETC .

your can view the clients @ http://redis.io/clients

REDIS PHP clients

  • Predis
  • Phpredis
  • Rediska
  • RedisServer
  • Redisent
  • Credis
Note : Phpredis and predis are the most popular clients . Having said that phpredis is the fastest since its written in c 

HOW to setup redis 


DEMO using phpredis

will update this soon
Made with Slides.com