Skip to content

Deploy Memcached

This guide shows you how to use Memcached, an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

To run it, follow these steps:

  1. Install the kraft CLI tool and a container runtime engine, e.g. Docker.

  2. Clone the examples repository and cd into the examples/memcached/ directory:

Terminal window
git clone
cd examples/memcached/

Make sure to log into KraftCloud by setting your token and a metro close to you. We use fra0 (Frankfurt, πŸ‡©πŸ‡ͺ) in this guide:

Terminal window
# Set KraftCloud access token
# Set metro to Frankfurt, DE

When done, invoke the following command to deploy this application on KraftCloud:

Terminal window
kraft cloud deploy -p 11211:11211/tls -M 256 .

The output shows the instance URL and other details:

Terminal window
[●] Deployed successfully!
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ name: memcached-arkv7
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ uuid: da436eca-bc64-46d7-a04c-72832652b10e
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ state: running
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ fqdn:
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ image: memcached@sha256:f53cdbce4dc185e8acc8ecb93a0ab0ba99085ca0837a0ad2062aae9e31382e58
β”œβ”€β”€β”€β”€β”€ boot time: 19.27 ms
β”œβ”€β”€β”€β”€β”€β”€β”€β”€ memory: 256 MiB
β”œβ”€ service group: weathered-smoke-hehsdinv
β”œβ”€β”€ private fqdn: memcached-arkv7.internal
β”œβ”€β”€β”€β”€ private ip:
└────────── args: /usr/bin/memcached -u root

In this case, the instance name is memcached-arkv7 and the service group is weathered-smoke-hehsdinv. They are different for each run.

To test the deployment, first forward the port with the kraft cloud tunnel command. Be sure to use the service group returned by the kraft cloud deploy command:

Terminal window
kraft cloud tunnel weathered-smoke-hehsdinv 11211:11211

Now, on a separate console, run the following commands to test that it works (you should see output when incrementing):

Terminal window
telnet 11211
set test 0 0 1
incr test 1
incr test 1

To exit telnet run:

Terminal window
Ctrl + ]
Ctrl + C

To disconnect, simply kill the tunnel command with ctrl-C

At any point in time, you can list information about the instance:

Terminal window
kraft cloud instance list
memcached-arkv7 weathered-smoke-hehsdinv.fra0.... running 11 minutes ago memcached@sha256:f53cdbce4... 256 MiB /usr/bin/memcached -u root 19266us

When done, you can remove the instance:

Terminal window
kraft cloud instance remove memcached-arkv7

Customize your Application

To customize the application, update the files in the repository, listed below:

  • Kraftfile: the KraftCloud specification, including command-line arguments
  • Dockerfile: In case you need to add files to your instance’s rootfs
spec: v0.6
runtime: memcached:latest
rootfs: ./Dockerfile
cmd: ["/usr/bin/memcached", "-u", "root"]

Learn More

Use the --help option for detailed information on using KraftCloud:

Terminal window
kraft cloud --help

Or visit the CLI Reference.