m
Our Mission Statement
This is Photoshop's version of Loremer Ipsn gravida nibh vel velit auctoregorie sam alquet.Aenean sollicitudin, lorem quis bibendum auci elit consequat ipsutis sem nibh id elit.
Follow Us
Top
Go Faster! - VoltDB
10540
post-template-default,single,single-post,postid-10540,single-format-standard,mkd-core-1.0,highrise-ver-1.0,,mkd-smooth-page-transitions,mkd-ajax,mkd-grid-1300,mkd-blog-installed,mkd-header-standard,mkd-sticky-header-on-scroll-up,mkd-default-mobile-header,mkd-sticky-up-mobile-header,mkd-dropdown-slide-from-bottom,mkd-dark-header,mkd-header-style-on-scroll,mkd-full-width-wide-menu,mkd-header-standard-in-grid-shadow-disable,mkd-search-dropdown,mkd-side-menu-slide-from-right,wpb-js-composer js-comp-ver-5.4.2,vc_responsive
VoltDB / Best Practices  / Go Faster!

Blog

Go Faster!

Several days ago, I saw a tweet fly by in my stream. The creator of Node.js, Ryan Dahl, was recommending Golang for any new server-side projects. While Node.js is still very popular, the growth in microservices has been driving a more wide-spread adoption of Golang for these projects.

Golang is becoming more and more appealing due to its ease of use, high performance, and lightweight architecture. Whether you are writing a simple script for a single task, a microservice in a pipeline, or a full-fledged enterprise service, Golang can do the job, quickly and efficiently. That’s why we are seeing more interest in using Golang to operate and communicate with VoltDB.

VoltDB has had a Golang driver using the native wire protocol for several years. It started out as an innovation week project by one of our developers. As our customers began to use it, we started supporting it officially and added enterprise features like client affinity and SSL to the driver.

We recently updated the Golang driver again. This latest release provides a significant performance boost, as well as many other improvements. To do that, we called on a Golang expert who lives half a world away in Tanzania, software engineer Geofrey Ernest.

Geofrey identified some bottlenecks and optimized the driver from the bottom up. The end result is very promising. It dramatically improves the throughput for both the blocking mode and the non-blocking mode. Not only that, it also reduces the memory consumption of the driver by up to 200 fold. The following table summarizes the performance improvements.

The following test results were produced using the Voter sample application running on a single node VoltDB and a different node for the Golang test application. Both nodes have 16 physical CPU cores. The Golang application calls a single read-write stored procedure repeatedly with different parameters each time.

Blocking
Non-Blocking

Throughput

Memory

Throughput

Memory

Before

130,000 tps6,656MB260,000 tps5,324MB

After

240,000 tps33MB450,000 tps770MB

With Geofrey’s optimizations, the non-blocking mode achieved 450,000 stored procedure calls per second! Each stored procedure call is a fully serializable transaction with at least three SQL statements.

The VoltDB Golang driver implements the interfaces specified in the Golang database/sql/driver package. If you are familiar with the usage of the database/sql package, then using the VoltDB Golang driver will be a breeze. The following code snippet connects to the VoltDB server, calls a stored procedure and handles the result.

The database/sql/driver package defines a blocking interface for interacting with databases. It is sufficient for the majority use case. You can easily create goroutines to make database requests without blocking the main thread of execution.

However, it may be hard to write a highly concurrent program that interacts with the database with limited resources (CPU & memory) using this model. An alternative is to use a non-blocking model to interact with the database and limit the number of goroutines running at the same time.

To do this, the VoltDB driver comes with a non-blocking mode. All you need to do is to create an object that implements the callback interface defined here. The following code snippet shows how to call the same “HELLOWORLD.select” stored procedure shown above in non-blocking mode.

If you are interested in the Golang driver or have used the old driver, I strongly encourage you to try the new driver out at https://github.com/VoltDB/voltdb-client-go. Thanks to Geofrey’s great work, there are other stability and usability improvements besides performance. Any feedback is welcome.