With the release of pgEdge Cloud Developer Edition Preview, we’re particularly excited about getting distributed Postgres in the hands of more developers. We think edge computing platforms like Cloudflare Workers® pair nicely with a Postgres database located geographically close to the end user, and we’re excited to see what folks will build with the power of these platforms together.

In order to demonstrate this, we’ve built and open sourced a sample application called pgEdge Northwind. This sample app uses Cloudflare Pages to serve a user interface, connected to an API running as a Cloudflare Worker, which leverages a pgEdge Cloud Developer Edition database to write and retrieve data.north_wind_sample_blog_picture1You can view a deployed version of the sample application at https://northwind.pgedge.com. It’s running on a pgEdge Developer Edition database deployed to Oregon, Northern Virginia, and Frankfurt.

Highlighting latency based routing

On the Dashboard, you’ll find a map that highlights pgEdge Cloud’s latency based routing, which ensures end users are routed to the nearest available database node for optimal performance.north_wind_blog_picture2

For your current session, you will see the latency from your machine to the Cloudflare Worker which serviced the API requests, which should be geographically close to your approximate location (provided by Cloudflare’s network).

You can also see the latency from the Cloudflare worker to the nearest pgEdge Cloud node which was chosen using latency-based DNS routing.

If you zoom in on your user icon, you should see the Cloudflare colocation which served your request.north_wind_blog_picture3In addition to your session, the map also shows other recent user sessions from around the world - highlighting how requests were routed via Cloudflare and pgEdge Cloud.

north_wind_blog_picture4Monitoring Query Performance

The Northwind database is a longstanding sample dataset, originally created by Microsoft, which can be easily added to your pgEdge Cloud database during setup.

As you browse the app, the database queries which are executed on each page by the API can be viewed on the dashboard, including their execution time. 

north_wind_blog_picture5Simple by design

We’ve tried to create the app in a way that ensures it is simple to run locally against your own pgEdge Developer Edition database, so you can get started without fully deploying all of the components to Cloudflare.

The sample app is written in Typescript and leverages NextJS, React, Mantine, and a few other packages. This allows us to keep the code in the repository focused on the interactions between the various components (Cloudflare Pages, Workers, and pgEdge Cloud).

If you’d prefer to bring your own frameworks and tools to test out pgEdge Cloud, we also provide a simple Cloudflare worker template to get started from scratch.

You can watch a 2-minute demo video or check out the full source code for the pgEdge Northwind app on Github. We’ll be adding more features to the sample app over time, and contributions are always welcome.

Cloudflare, the Cloudflare logo, and Cloudflare Workers are trademarks and/or registered trademarks of Cloudflare, Inc. in the United States and other jurisdictions.