Memcached

Insert performance comparison of NoSQL vs SQL servers

I have played around with CouchDB half year ago and it's performance was just horrible. I have heard a lot of good about mongodb recently so i thought i will have a look at it.

I think that NoSQL can have really good use cases in web. The problem is that you need a really performant and stable system if you want to use it in production. I ran just a few simple tests so its not a real benchmark or anything. It is just a simple test trying to figure out how far behind are nosql solutions (performancewise).

Installing PHP 5.3.3 from packages on Debian Lenny with apc, xdebug, memcache etc

Building apache and PHP with all its extensions may be fun once or twice but it is a major pain in the neck. So to avoid that (and to have it before Debian Squeeze is released) you can use e special dotdeb repository of almost everything that you may need as a web dev. It is especially convenient if you have a few development servers to update with different configurations and you don't want to waste too much time on it.

Comparing APC and Memcache as local PHP content cache.

When you build PHP applications you need cache storage to keep your calculated data in. There are quite a few options and use case decides which solution is better.

I knew that APC is faster than memcached as there is much less overhead but I wanted to see how memcached would compare to APC user cache.

PHP session in Mysql VS Memcached

In my previous companies we used to serve sessions from mysql via a custom made session handlers and to be honest we never really had any problems with it. I cant actually remember the traffics and concurrency rates but it was not that low. Currently the solution im working with uses memcached for sessions storage, the default build in session handler. I am a bit worried about the way it works with memcached.

Problems with memcached sessions in PHP

First of all memcached is a cache storge engine and it was not designed with sessions in mind. The way php extension uses memcache causes a few more problems in the long run. Here are my concerns:

Using early cache rebuild to optimize web cache performance

Having a busy website requires a few techniques to optimize the performance of caches. It is not that difficult and should help you reduce the load times (pessimistic load times) a whole lot.

Imagine you have home page cache (as fragments or entire page). Its all good and beautiful as long as it sits in the cache. All threads connect to cache, get the content and send to the user. What happens when the cache expires? Well all threads have to rebuild it. Unfortunately on very busy content elements it can cause dozens of processes trying to rebuild the same page!

PALM v3 - bundle of Php Apache Linux Memcached APC Cacti scripts

Finally i had some time to gather all the files together and make third release of my cacti monitoring scripts and graph templates.

Monitoring of application and server health is an important task, while trying to maintain high availability. Without monitoring you dont know what goes wrong and you do not know when exactly does it happen. Some time ago i realized that the graphs i used to use were not perfect. I searched the web, read a bit of documentation and decided to put together a set of simple scripts gathering key server performance metrics.

This bundle includes gathering scripts and graph templates for Memcached, APC, Apache2, Linux file system, Linux memeory, CPU and Network. It should cover all the most important aspects for a typical web server. Graphs are designed to match my expectations and to make analysis easier.

I still dont have postgres, sphinx nor mysql stats included but .... who knows .... maybe in version 4! :- )

Compile Memcached on Mac OS X

First of all lets make it clear, memcahced on mac? why bother?! Well i have to work on mac at work so i dont really have a choice. I assume if you are interested in that hint you are in same situation. Personally i think its just pain that i dont work on debian but any way.

If you need memcached running locally on mac download sources of libevent from lib event site. Then follow typical procedure of compilation and installation:

PHP Memcache extension API Pitfall

It happened again, i spent like 15 minutes trying to figure out what am i doing wrong before i realized that i got caught in a API snare ;- )

Problem i had was caused that PHP extension for Memcached communication has a strange way of interpretation time to live parameter. If you provide 3rd parameter to set function it will set value in cache and mark it to expire after X amount of seconds. Well that all cool and nice but if you try to pass amount of seconds greater than 2.5 mln seconds (about 30 days) it will be actually interpreted as unix timestamp! Oh noooooo! : -)

How to compile memcached 1.4 on MAC

I am using Mac just since January and im still not so familiar with it. If you want to install latest memcached on Mac OSX you will need libevent.

Download libevent from this site:
http://www.monkey.org/~provos/libevent/

Then unpack, configure and compile it. Also install it in /usr/local

PALM - bundle of Linux system, Network, Apache2, PHP, APC and Memcached scripts and Cacti graphs

After some more work on the weekend and playing around with cacti i have fixed up some of the previous scripts and joined input methods with data sources and graphs all together.

I have also added a host template so now adding servers will be much easier you just enter host name and click ccreate graphs ... job done.

Package includes graphs to monitor Linux system metrics, disk IO, network IO, apache status, APC op code cache, memcached.

Im still adding stuff to it so make sure to come back for an update : -)

You can see some of the graphs in earlier versions here:
Linux graphs

Syndicate content

About the author

Artur Ejsmont

Hi, my name is Artur Ejsmont,
welcome to my blog. I am a passionate software engineer living in Sydney and working for Yahoo!

Web Scalability for Startup Engineers

If you are into technology, you can order my book Web Scalability for Startup Engineers on Amazon. I would love to hear what are your thoughts so please feel free to drop me a line or leave a comment.

Follow my RSS