From laptop to cluster with the same binary

Develop with teseladb dev on your machine and take the same thing to three machines without changing your code.

TeselaDB

TeselaDB

TeselaDB team

2 min read

  • development
  • cluster
  • deployment

The binary you use to develop is the same one that runs in production. What changes between your laptop and a three-machine cluster are the start options, not your application.

On your machine

teseladb dev starts several nodes in a single process, with the data in memory. Node k listens on the client port plus k, so the three nodes started by the command below answer on the ports from 27017 to 27019 of your machine:

Shell
teseladb dev --nodes 3

This development cluster uses neither TLS nor users, so you connect with mongosh "mongodb://127.0.0.1:27017,127.0.0.1:27018,127.0.0.1:27019/".

On three machines

In production, each node is a teseladb start on its machine. The first one creates the CA and the root user; the others join with a single-use enrolment token and get their certificate. The cluster spreads the ranges and their leaders across the three without you moving data by hand.

What changes in your application

Only the connection string changes: it now carries the three nodes, tls=true, the cluster CA and a user with the roles it needs, while the code of your application keeps its queries and its indexes as they were. For the whole path, follow Quick start with a local cluster and then Three machines with systemd.

All posts