Funtap - stock.adobe.com
PlanetScale reaches to the edge with serverless driver
The vendor continues to build out its database-as-a-service platform and is now aiming to make it easier for developers to connect to edge services.
PlanetScale released a new capability that makes its database more easily accessible from serverless edge deployments.
An emerging deployment paradigm for applications is to use serverless edge services, such as Cloudflare Workers, Vercel Edge Functions, and Netlify Edge Functions. Those services are largely based on JavaScript and enable organizations to run applications at the edge of a network.
A challenge to date with the edge services has been the database layer, which is where the PlanetScale serverless driver, released on Aug. 18, fits in. The driver creates a new layer to the PlanetScale database that enables queries over JavaScript in an approach that can integrate with edge deployment platforms.
PlanetScale is increasingly targeting developer-driven database deployment, an area where it competes against serverless database vendor FaunaDB, which is also accessible over JavaScript.
Among the users of the PlanetScale database looking to use the PlanetScale serverless driver is online sports and popular culture news service Barstool Sports.
The company had been running on Amazon Aurora for its MySQL database workloads and ran into scaling and performance problems, said Andrew Barba, head of engineering at Barstool Sports.
Amazon Aurora, like PlanetScale, is intended to be compatible with MySQL. In 2021, Barstool moved to PlanetScale after the database vendor launched its fully managed database-as-a-service offering.
The new PlanetScale serverless driver is a particularly notable development for Barstool. In recent years, there's been a growing trend of organizations moving compute as close to users as possible -- the edge. Barstool has been looking forward to PlanetScale serverless driver for JavaScript, as Barstool continues to build out and optimize its operations, Barba said.
Andrew BarbaHead of engineering, Barstool Sports
"Similar to how compute is moving the edge, it’s time for databases to move to the edge as well," Barba said.
PlanetScale serverless driver enables JavaScript API
With a traditional application stack that runs on a server, a developer would have access to a full set of APIs that enable connections to any database.
Serverless edge services are using JavaScript and WebAssembly runtimes that don't have the same access as traditional application stacks. The serverless edge environments have traded off full API access for speed and security, said Nick Van Wiggeren, vice president of engineering at PlanetScale.
Edge services, including Cloudflare Workers, have provided users with somewhat complicated workarounds to connect to different types of databases, Van Wiggeren noted. PlanetScale wanted to provide a mechanism for edge services that will work with any edge service and be easy to configure.
For PlanetScale, the hardest part of building out the serverless driver was figuring out how to expose all the capabilities of the database with an API that connects over HTTP. It's a process that took PlanetScale about six months as it built out capabilities in the database and its platform infrastructure.
"We started out and realized what we actually needed is a new load balancer, a new front door into the database that can serve queries over HTTP," Van Wiggeren said. "We weren't willing to compromise on security or functionality, so we actually built and architected from the ground up, our very own HTTP load balancer for MySQL databases."
How it PlanetScale serverless driver works with JavaScript
The new load balancer for serving HTTP database requests is only one part of enabling serverless edge capabilities; the other key part is JavaScript.
The actual driver for the new PlanetScale service uses the Fetch API standard in JavaScript to enable HTTP connections. The cross-platform nature of Fetch is why PlanetScale is using it, Van Wiggeren said, adding that the PlanetScale serverless driver is essentially a wrapper around the Fetch API that handles all database query components, using Fetch to connect to the database over HTTP.
"The reason we're so specific about Fetch is because that's what's cross-platform -- whether you're using JavaScript in the browser, whether you're using JavaScript on the Cloudflare Worker or a Vercel Edge function, Fetch is the standard for how you make that request," he said.
Looking forward, there are still some areas PlanetScale might be looking to address in term of API connectivity. One such area could be GraphQL, another API approach for connecting and querying data.
"It's an area that we're really interested in," Van Wiggeren said of GraphQL. "It's definitely an attractive and, I think, very interesting way that people are leveraging their databases."