Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: tmpfs vs memcached

Tags:

php

memcached

I want to store information (sessions and a lot of strings) in RAM and I don't know if I should use a tmpfs or a memcached server. Someone did some benchmark and knows which one is faster? It's needed for some ajax scripts that requests informations every 1-5 seconds per user who is logged in, like a webchat in PHP. So PHP has to connect to memcache quite often.

The advantage of using tmpfs whould be that I can create a lot of files and have a structur (dirs), while I only have a key-value system in memcached, but there i could use arrays or objects to store information. CPU load whould be interesting, too, if there is any difference.

Thanks.

like image 256
D.Unknown Avatar asked Mar 06 '10 19:03

D.Unknown


1 Answers

Just a couple points

  1. tmpfs or ramdisk are more mature than memcached (been around longer but both are stable
  2. tmpfs is scalable (you can resize or increase as needed without loosing the contents of tmpfs
  3. memcahced is great if you need memory on another machine or if you need to share that information between machines.
  4. local file/socket/pipe performance is ALWAYS faster than a network socket and accessing a file in tmpfs is the same as any other file so it does not require any 3rd party libraries.

If you don't expect you data to our grow the memory on your server use tmpfs.

If you must share the data between servers or want to store more data that whats fits into the RAM on your local server use memcahed.

like image 133
Kelvin Avatar answered Oct 11 '22 02:10

Kelvin