Review: YugabyteDB does PostgreSQL proud

YugabyteDB 2.13 is a highly scalable, distributed version of PostgreSQL that combines compelling ideas from Google Cloud Spanner and Amazon Aurora—and serves as a Cassandra-compatible database too.

1 2 Page 2
Page 2 of 2

YugabyteDB integrations, drivers, and PostgreSQL compatibility

Since YugabyteDB is PostgreSQL-compatible, and PostgreSQL is well established and popular, YugabyteDB has lots of integrations with programs that use data, from Apache Kafka (as a connect sink) to WSO2 Identity Server. Similar logic explains YugabyteDB’s language support and client drivers.

Some of the drivers listed below are basic PostgreSQL client drivers. Some have been enhanced to support cluster awareness or topology awareness. Cluster awareness eliminates the need for a load balancer. Topology awareness makes geographically distributed applications much more efficient.

The list of ORMs and drivers below comes from the YugabyteDB GitHub repository.

PostgreSQL compatibility is a complicated issue. You can watch this video from April 2022 for a deep dive about exactly how YugabyteDB is and isn't PostgreSQL-compatible. You can also read the GitHub notes for a current roadmap and a list of recently completed features.

Running a Go app against a Yugabyte database

In real life, most people either program against YugabyteDB or run queries from a database client, which may range from a simple SQL IDE with Postgres compatibility to a BI or machine learning system. I decided to test out the YugabyteDB Go language sample. First I created a real YugabyteDB cloud cluster in the cloud UI.

yugabyte 13 IDG

Creating a useful three-node, fault-tolerant cluster with eight vCPUs, 16 GB RAM, and 400 GB of disk per node. This cluster costs $6 per minute when active, but only a few cents per minute when it is suspended.

I followed the instructions to download the cluster SSL root certificate from the Yugabyte cloud, and the sample app using Git. I placed the app in my Go source code path, under a github.com/yugabyte path, even though I knew I’d be turning Go 1.11 module handling on. Old habits die hard.

martinheller@Martins-Retina-MacBook github.com % mkdir yugabyte && cd yugabyte
martinheller@Martins-Retina-MacBook yugabyte % git clone https://github.com/yugabyte/yugabyte-simple-go-app.git && cd yugabyte-simple-go-app
Cloning into 'yugabyte-simple-go-app'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 59 (delta 32), reused 37 (delta 15), pack-reused 0
Receiving objects: 100% (59/59), 197.14 KiB | 3.65 MiB/s, done.
Resolving deltas: 100% (32/32), done.
martinheller@Martins-Retina-MacBook yugabyte-simple-go-app % ls
LICENSE     README.md    resources    sample-app.go

Then I used the information about the cluster to edit sample-app.go in Sublime Text to fill all the bits of the cluster path, and retrieved the Go language driver.

martinheller@Martins-Retina-MacBook yugabyte-simple-go-app % export GO111MODULE=auto
martinheller@Martins-Retina-MacBook yugabyte-simple-go-app % go get github.com/lib/pq
martinheller@Martins-Retina-MacBook yugabyte-simple-go-app % go run sample-app.go

>>>> Successfully connected to YugabyteDB!
2022/04/19 16:17:54 open ~/Dropbox/root.crt: no such file or directory
exit status 1

Whoops! I tried to use the ~ shortcut for my home directory, which doesn’t work in this context. On the positive side, the Go error handling did work. I then expanded the path to the cluster SSL root certificate in the editor, saved, and re-ran the program.

      sslRootCert = "/Users/martinheller/Dropbox/root.crt"

martinheller@Martins-Retina-MacBook yugabyte-simple-go-app % go run sample-app.go

>>>> Successfully connected to YugabyteDB!
>>>> Successfully created table DemoAccount.
>>>> Selecting accounts:
name = Jessica, age = 28, country = USA, balance = 10000
name = John, age = 28, country = Canada, balance = 9000
>>>> Transferred 800 between accounts.
>>>> Selecting accounts:
name = Jessica, age = 28, country = USA, balance = 9200
name = John, age = 28, country = Canada, balance = 9800
martinheller@Martins-Retina-MacBook yugabyte-simple-go-app %

