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

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

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

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

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/

Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more. https://google.com/+ContainerbasisDe

Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site. Artists

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://www.floorsandchores.net

I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. http://hackps.com

There are various motives that you would would like to buy Instagram followers. We offer actual followers so they're authentic people today looking at your posts, not bots or phony followers. This can place your pictures and video clips in front of a huge number of viewers who will likes and comment. This normally produces a snowball effect allowing for lots of our consumers to go viral. http://www.getigpromotion.com/buy-instagram-comments/

This is very useful post for me. This will absolutely going to help me in my project. http://leapforwardinc.com/

Thanks Fiona - good point. For most of us, orienting our lives towards love is a huge change. However, once it takes hold, the economic problems usually fade into the background. I'll reflect on that for the next book http://www.howtolosethighfat.org

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. waffle maker

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. noise cancelling headphones review

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. health product reviews

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. Sperian Biosystems

Great tips and very easy to understand. This will definitely be very useful for me when I get a chance to start my blog. raleigh search engine optimization http://raleighseo.marketing1on1.com/

I'm tossing it (too late to return it to Amazon). This has a lot of great attributes to it, especially for the price (the biggest selling point IMO), but it does have a lot of sugars in it and the protein is a mix of time released protein as opposed to straight whey. Not worth keeping, sending all back. This is much better! Trying to avoid surgery for as long as I can farby palette blond

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.http://delong.typepad.com/sdj/2014/05/morning-must-read-christian-broda-and-jonathan-a-parker-the-economic-stimulus-payments-of-2008-and-the-aggregate-demand-fo.html

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. http://www.gfsprague.com/gutters/

I'm now not sure the place you are getting your information, but good topic. I must spend a while finding out more or understanding more. Thank you for fantastic information I used to be searching for this info for my mission. http://www.newcase.com.au/iphone-4-4s-leather-wallet-case-blue/

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.calgary mortgage broker

Its opportunity are so fantastic and working style so speedy - See more at: http://www.youmedia.org/resources#sthash.MVSaM8GV.dpuf
sustanon for sale

Its opportunity are so fantastic and working style so speedy ..
sustanon for sale

Most of the time I don't make comments on websites, but I'd like to say that this article really forced me to do so. Really nice post. kimberly clark products catalog

This is so cool. I am such a huge fan of their work. I really am impressed with how much you have worked to make this website so enjoyable. benicar lawyer attorney

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

First You got a great blog .I will be interested in more similar topics. i see you got really very useful topics , i will be always checking your blog thanks. read here

I really like the dear information you offer in your articles. I'm able to bookmark your site and show the kids check out up here generally. Discover More

Pertandingan Sepak Bola Online Kumpulan Jadwal Pertandingan Bola Online di NOBARTV Click for information

