Note: Please go to docs.rightscale.com to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > ServerTemplates > v13.5 LTS > ST > Memcached Server (v13.5 LTS) > Memcached Server (v13.5 LTS) - Tutorial

Memcached Server (v13.5 LTS) - Tutorial

 

Table of Contents    

Long Term Support

Stable, tested ServerTemplate assets

   ►  Tutorial

Objective

To set up a Memcached server in a public or private cloud environment.

Prerequisites

The following are prequisites for completing this tutorial:

  • Required user roles: 'actor', 'designer', and 'library'
  • This tutorial assumes that you are setting up Memcached servers that will function as part of a multi-tier architecture that includes both back-end MySQL database servers and front-end load balancer servers (e.g. HAProxy or aiCache) or services (e.g. Amazon Elastic Load Balancing (ELB) or Rackspace Cloud Load Balancers (CLB)). 
  • A deployment into which you are going to add the Memcached server. 

Overview

This tutorial describes the steps for launching one or more Memcached servers in the cloud.  A Memcached server offloads traffic from your database by allowing your applications to access commonly used objects from the Memcached server instead of the database server. The RightScale Memcached ServerTemplate allows you to deploy Memcached servers where needed.

Scalable Multi-tier Architecture Example with Memcached

In the following architecture example diagram, the application servers can still make writes to the database, but many commonly used objects will be retrieved from one of the Memcached servers instead of the Master-DB server.

diag-4tier_Memcached-v1.png

 

 

 

Steps

Configure the Application

You must configure your applications to connect to a Memcached server.

Using Tags

Currently, the Memcached ServerTemplate does not contain scripts to connect to either an application or database tier. However, there are a number of Memcached-specific tags that can be used by a script to connect to the Memcached server so you could configure the application servers to query for the memcached server using the tags below to establish connections.

  • memcached_server:active=true
  • memcached_server:uuid=#{node[:rightscale][:instance_uuid]}
  • memcached_server:cluster=#{node[:memcached][:cluster_id]}
  • memcached_server:port=#{node[:memcached][:tcp_port]}

 

Example

  • memcached_server:active=true
  • memcached_server:cluster=cache_cluster
  • memcached_server:port=11211
  • memcached_server:uuid=01-APKJHSHAPKJHS

 

Using DNS Records

Alternatively, you could also configure the application servers to connect to the Memcached server(s) using a DNS A record. After you launch the Memcached server later in the tutorial, you can create a DNS record that points to the private IP address of the Memcached server (assuming the application servers can establish a connection using the private IP network).

 

diag-System_Architecture-6.png

 

 

 

Create a Security Group

If the cloud supports security groups (e.g. AWS EC2) you must create a security group with the appropriate firewall permissions.

  1. Create a new security group and name it appropriately. (e.g. 'linux-memcached')
  2. Create a firewall rule that will allow the application servers to connect to the Memcached server(s) on TCP and UDP port 11211. If the cloud supports a "group" rule (e.g. Amazon EC2), you can create a rule for the tier of application servers instead of opening up the ports to 'any' IP addresses. In the example below, the security group has a firewall rule that allows the Memcached server to accept requests from the application servers, which are using the 'linux-app' security group.

screen-Memcached_SG-v1.png

Add a Server

Follow these steps to add a memcached server to the deployment.

  1. Go to the MultiCloud Marketplace (Design > MultiCloud Marketplace > ServerTemplates) and import the most recently published revision of the Memcached Server (v13.x) ServerTemplate into the RightScale account.
  2. From the imported ServerTemplate's show page, click the Add Server button.
  3. Select the cloud for which you will configure a server. 
  4. Select the deployment into which the new server will be placed.
  5. Next, the Add Server Assistant wizard will walk you through the remaining steps that are required to create a server based on the selected cloud.
    • Server Name - Provide a nickname for your new load balancer server (e.g., memcached1). 
    • Select the appropriate cloud-specific resources that are required in order to launch a server into the chosen cloud. The required cloud resources may differ depending on the type of cloud infrastructure. Be sure to select the security group you created in a previous step, if applicable. For more information, see Add Server Assistant.
  6. Click Confirm, review the server's configuration and click Finish to create the server.

