Zudoku
Guides

DragonflyDB

This guides shows you how to deploy Dragonfly, a simple, performant, and cost-efficient in-memory data store.

To run it example, 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/dragonflydb/ directory:

TerminalCode
git clone https://github.com/kraftcloud/examples cd examples/dragonflydb/

Make sure to log into Unikraft Cloud by setting your token and a metro close to you. We use fra0 (Frankfurt, ๐Ÿ‡ฉ๐Ÿ‡ช) in this guide:

TerminalCode
# Set Unikraft Cloud access token export UKC_TOKEN=token # Set metro to Frankfurt, DE export UKC_METRO=fra0

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

TerminalCode
kraft cloud deploy -p 443:6379 -M 512 .

The output shows the instance URL and other details:

TerminalCode
[โ—] Deployed successfully! โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ name: dragonflydb-10zgk โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ uuid: 6282ef0c-2161-494c-a3f3-2d16055096c2 โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ state: running โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ url: https://dry-moon-x6bgl6c0.fra0.kraft.host โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ image: dragonflydb@sha256:21e6d3ff1f86292e14266bcf5c6e73d3b7a86a0ec4102c66a0961373af743f19 โ”œโ”€โ”€โ”€โ”€โ”€ boot time: 28.74 ms โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ memory: 512 MiB โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€ service: dry-moon-x6bgl6c0 โ”œโ”€โ”€ private fqdn: dragonflydb-10zgk.internal โ”œโ”€โ”€โ”€โ”€ private ip: 172.16.6.5 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ args: /usr/bin/dragonfly --maxmemory 256MiB

In this case, the instance name is dragonflydb-10zgk and the URL is https://dry-moon-x6bgl6c0.fra0.kraft.host. They are different for each run.

Use curl to query the Unikraft Cloud instance of Drangonfly.

TerminalCode
curl https://dry-moon-x6bgl6c0.fra0.kraft.host
Code
<!DOCTYPE html> <html><head> <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/> <link href='https://fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'> <link rel='stylesheet' href='http://static.dragonflydb.io/data-plane/status_page.css'> <script type="text/javascript" src="http://static.dragonflydb.io/data-plane/status_page.js"></script> </head> <body> <div><img src='http://static.dragonflydb.io/data-plane/logo.png' width="160"/></div> <div class='left_panel'></div> <div class='styled_border'> <div>Status:<span class='key_text'>OK</span></div> <div>Started on:<span class='key_text'>1970-01-01T00:00:00</span></div> <div>Uptime:<span class='key_text'>474611:3:38</span></div> <div>Render Latency:<span class='key_text'>110 us</span></div> </div> </body> <script> var json_text1 = {"engine": { "keys": 0,"obj_mem_usage": 0,"table_load_factor": 0 }, "current-time": 1708599818}; document.querySelector('.left_panel').innerHTML = JsonToHTML(json_text1); </script> </html>

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

TerminalCode
kraft cloud instance list
Code
NAME FQDN STATE CREATED AT IMAGE MEMORY ARGS BOOT TIME dragonflydb-10zgk dry-moon-x6bgl6c0.fra0.kraft.... running 1 minute ago dragonflydb@sha256:21e6d3... 512 MiB /usr/bin/dragonfly --maxmemor... 28740us

When done, you can remove the instance:

TerminalCode
kraft cloud instance remove dragonflydb-10zgk

Customize your Application

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

  • Kraftfile: the Unikraft Cloud specification, including command-line arguments
  • Dockerfile: In case you need to add files to your instance's rootfs

Learn More

Use the --help option for detailed information on using Unikraft Cloud:

TerminalCode
kraft cloud --help

Or visit the CLI Reference.

Last modified on