Book Image

Getting Started with Memcached

By : Ahmed Soliman
Book Image

Getting Started with Memcached

By: Ahmed Soliman

Overview of this book

<p>Web application performance is no longer a non-functional requirement, but an implicit condition for an engaging user experience. As a result, responsive and highly scalable applications are becoming a necessity. Memcached is a high-performance distributed memory caching system built to speed up dynamic web applications by offloading pressure from your database. <br /><br />Getting Started with Memcached is a hands-on, comprehensive guide to the Memcached service and it’s API in different programming languages. It contains practical recipes to integrate Memcached within your Rails, Django, or even Scala Play! applications.<br /><br />This book will show you everything you need to know to start using Memcached in your existing or new web applications.<br />This book uses real-world recipes to help you learn how to store and retrieve data from your clustered virtual memory cache pool and how to integrate caching into your favourite web development framework.</p> <p><br />You will also learn how to build a Memcached consistent-hashing scalable cluster and how Memcached clients are properly configured to use different servers to scale out your memory cache pool in Ruby, Python, PHP, and Java. With this book, you will see how to cache templates and database queries in the most popular web development framework in use today.</p>
Table of Contents (9 chapters)

Setting up memcached to start on boot in Ubuntu (Simple)


How to make sure that memcached daemon is started by default on boot?

Getting ready

On server installations, we need to ensure that memcached is automatically started on boot if it's not already.

How to do it...

  1. Check if memcached is already running or not:

    /etc/init.d/memcached status* memcached is running 
    
  2. If you want to disable starting memcached on boot:

    sudo update-rc.d memcached disable
    
  3. If you want to re-enable memcached to start on boot:

    sudo update-rc.d memcached enable
    
  4. To ensure it's running in the default run levels:

    sudo update-rc.d memcached defaults
    

How it works...

We are using update-rc.d script to create and delete symbolic links at /etc/rcX.d/ where X is the runlevel number.

Those symlinks are scanned on boot and they control whether the service is going to be started or not, based on the initial letter.

If you have seen the output of update-rc.d memcached enable

   Enabling system startup links for /etc/init.d/memcached.
   Removing any system startup links for /etc/init.d/memcached:
   /etc/rc0.d/K20memcached
   /etc/rc1.d/K20memcached
   /etc/rc2.d/K80memcached
   /etc/rc3.d/K80memcached
   /etc/rc4.d/K80memcached
   /etc/rc5.d/K80memcached
   /etc/rc6.d/K20memcached
   Adding system startup for /etc/init.d/memcached:
   /etc/rc0.d/K20memcached -> ../init.d/memcached
   /etc/rc1.d/K20memcached -> ../init.d/memcached
   /etc/rc6.d/K20memcached -> ../init.d/memcached
   /etc/rc2.d/S20memcached -> ../init.d/memcached
   /etc/rc3.d/S20memcached -> ../init.d/memcached
   /etc/rc4.d/S20memcached -> ../init.d/memcached
   /etc/rc5.d/S20memcached -> ../init.d/memcached

You will see that the symlinks may start with K or S. which indicates that in a certain runlevel, the system should Kill or Start the service, respectively.