Configure Inputs

The next step is to define the properties of your Memcached server or servers by entering values for inputs. As a best practice, you should define required inputs for the servers at the deployment level. For a detailed explanation of how inputs are defined and used in Chef recipes and RightScripts, see Inputs and their Hierarchy.

To enter inputs for the Chef recipes that will run on your Memcached servers, open the deployment's Inputs tab, click Edit, and use the following settings to configure input values. We recommend that you set up credentials for password values and any other sensitive data as shown in the examples.

LOGGING

Input Name Description Example Value
SSL Certificate Specify the SSL Certificate to enable authentication with stunnel. Should contain both certificate and key. Certificate should be provided for both the Clients and the Logging Server. cred:LOGGING_SSL_CRED
Logging Protocol Protocol used to send logging messages from client to server. text: udp
Remote Server Configures an instance to forward its log data to a remote server. Specify either the remote server's FQDN or IP address. text: syslog.example.com or 192.168.0.1

MEMCACHED

Input Name Description Example Value
Memcached connection limit Option to either reduce the number of connections (to prevent overloading memcached service) or to increase the number making more effective use of the server running memcached. text: 1024
Memcached listening interface Interface used for memcached connections. text: any
Memcached Cache size percentage Set the amount of memory allocated to memcached for object storage in percentage from total system memory. text: 90
Memcached TCP Port The TCP port to use for connections. text: 11211
Memcached used threads The number of threads to use when processing incoming requests. text: 1
Memcached UDP Port The UDP port to use for connections. text: 11211
Memcached user

The user for executing Memcached. Use one of the users that is preconfigured at boot time.

  • nobody (default)
  • memcached
text: nobody
Memcached cluster_id Used to associate an application server with a memcached cluster. text: cache_cluster
Memcached logging output level Without the verbose options, Memcached normally produces no output during normal operating. text: off

RIGHTSCALE

Input Name Description Example Value
Process List A space-separated list of additional processes to monitor in the RightScale Dashboard. text: sshd crond
Process Match List A space-separated list of pairs used to match the name(s) of additional processes to monitor in the RightScale Dashboard. Paired arguments are passed in using the following syntax 'name/regex'. text: ssh/ssh* cron/cron*

SYS_FIREWALL

Input Name Description Example Value
Firewall

Enables an iptables firewall for this server which allows port 22, 80 and 443 open by default. Use the 'sys_firewall::setup_rule' recipe to enable/disable extra ports. 

  • enabled - Set to 'enabled' to enable iptables
  • disabled - Set to 'disabled' to disable iptables
text: enabled

Launch the Server

  1. Go to the deployment's Servers tab and launch your Memcached server. When you view the input confirmation page, there should not be any required inputs with missing values.  If there are any required inputs that are missing values (highlighted in red) at the input confirmation page, cancel the launch and add values for those inputs at the deployment level before launching the server again. Refer to the instructions in Launch a Server if you are not familiar with this process.

Update the DNS Record

If the applications servers are connecting to the Memcached server using a DNS record, update the DNS record with the private IP address of the Memcached server. 

Create a Firewall Rule

If the cloud (of the Memcached server) does not support security groups you must use iptables to create the necessary firewall rule that will allow the application servers to connect to the Memcached server over the specified Memcached ports. If you are using the ServerTemplate's default settings, you must create two firewall rules for TCP port 11211 and UDP port 11211.

  1. Once the Memcached server is operational, go to the "current" server's Scripts tab.
  2. Run the sys_firewall::setup_rule operational script.
  3. Set the inputs accordingly.
    • Firewall Rule Port = 11211
    • Firewall Rule = enable
    • Firewall Rule IP Address = any
    • Firewall Rule Protocol = tcp
  4. Run the script again to allow access over UDP port 11211.

Launch and Connect Application Servers

Now that the Memcached server is operational and configured to accept requests from its related application servers, launch a few application servers and test their connections to the Memcached server.

 

You must to post a comment.
Last modified
10:41, 31 Oct 2013

Tags

Classifications

This page has no classifications.

Announcements

None


© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.