Skip to content

Instantly share code, notes, and snippets.

@knazarov
Last active February 7, 2018 06:26
Show Gist options
  • Save knazarov/ba0eae744ee38d54eef71b2acacbdbf8 to your computer and use it in GitHub Desktop.
Save knazarov/ba0eae744ee38d54eef71b2acacbdbf8 to your computer and use it in GitHub Desktop.

Tarantool Cloud

asciicast

This is a master class about Tarantool Cloud.

Star, share, raise issues and send pull requests :)

Here you will find key commands I eneted on my notebook during the demo, as well as any reference materials we will be going over.

Quickstart

This will run Tarantool and immediately put you into command-line prompt.

docker run --rm -t -i tarantool/tarantool

Press ^C to exit.

Running Docker on your machine

To do what I just did, you will need to install Docker:

Expose Tarantool port to local machine

docker run --rm -t -i -p 3301:3301 tarantool/tarantool

And then connect to port 3301 on localhost!

Running different versions of Tarantool

docker run --rm -t -i tarantool/tarantool:1.7

or

docker run --rm -t -i tarantool/tarantool:1.5

Customizing settings

docker run --rm -t -i -e TARANTOOL_SLAB_ALLOC_ARENA=0.7 tarantool/tarantool

Running master-master scenario

Save the following as docker-compose.yml:

version: '2'

services:
  tarantool1:
    image: tarantool/tarantool:1.7
    environment:
      TARANTOOL_REPLICATION_SOURCE: "tarantool1,tarantool2"
    networks:
      - mynet
    ports:
      - "3301:3301"

  tarantool2:
    image: tarantool/tarantool:1.7
    environment:
      TARANTOOL_REPLICATION_SOURCE: "tarantool1,tarantool2"
    networks:
      - mynet
    ports:
      - "3302:3301"

networks:
  mynet:
    driver: bridge

And then run:

docker-compose up

You will have 2 containers with Tarantool 1.7 with master-master replication.

Running taranool-memcached instances in tarantool-cloud

Go to http://tarcl1.dev.mail.ru. (Sorry guys, only internal page at this time)

Press "Create" and wait for 20 seconds. You will get a fault-tolerant memcached instance.

I will be using Python, but you can use any language.

easy_install pymemcache

Then write the following python code (replace 10000 with your own port):

from pymemcache.client.hash import HashClient

client = HashClient([
    ('tarcl1.dev.mail.ru', 10000),
    ('tarcl2.dev.mail.ru', 10000)
])

client.set('some_key', 'stored value')
result = client.get('some_key')
print(result)

How the cloud is implemented

2 services:

The 'exposer' is needed to automatically reroute traffic from broken to live instances. Everything else is done with Instance Manager.

Spin up tarantool cloud on your machine, in one command

Clone the repository

git clone https://github.com/tarantool/cloud.git
cd cloud

Now use docker-compose to run the cloud:

docker-compose up

In a few seconds, go to http://localhost:5061 and try creating Tarantool instances.

Create instances from command line

./taas -H localhost:5061 run --name myinstance 0.3

Future

There are solutions for sharding and dynamic code reloading, but they don't give you the full solution. We will change that.

So, in future cloud project will give you:

  • Tarantool binary protocol
  • Transparent horizontal scaling
  • Code deployment (blue/green and feature flags)
  • App marketplace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment