YugabyteDB
YugabyteDB is a PostgreSQL-compatible Open-Source Distributed SQL database. It adds horizontal scalability to applications built for PostgreSQL. We can use pREST works by connecting to any YugabyteDB node.
Start a YugabyteDB cluster with one of the Quick Start methods: YugabyteDB Documentation / Quick Start
Start prestd with the PostgreSQL connection string to one YugabyteDB node ( default port is 5433 )
Node locality
In a public or private cloud, there are multiple ways to scale out the pREST servers with YugabyteDB nodes:
Start
prestdwithPREST_PG_URLset to a cluster service (HA proxy, Kubernetes ClusterIP...) over the YugabyteDB nodesStart one
prestdfor each YugabyteDB node, with its local IPchange the
github.com/jackc/pgxdriver to the cluster-aware onegithub.com/yugabyte/pgx/v4, as in https://docs.yugabyte.com/preview/drivers-orms/go/yb-pgx/, so that it discovers all nodes of the cluster from any node.
With geo-distribution, it is recommended to co-locate the prestd server in the same zone as the database node(s) it connects to. This will lower the latency and increase availability.
Testing
Start a YugabyteDB cluster with one of the Quick Start methods: YugabyteDB Documentation / Quick Start
Start prestd with the PostgreSQL connection string to one YugabyteDB node ( default port is 5433 )
Example
Starting a single-node YugabyteDB cluster on Docker:
docker network create yb-net
docker run -d --hostname yb-tserver-n1 -p 7000:7000 \
--network yb-net yugabytedb/yugabyte:2.14.6.0-b30 \
yugabyted start --daemon false --listen yb-tserver-n1Starting prestd connecting to this node:
Creating a view (yb_servers() is a table function showing all YugabyteDB nodes in the cluster)
Querying this view through the REST API:
Starting two more YugabyteDB nodes (yb-tserver-n2 and yb-tserver-n3) to join the previous one (yb-tserver-n1):
Starting one prestd for each YugabyteDB node:
Querying any endpoint to read from the view
All works as with PostgreSQL, with the additional High Availability and Elasticity provided by YugabyteDB 🚀
Was this helpful?