Sales:  800-573-7846 or Live Chat

The ServInt Source

The Tech Bench: Memcached

What is caching?

Servers have limited resources, and at any given time of high traffic, one or more of these resource limitations may create a bottleneck. A server–no matter the size–can only handle so many requests at a time. But what if there was a way to ease the burden when a server is asked to serve up the same information over and over?

Think about a WordPress site. Each page a user visits is not a single file, but rather an amalgamation of the theme, widgets, posts, footers, headers, etc. Each time a page is accessed, PHP will generate the page requested on the fly from the database. It takes time to query the database to create the page. These database queries put a strain on the resources of your server.

However, what if instead of continually generating a new page–the same page–for every visitor, you turned those pages into static HTML files? No database querying would be needed for new visitors. And a static file can be served up much faster and with significantly less resource consumption. Your visitors see their requested page sooner, and you save on CPU cycles. Everyone is happy. This is what caching does.


Memcached is a general-purpose, free and open-source distributed memory caching system. It is one of the most popular caching tools and is used in such popular sites as YouTube, Reddit, Zynga, Facebook, and Twitter. If you also run dynamic, database-driven sites, Memcached may reduce resource consumption and speed up page delivery on your server as well.

Installing Memcached (daemon)

The quickest and easiest method is to install Memcached via Yum on the command line of your server.

1. Grab the RPM that matches your OS:

CentOS 6 (64 bit):

su -c ’rpm -Uvh’

CentOS 6 (32 bit):

su -c ’rpm -Uvh’

CentOS 5 (64 bit):

su -c ’rpm -Uvh’

CentOS 5 (32 bit):

su -c ’rpm -Uvh’

2. Install it with Yum:

yum install memcached

3. Start the memcached service:

/etc/init.d/memcached start

4. Configure the memcached service to start when the server boots:

chkconfig memcached on

5. Finally, disable the RPM so that it is not used for future Yum functions:

perl -pi -e “s/enabled=1/enabled=0/g;” /etc/yum.repos.d/epel.repo

Of course, if you think Memcached may be right for your server, but you’re not ready to install it yourself, just open up a support ticket in your ServInt Customer Portal and the MST will be happy to help.

Configuring Memcached

A main benefit of Memcached is also a drawback. It is language independent so it can work in many environments. But specifically because of this, it needs to be coded into the site to do its job. If you’re not fluent in PHP, a qualified web developer can do this for you.

Alternatively, check the sites of any third-party software running on your server to see if they have a plugin that allows you to use Memcached without further coding.

Check back next time, we we discuss how to install the PHP memcache extension.

The Tech Bench is an ongoing blog series featuring the answers to common questions the ServInt MST fields everyday. You can also find more great tech tips in the ServInt KnowledgeBase.

About Jacob Tirey

Jacob Tirey is an IT professional and former member of ServInt's Managed Services team.

The ServInt Source | Web Hosting Blog