Memcached

Definition

A Memcached Resource is defined in convox.yml and linked to one or more Services.

resources:
  cache:
    type: memcached
services:
  web:
    resources:
      - cache

Containerized Options

By default, Convox runs Memcached as a container inside your Rack. Containerized Memcached does not use persistent storage. Cached data is lost if the container restarts.

resources:
  cache:
    type: memcached
    options:
      version: "1.6"
Attribute Type Default Description
version string 1.6 The Memcached Docker image tag. The default applies when the Resource is created
cpu int CPU request and limit for the container, in millicores
mem int Memory request and limit for the container, in MiB

On Rack version 3.26.0 or later, a new Resource without version runs 1.6. An existing Resource keeps the version it runs, which is 1.4.34 for a Resource created with the earlier default; set version to move it. See Containerized Versions. The 1.4.34 image has no arm64 variant, so on a Rack whose workload nodes can be arm64 a Resource still on 1.4.34 crash-loops with an exec format error. Set version: "1.6" on those Resources.

AWS ElastiCache Managed Memcached Resources

Convox allows the creation of Memcached resources via AWS ElastiCache. This provides a managed, scalable caching cluster. Use elasticache-memcached as the resource type:

resources:
  cache:
    type: elasticache-memcached
    options:
      class: cache.t3.micro
      version: "1.6.22"
      nodes: 2
      deletionProtection: true
services:
  web:
    resources:
      - cache

The nodes option is required for Memcached and specifies the number of nodes in the cluster.

ElastiCache Features

  • Scalable Memcached Clusters: ElastiCache Memcached supports multiple nodes for improved scalability, making it ideal for distributed caching workloads.
  • Import Existing ElastiCache Memcached Instance: Import an existing AWS ElastiCache Memcached instance into a Convox rack for management or access via linking.

ElastiCache Configuration Options

Attribute Type Default Description
nodes int Required The number of nodes in the Memcached cluster
class string Required The compute and memory capacity of the cache instance (e.g., cache.t3.micro, cache.m5.large)
version string Required The version of the Memcached engine (e.g., 1.6.22, 1.6.6)
deletionProtection boolean false Whether to enable deletion protection. Managed by Convox (not an AWS feature). Prevents the resource from being removed if accidentally deleted from convox.yml
encrypted boolean false Whether to enable encryption at rest
autoMinorVersionUpgrade boolean false Whether to allow automatic minor version upgrades
import string The cache cluster identifier for importing an existing ElastiCache instance. An imported instance is not deleted when the App is deleted

Deleting the App or removing the Resource deletes the cache cluster and, on Rack version 3.26.1 or later, the security group and cache subnet group Convox created for it. A subnet group named with the cacheSubnetGroupName option is never deleted. See Advisory for the wait and the rules that apply.

Command Line Interface

Listing Resources

$ convox resources -a myapp
NAME   TYPE                  URL
cache  elasticache-memcached memcached://hostname:port

Getting Information about a Resource

$ convox resources info cache -a myapp
Name  cache
Type  elasticache-memcached
URL   memcached://hostname:port

Getting the URL for a Resource

$ convox resources url cache -a myapp
memcached://hostname:port

Starting a Proxy to a Resource

$ convox resources proxy cache -a myapp
Proxying localhost:11211 to hostname:port

Proxying allows you to connect tools on your local machine to Resources running inside the Rack.