Select Star Logo
September 9, 2021

HarperDB is Collapsing the Stack: Introducing Custom Functions

Generic Placeholder for Profile Picture
September 9, 2021
Jacob Cohen
Director IT & Operations at HarperDB

Table of Contents

Introducing the newest innovation from HarperDB: HarperDB Custom Functions. With the release of HarperDB 3.1 users are able to define their own API endpoints within HarperDB. What does that mean for you? HarperDB grows from a distributed database to a distributed application development platform with integrated persistence - one that can serve as a single solution for all of your backend needs. We’re collapsing the stack!

Alright, alright, what’s the big deal? Up until 3.1, in order to power an application you would need to deploy and host your backend API code on additional servers, then have them call out to HarperDB for database needs. This is a pretty typical software stack, but at HarperDB, we’re far from typical. We’re constantly innovating and changing the game. Custom Functions enable developers to build their entire application backend in one place. Oh yeah, and it’s faster, significantly faster! Traditional architectures naturally introduce latency as data moves across multiple servers through a local network or potentially even the Internet. HarperDB is collapsing the stack onto a single server, which eliminates any and all network latency. This frees up headroom for achieving higher throughput from a single server. Capitalizing on HarperDB’s already powerful horizontal scalability, this means you can now distribute both your APIs and your database to the edge.

For those familiar with modern cloud architectures, Custom Functions are just like AWS Lambda functions. For those familiar with relational databases, they’re like Stored Procedures. You define your logic and choose when to execute it. At a high level it’s as simple as that! They’re low maintenance and easy to develop. You can develop HarperDB Custom Functions in the Studio or in your own IDE and Version Management System. HarperDB Custom Functions can be maintained like any other development project, in fact, the sample Custom Functions provided in the Studio are generated from our public GitHub repository. That means you can develop, maintain, and deploy your HarperDB Custom Functions code just like any other development project, so you don’t have to deviate from your existing development practices. That’s great news!

HarperDB Studio Functions Editor
HarperDB Studio Functions Editor

What makes Custom Functions so powerful? They leverage the full power of Node.js and Fastify. HarperDB Custom Functions projects are effectively just Node.js projects, which means you can leverage the npm ecosystem, opening the doors to fast and efficient development. Fastify serves as the basis for the webserver, which means you can define and build a fully functional REST API with all the bells and whistles you’d expect. The key differentiator is that these Fastify routes have direct access to HarperDB core methods, bypassing the HarperDB API, and instead interacting directly with HarperDB on the same machine.

WebStorm IDE with HarperDB Functions Project
WebStorm IDE with HarperDB Functions Project

By collapsing the stack, we deliver unparalleled performance and efficiency out of the box. Let’s take a look at some different ways Custom Functions can be used. I’m not going to cover everything here, in fact, I’m sure there are plenty of options that I haven’t even thought of.

  • Integrate with third-party apps and APIs: Seamlessly connect third-party/external data with data stored in HarperDB within a single function.
  • Utilize third-party authentication: Tightly integrate with third-party application providers to validate user requests within your API.
  • Define your own database functionality: HarperDB is always adding features, but let’s say there’s a feature you need that’s missing. Build a HarperDB Custom Function to solve the problem. For example, if you need to enforce row-level security based on a user account, write a function!
  • Serve a website: Custom Functions can serve static content and serve as backend APIs, which means you can fully power a website or web app all with HarperDB.

These are just some of the ideas we’re kicking around with HarperDB Custom Functions. We also hosted a livestream event where you can watch a live product tour! We look forward to hearing what the HarperDB community can build. Please share any ideas you have in the comments, I’m eager to hear what the community has to say!

Since this will be the initial release of HarperDB Custom Functions, please let us know what else you’d like to see in future releases.

While you're here, learn about HarperDB, a breakthrough development platform with a database, applications, and streaming engine in one unified solution.

Check out HarperDB