Sure enough, that worked as documented once I got the path to the SSL certificate right.

yugabyte 14 IDG

Monitoring the three-node, fault-tolerant cluster during the Go language client testing. The relatively high write latency is related to the availability zone level fault tolerance, which positions the nodes in separate data centers.

Once that was done, I put the cluster to sleep. I didn’t want to incur $6-per-minute charges when I wasn’t using the cluster, and I also didn’t want to have to spend half an hour re-creating the cluster if I needed it later.

PostgreSQL, distributed

Overall, YugabyteDB is a very capable distributed PostgreSQL-compatible database as well as a very capable distributed Cassandra-compatible database. Note that the PostgreSQL and Cassandra data are not cross-compatible. You can use an external client to access each separately and perhaps join the data for queries, but that’s as far as it goes.

Compared to Google Cloud Spanner, which has its own dialect of SQL, YugabyteDB has the advantage of PostgreSQL compatibility. Compared to Amazon Aurora, YugabyteDB has the advantage of having distributed writes, not just distributed reads.

The comparison between YugabyteDB and CockroachDB as distributed PostgreSQL-compatible databases is much closer and trickier. One difference has to do with licenses.

Cockroach Labs chose to protect itself from predation by public clouds by adopting the Business Source License (BSL), which prohibits use of the otherwise open-source software as a service without a commercial license. The BSL was developed so that MariaDB could offer its database proxy server MaxScale as a service without predatory competition from cloud providers such as AWS. BSL-licensed software becomes fully open source after three years.

I honestly don’t think that the difference between a BSL license and a GPL (Apache v2.0) license matters to me as a developer. There probably are company lawyers and open-source advocates who differ with me, however. It certainly isn’t reflected in CockroachDB’s GitHub stars, which are three times YugabyteDB’s.

On the technical side, there are things that YugabyteDB does better than CockroachDB, and vice versa. For example, YugabyteDB doesn’t yet have full support for geospatial indexing, but CockroachDB does. YugabyteDB supports stored procedures, cursors, and triggers; CockroachDB doesn’t.

The differences are not always clear-cut, however. YugabyteDB just added change data capture (CDC), an enterprise feature useful for communication with Apache Kafka and data warehouses, as of version 2.13. Yugabyte claims that CockroachDB doesn’t do this, but the feature was added in CockroachDB 21.2, possibly after Yugabyte’s comparison table was written.

What distributed database would I recommend to your company? I’m afraid that it depends. As always, check the alternatives for the features and performance indicators you need, perform a proof of concept for each, and when you think you have a good candidate, roll it out slowly and carefully.

Cost: YugabyteDB and SQL Shell are free open source. Yugabyte Platform: Contact sales for paid support contract (still open source). Yugabyte Cloud: One free small cluster; other clusters depend on number of vCPUs and disk space per node, starting at $1,080 per month plus usage for three nodes with 2 vCPUs, 4 GB of RAM, and 100 GB of storage per node.

Platform: macOS, Linux, Kubernetes, Docker; AWS, GCP, Azure; Yugabyte Cloud currently runs on AWS and GCP.

At a Glance
  • YugabyteDB is a very capable distributed PostgreSQL-compatible database, supporting most PostgreSQL features including stored procedures, cursors, and triggers. It is also a very capable distributed Cassandra-compatible database.

    Pros

    • Distributed PostgreSQL- and Cassandra-compatible database
    • Available as open source
    • Available as a service
    • Most PostgreSQL features are supported
    • High scalability

    Cons

    • GiST indexes (for geospatial queries) not yet supported
    • Scalability is not as good as CockroachDB

Copyright © 2022 IDG Communications, Inc.

1 2 Page 2
Page 2 of 2
How to choose a low-code development platform