Memcached and PECL memcache on CentOS and Fedora

At Tag1 Consulting we do a lot of work on increasing web site performance, especially around Drupal sites. One of the common tools we use is memcached combined with the Drupal Memcache module. In Drupal, there are a number of different caches which are stored in the (typically MySQL) database by default. This is good for performance as it cuts down on potentially large/slow SQL queries and PHP execution needed to display content on a site. The Drupal Memcache module allows you to configure some or all of those caches to be stored in memcached instead of MySQL, typically these cache gets/puts in memcache are much faster than they would be in MySQL, and at the same time it decreases work load on the database server. This is all great for performance, but it involves setting up an additional service (memcached) as well as adding a PHP extension in order to communicate with memcached. I've seen a number of guides on how to install these things on Fedora or CentOS, but so many of them are out-dated or give instructions which I wouldn't suggest such as building things from source, installing with the 'pecl' command (not great on a package based system), or using various external yum repositories (some of which don't mix well with the standard repos). What follows is my suggested method for installing these needed dependencies in order to use memcached with Drupal, though the same process should be valid for any other PHP script using memcache.

PECL Packages

For the Drupal Memcache module, either the PECL memcache or PECL memcached (note the 'd'!) extensions can be used. While PECL memcached is newer and has some additional features, PECL memcache (no 'd'!) tends to be better tested and supported, at least for the Drupal Memcache module. Yes, the PECL extension names are HORRIBLE and very confusing to newcomers! I almost always use the PECL memcache extension because I've had some strange behavior in the past using the memcached extension; likely those problems are fixed now, but it's become a habit and personal preference to use the memcache extension.

Installing and Configuring memcached

The first step is to get memcached installed and configured. CentOS 5 and 6 both include memcached in the base package repo, as do all recent Fedora releases. To install memcached is simply a matter of:
# yum install memcached

Generally, unless you really know what you're doing, the only configuration option you'll need to change is the amount of memory to allocate to memcached. The default is 64MB. That may be enough for small sites, but for larger sites you will likely be using multiple gigabytes. It's hard to recommend a standard size to use as it will vary by a large amount based on the site. If you have a "big" site, I'd say start at 512MB or 1GB; if you have a smaller site you might leave the default, or just bump it to 512MB anyway if you have plenty of RAM on the server. Once it's running, you can watch the memory usage and look for evictions (removal of a cache item once the cache is full) to see if you might want to increase the memory allocation.

On all Fedora / CentOS memcached packages, the configuration file is stored in /etc/sysconfig/memcached. By default, it looks like this:

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""

To increase the memory allocation, adjust the CACHESIZE setting to the number of MB you want memcached to use.

If you are running memcached locally on your web server (and only have one web server), then I strongly recommend you also add an option for memcached to listen only on your loopback interface (localhost). Whether or not you make that change, please consider locking down the memcached port(s) with a firewall. In order to listen only on the 127.0.0.1 interface, you can change the OPTIONS line to the following:

OPTIONS="-l 127.0.0.1"

See the memcached man page for more info on that or any other settings.

Once you have installed memcached and updated the configuration, you can start it up and configure it to start on boot:

# service memcached start
# chkconfig memcached on

CentOS / RHEL PECL Module Install

Fedora

If you are on Fedora and using PHP from the base repo in the distribution, then installation of the PECL extension is easy. Just use yum to install whichever PECL extension you choose:

# yum install php-pecl-memcache

Or

# yum install php-pecl-memcached

CentOS 5 / RHEL 5

CentOS and RHEL can be a bit more complicated, especially on EL5 which ships with PHP 5.1.x, which is too old for most people. Here are the options I'd suggest for EL5:

  • If you are OK using the PHP provided with EL5, then you can get the PECL extensions from EPEL. Once you've enabled the EPEL repository (instructions), you can install either PECL extension by using the same yum commands outlined above in the Fedora section.
  • If you want to use PHP 5.2 or PHP 5.3 with EL5, I suggest using the IUS repositories (IUS repo instructions). Note that IUS provides the PECL memcache extension, but not the PECL memcached extension. Based on which PHP version you decide to use, you can install the PECL memcache extension with either:

    # yum install php52-pecl-memcache

    Or

    # yum install php53u-pecl-memcache

CentOS 6 / RHEL 6

EL6 ships with PHP 5.3, though it is an older version than is available for EL6 at IUS. If you are using the OS-provided PHP package, then you can install the PECL memcache extension from the base OS repo. If you want the PECL memcached extension, it is not in the base OS repo, but is available in EPEL. See the instructions linked from the CentOS 5 section above if you need to enable the EPEL repo.

# yum install php-pecl-memcache

Or, enable EPEL and then run:

# yum install php-pecl-memcached

As with EL5, some people running EL6 will also want the latest PHP packages and can get them from the IUS repositories. If you are running PHP from IUS under EL6, then you can install the PECL memcache extension with:

# yum install php53u-pecl-memcache

Similar to EL5, the IUS repo for EL6 does not include the PECL memcached module.

PECL Memcache Configuration

If you are using PECL memcache extension and will be using the clustering option of the Drupal Memcache module which utilizes multiple memcached instances, then it is important to set the hash strategy to "consistent" in the memcache extension configuration. Edit /etc/php.d/memcache.ini and set (or un-comment) the following line:

memcache.hash_strategy=consistent

If you are using the PECL memcached module, this configuration is done at the application level (e.g. in your Drupal settings.php).

Once you've installed the PECL memcache (or memcached) extension, you will need to reload httpd in order for PHP to see the new extension. You'll also need to reload httpd whenever you change the memcache.ini configuration file.

# service httpd reload

SELinux

If you have SELinux enabled (you should!), I have an older blog post with instructions on configuring SELinux for Drupal.

That's it, you're now good to go with PHP and memcache!

Comments

Helped a lot thanks

Jadwal Nonton TV Bola Online Jadwal Nonton TV Berita Bola Online di NOBARTV
Berita Sepak Bola Online Terkini berita bola terbaru di NOBARTV
Kumpulan Jadwal Pertandingan Sepak Bola Online Kumpulan Jadwal Pertandingan Bola Online di NOBARTV
Kumpulan Kabar Harian Berita Sepak Bola Online Kumpulan Berita Bola Online di NOBARTV

Online Terkini berita bola terbaru di NOBARTV
Kumpulan Jadwal Pertandingan Sepak Bola Online Kumpulan Jadwal Pertandingan Bola Online di NOBARTV Anime Filme

Kumpulan Jadwal Pertandingan Sepak Bola Online Kumpulan Jadwal Pertandingan Bola Online di NOBARTV Bromo Tengger Semeru

Jadwal Pertandingan Sepak Bola Online Kumpulan Jadwal Pertandingan Bola Online di NOBARTV Internetbureau Haarlem

The range of healthcare products offered by Flamingo Health includes Fahrenheat Sauna Belt, Flamingo Cool Eyes, Flamingo Cool Pack, Flamingo Orthopaedic Heat Belt and Premium Orthopaedic Heat Belt. breakfast4health

Merawat printer akan membantu anda memperpanjang usia dari alat cetak ini. Anda bisa mendapatkan spareparts dari printer yang anda inginkan jika anda hanya ingin melakukan perawatan printer. Hanya saja pada umumnya spareparts ini tidak tersedia di tempat umum dan harus dipesan online. download di sini . lihat perlengkapan printer lainnya di sini semakin banyak permintaan catridge printer bekas .
Jika anda ingin melakukan aktifitas wisata yang menyenangkan, maka sebaiknya anda menyewa jasa wisata. Karena anda akan mendapatkan paket wisata yang biayanya ringan dan pelayanannya profesional. Jadi sekarang coba lakukan pemesanan. baca di sini . dapatkan penawaran paket wisata lainnya di sini wisata di daerah dataran tinggi dieng .
Apakah anda membutuhkan bantuan untuk mendapatkan gems, atau xp atau food di dragon city? Jangan kuatir karena saat ini sudah ada layanan joki dragon city yang akan membantu anda mendapatkan semuanya itu. lihat artikel . lihat penawaran lainnya bagaimana cara mendapatkan dragon terkuat di dragon city .
Untuk melakukan kegiatan outbound yang berkelas anda perlu menyewa jasa pelatihan outbound yang profesional. Hal ini sangat penting untuk menjamin keselamatan para peserta outbound. Ada beberapa layanan outbound yang tersedia saat ini. baca artikel . butuh paket outbound yang lengkap? outbound training puncak bogor dengan biaya murah .
Jika anda berusaha mengadakan bisnis konveksi baju seragam kantor, maka kami menyediakan jasa konveksi dengan harga murah dan kualitas jahitan yang sangat rapi. Jika anda tertarik, silahkan melihat koleksi dari baju kerja kantor yang kami miliki. lihat penjelasan lengkapnya . Silahkan cek koleksi model tas kami kualitas dan mutu tas dari tasseminar.net .
Jerawat adalah salah satu masalah yang kerap kali membuat wanita kehilangan rasa percaya diri. Oleh karena itu saya mau memperkenalkan bps yaitu sebuah krim perawatan kecantikan yang bisa membantu anda menghilangkan jerawat yang membandel kunjungi blog . baca informasi selengkapnya produk majakani ini cream kecantikan .

The fitness center also focuses on stress management. Everybody is under stress and their classes help you to reduce your stress. You get to learn methods on how to eat, do regular exercise, and lead a healthy lifestyle. waterloohealthcare

I admire what you have done here. I like the part where you say you are doing this to give back but I would assume by all the comments that this is working for you as well.
our page

Di dalam tiap perkantoran ada banyak aktifitas yang membutuhkan tunjangan alat tulis kantor yang memadai. Tidak adanya suply yang terjamin bisa membuat anda kesulitan beraktifitas. Jadi jika anda memerlukan alat tulis kantor anda bisa melakukan pemesanan secara online dan mendapatkan harga terbaik dari kami. lihat artikel . pesan alat tulis kantor di sini tender pengadaan alat tulis kantor .
Laptop adalah peralatan kerja mobile yang bisa memungkinkan anda melakukan aktifitas kerja di mana saja. Namun untuk membawa laptop anda membutuhkan tas laptop demi kemudahan dan keamanan laptop saudara. Jadi coba dapatkan di toko tas laptop online ini. baca artikel . jual tas laptop dengan harga murah jual beli tas bonjour di dunia maya .
Olahraga adalah aktifitas yang akan menguras keringat saudara, dan oleh karena itu ada baiknya anda menggunakan baju kaos olahraga yang berkualitas. Baju ini bisa membantu anda menyerap keringat selama olahraga . lihat penjelasan lengkapnya . pesan grosir kaos olahraga dan cek modelnya jual seragam olahraga di inyernet .
Untuk membangun sebuah blog yang SEO friendly anda membutuhkan template blog yang juga SEO friendly dan saat ini salah satu kriteria blog yang SEO friendly adalah responsive design karena akan mudah menyesuaikan dengan layar pengguna internet. read more . pelajari lebih lanjut cara membuat blognya template blog yang SEO friendly dan responsive .
Wanita saat ini mempunyai selera busana yang sangat kompleks dan semakin jenuh untuk mencarinya di mal atau pasar. Dengan adanya kemajuan teknologi, maka semakin banyak orang yang melakukan belanja online untuk sepatu ataupun baju wanita. lihat penawaran kami . silahkan lihat koleksi baju wanita dan sepatu lainnya jual sepatu wanita dengan model terbaru .

First, you would just need to be measured properly as you go into a lingerie store. This way you would be able to make sure that you would be getting the correct bra cup size and the correct length of the bra strap. onlinewatchshopping

nice post, keep up with this interesting work. It really is good to know that this topic is being covered also on this web site so cheers for taking time to discuss this!
Viagra soft or Brand viagra

nice post, keep up with this interesting work. It really is good to know that this topic is being covered also on this web site so cheers for taking time to discuss this!..
in depth coverage of Morin\'s dealings

It is truly a great and helpful piece of information. rumah minimalis 2 lantai

There also other types of lingerie which have been tailored to fit plus size women. You need not have a perfect body to be able to enjoy wearing sexy lingerie. italianshopping

Lihat saja
http://language-komputer.blogspot.com/2014/08/asus-zenfone-smartphone-android-terbaik.html yang sudah berbuat banyak untuk teknologi.

Dapatkan cerita gratis Asus zenfone Smartphone Android Terbaik hanya disini.

Dapatkan info terkini jersey munchen 2015 yang pasti keren untuk anda.

Pastikan jika jersey city 2015 bisa anda pakai untuk musim ini dengan baik.

With the rapid development of real estate, a complete set of lighting products, demand is growing significantly. Whether lighting needs, atmosphere, space rendering effects such as manufacturing, are inseparable from the lighting. homesmarthome

Jadwal Pertandingan Sepak Bola Online Kumpulan Jadwal Pertandingan Bola Online di NOBARTV Agen bola terpercaya

This is also a very good post which I really enjoyed reading. It is not everyday that I have the possibility to see something like this. rowing machine reviews

It is not everyday that I have the possibility to see something like this.Cars On Terms

This article is really the best. So, I would like you that you keep on continuing your work on this article. And upload as many new articles about this as possible. i need him to fall in love with me

Kami Toko mebel jepara jual mebel harga murah asli Mebel Jati yang tentunya dengan kualitas terbaik dan khas dengan ukiran mebel Tempat Tidur katalog produk mebel kami banyak dan lebih dari ratusan hingga ribuan produk yang bisa anda cek disini Kamar Set dengan harga yang relatif murah anda sudah bisa mendapatkan produk Kamar Set Minimalis asli produk jati dari jepara, juga tersedia produk Gebyok Jepara yang sangat cantik dan khas dengan ukirannya, banyak juga produk produk untuk ruang tamu rumah anda berupa Kursi Tamu dengan desain minimalis ataupun klasik, semuanya kami tawarkan dengan harga yang cukup terjangkau Meja Makan salah satu produk utama yang harus ada dalam satu hunia rumah kami sediakan dengan berbagai macam model Kursi Tamu Minimalis sampai dengan model yang mewah yang tentunya kemewahan dari produk kami beda dengan yang lain Kursi Tamu Mewah model meja makan minimalis ada banyak di katalog website kami, anda bisa mengeceknya di sini Meja Makan Jati produk modern berbahan baku jati yang tentunya sangat awet untuk anda peroleh untuk ditempatkan di rumah anda, semua itu anda bisa melihatnya di katalog produk Mebel Minimalis untuk mebel jati memang sudah tidak asing lagi kalau kualitas mebel jati yang bagusa hanya dari Mebel Jati Jepara untuk semua produk yang kami tawarkan semuanya kami tawarkan produk tersebut dengan harga Mebel Jepara Murah

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well..
https://www.rebelmouse.com/restoremyvisiontodayreviews/

Yes, i believe the fact with you. Great details on your website here. I really like this publish because we can get some useful. hotel intimacy kits

I think that thanks for the valuabe information and insights you have so provided here.
https://www.rebelmouse.com/

for installing these needed dependencies in order to use memcached with Old School New Body book

The new talent system makes every decision difficult.
Buy High PageRank BackLinks

This is some real bad ass article, my man! One of the most hi-fi article that I've ever read is surely this one. I am real pleased by this and hope that you will continue to contribute in the same way in the coming weeks as well. kontorimööbel

I really loved reading your blog. It was very well authored and easy to undertand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting. In fact after reading, I had to go show it to my friend and he ejoyed it as well!
small hand vacuum

I learn some new stuff from it too, thanks for sharing your information.
seo services dallas

Thank you for some other informative blog. Where else could I get that type of information written in such an ideal means? I have a mission that I’m just now working on, and I have been at the look out for such information.
get smart watch online

order to use memcached with Drupal, though the same process should be valid for any other PHP script using memcache.read original article

Thanks very much for this great article, this is the stuff that keeps me going through out these day. ning

I wouldn't suggest such as building things from source, installing with the 'pecl' command (not great on a package based system http://theofficialwebsite.co/michael-fiore-text-your-ex-back-review/

I found that site very usefull and this survey is very cirious, I ' ve never seen a blog that demand a survey for this actions, very curious...
top double strollers

Thanks for taking the time to discuss this, I feel strongly that love and read more on this topic. If possible, such as gain knowledge, would you mind updating your blog with additional information? It is very useful for me.
life alert system

Most of the time I don’t make comments on but I'd like to say that this article really forced me to do so. Really nice post! more techniques on rebelmouse

The Ponte City photo essay speaks in a similar voice. As with the prison series, it stresses the space that controls the movements and choices of the individual – recalling Michel Foucault’s meditations on space, power and control.Charter Communications Login

likely those problems are fixed now, but it's become a habit and personal preference to use the memcache extension. voyante

likely those problems are fixed now, but it's become a habit and personal preference to use the memcache extension. best fat burner

order to use memcached with Drupal, though the same process should be valid for any other PHP script using memcache. buy seo

You can get a Paypal debit card that works in the Czech Republic? ovariancystmiracle.net

I've had some strange behavior in the past using the memcached extension; likely those problems are fixed now, but it's become a habit and personal preference to use the memcache extension.http://www.super6.me/365bet.html

I am having a good day today. I am reading the world's best article right now, soon I will be going to my farm house to enjoy! building chicken coops

You may post on the professional credentials for the blog owner. You could express it's outstanding. Your blog experience can springboard your click through. http://vivitranslation.com/about-us/china-business-etiquette-culture.html

It's really nice and meanful. it's really cool blog. Linking is very useful thing.you have really helped lots of people who visit blog and provide them usefull information. http://kbdc.org

I don't have time to go through it all at the minute but I have saved it and also added in your RSS feeds, so when I have time I will be back to read more, Please do keep up the awesome job. http://www.muddybuddies.com

If you have a business in Yorkshire and would appreciate extra paying customers, extra sales and greater profits, we would love to carry out SEO for you. Give us chance. We want to make your business more of a success. http://www.perfect4tography.com/trick-photography-and-special-effects-re...

This is really good information I have visited this blog to read something fresh and I really admire you efforts in doing so. http://www.donnaglamour.it

I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work. http://www.invoicefunders.co.nz/

Pages

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.