Jika anda membutuhkan koleksi hijab terbaru kami memiliki beberapa penawaran yang akan sangat sesuai dengan busana muslimah saudara. Silahkan melihat koleksi jilbab dan gamis muslim di website kamid an dapatkan penawaran menarik lainnya lihat produk . Sabun Amoorea ini sudah sangat terkenal tren fashion dress muslimah .
Kalau anda tertarik untuk membuat takoyaki atau martabak atau tempe mendoan, maka anda bisa mencoba resep yang ada di dalam blog kami, baik tempe mendoan, ataupun takoyaki dibeberkan rahasianya dengan blak-blakan. Kami juga menyediakan bahan bakunya. buka halaman . jaket korea ini ditawarkan dalam berbagai model cara membuat tempe mendoan yang lezat .
Anda bisa membeli tas laptop untuk melindungi peralatan online anda. Dengan tas laptop anda akan lebih praktis ke mana-mana tanpa harus kuatir akan keamanan tas laptop dari cuaca dan kerepotan lainnya. Silahkan cek ragam model tas laptop yang kami miliki penjelasan selengkapnya . Lihat koleksi jaket couple dari distro bandung jual baju tidur .
Jika anda memiliki lirik lagu yang anda ingin temukan silahkan mencarinya di website kami, di sini ada banyak sekali pilihan lirik lagu yang bisa membantu anda mendapatkan lirik yang anda butuhkan. Mulai dari lagu daerah sampai lagu barat ada di sini. lihat di sini . Dapatkan sarung, baju batik, dan jilbab murah aneka model di sini lirik lagu lengkap .
We picked 60 of our favorite blogs that are shaking up the health and wellness space by posting great content, interacting with readers, and generally providing kick-ass information to the Internet at large. read more . Dapatkan tips terbaik tentang cara membuat blog dan SEO di sini, skin cancer melanomas .
Apakah anda suka mendownload lagu dari internet? Saat ini hadir website dengan pilihan download lagu gratis yang sangat beragam. Berbagai genre lagu ada di sini, dan anda bisa memilih mana yang sesuai dengan pilihan anda. lihat penawaran kami . Lihat koleksi sepatu wanita yang dijual online berikut ini download mp3 gratis .
Apakah anda membutuhkan referensi? Anda bisa mencari referensi yang anda butuhkan dari situs perpustakaan online yang kami miliki silahkan lihat koleksi referensi yang dimiliki oleh website perpustakaan online kami di sini. download di sini . Lihat koleksi sepatu wanita yang dijual online berikut ini perpustakaan digital .
Berwisata adalah sesuatu yang bisa menyegarkan pikiran kita. Jika anda punya rencana berwisata di kota padang maka anda bisa mendapatkan layanan wisata dari pelangiholiday yang sangat berpengalaman dalam melayani para wisatawan. Anda juga bisa menyewa kendaraan untuk keliling kota. lihat penjelasan lengkapnya . Lihat koleksi sepatu wanita yang dijual online berikut ini rental mobil kijang .
Aki kendaraan bisa membawa maslah jika perawatannya di abaikan, sekarang silahkan cek aki pada kendaraan anda dan jika sudah soak sebaiknya segera dirawat atau diganti dengan baru sebelum mendatangkan masalah di jalanan ini adalah sesuatu yang perlu anda perhatikan. baca selengkapnya . Lihat koleksi sepatu wanita yang dijual online berikut ini membedakan aki baru dan bekas .
Tenda adalah sesuatu yang sering dibutuhkan saat kita mengadakan suatu acara. Jika anda memerlukan bantuan untuk mengadakan tenda maka anda bisa menghubungi jasa sewa tenda yang sudah cukup berpengalaman yang telah melayani banyak instansi. baca di sini . Lihat koleksi sepatu wanita yang dijual online berikut ini menyediakan perlengkapan pernikahan .
Di dalam sebuah bisnis tentunya selalu ada risiko jadi silahkan mempelajari bagaimana cara manajemen resiko dalam bisnis mmm ini. Sebuah konsep bisnis yang bisa membantu anda mengatasi masalah keuangan dalam cara sederhana tanpa bergantung kepada utang. kunjungi blog . Lihat koleksi sepatu wanita yang dijual online berikut ini bagaimana menerima bantuan di mmm .
Stabiliser tegangan adalah peralatan untuk melindungi peralatan listrik anda dari tegangan yang tidak stabil. Anda bisa mendapatkan kualitas listrik yang lebih baik jika anda mempergunakan stabilizer tegangan atau AVR. Adapun AVR yang paling terkenal saat ini adalah matsunaga. lihat artikel . Lihat koleksi sepatu wanita yang dijual online berikut ini menyediakan stabilizer matasunaga yang asli .
Kami juga menyediakan jam tangan keren dengan berbagai pilihan model yang sangat menarik. Baik itu jam tangan replika atau kw maupun yang original. Semuanya tersedia di toko jam tangan online kami. Silahkan menghubungi kami dari website yang tersedia di samping. baca artikel . Lihat koleksi sepatu wanita yang dijual online berikut ini jam tanga replika dan original .
Bagaimana tips untuk lulus tes semuanya dibagi di sini. Tes apapun yang anda hadapi selalu saja ada solusinya. Mari lihat berbagai trik yang bisa membantu anda lolos tes cari kerja atau UAN atau tes masuk pergutuan tinggi negeri. kunjungi website kami . Lihat koleksi sepatu wanita yang dijual online berikut ini curiculum vitae dan cara membuatnya .
Apakah anda membutuhkan jasa konveksi dengan harga murah? Anda bisa mendapatkan layanan yang prima hanya di sini. Kualitas jahitan dari jasa konveksi ini sangatlah terjamin dan sudah banyak bekerja sama dengan instansi resmi pemerintah dan BUMN. silahkan baca selengkapnya . Lihat koleksi sepatu wanita yang dijual online berikut ini konveksi baju seragam di kota surabaya .
Ada banyak sekali penyakit di luar sana yang memerlukan penanganan serius. Hanya saja pengobatan barat cenderung mengakibatkan efek samping. Saat ini tiens menyediakan produk alami yang bisa membantu anda mendapatkan kesembuhan dengan lebih aman. Jadi hubungi website jual online produk herbal tiens. klik di sini . Lihat koleksi sepatu wanita yang dijual online berikut ini tips menambah tinggi badan .
Jika anda memulai usaha anda dan ingin mempromosikannya dengan menggunakan blog maka anda harus mempelajari apa yang namanya SEO. Jika anda merasa tertarik untuk mempelajari SEO maka trikmudahseo adalah langkah awal yang tepat untuk anda. Silahkan kunjungi blognya. trikmudahseo.blogspot.com . silahkan anda pelajari lagi cara membuat facebook, atau twitter, atau blog atau email dan sebagainya. Petunjuknya ada lengkap di sini dan sudah siap untuk anda pelajari. Dapatkan tutorial cara membuat lainnya. ini dia cara membuat blog dan petunjuk terbaru blogging .
Atau jika anda adalah penggemar belanja online maka anda memerlukan website yang bisa memenuhi selera anda. Saat ini evafashionstore menyediakan banyak pilihan baju wanita, sepatu wanita dan masih banyak lagi yang lainnya dan anda bisa mendapatkannya dengan harga murah. www.evafashionstore.com . Ini dia yang anda butuhkan untuk menambah tinggi badan anak anda jual online sepatu wanita berkualitas .

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. browse around this web-site

This really is an excellent submit which I actually loved reading. It is not daily i possess the possibility to see something similar to this. rumah idaman minimalis

This one helped me for a thesis which I am writing. Thank you for giving me another point of view on this difficult situation. Now I can easily complete my article. Thanks. sneak a peek at these guys

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.