I am investigating DBaaS (Cockroach Serverless) and Faas (Cloudflare Workers) but not yet successful in finding how to call CRDB from a Worker (or any FaaS, for that matter). Has there been any success marrying the two? Any resources that help bridge this gap (even if on some other FaaS)?
I succeeded in calling CRDB from Deno Deploy, which is in BETA and has no current pricing model in place. I am looking to try Denoflare (from Cloudflare) next.
What Deno Deploy made easy was it handled all the dependencies via ES imports and avoids the need to bundle. Big help. I’m hoping Denoflare is similar in this regard.
Hi Mario. I love your instinct to connect to CockroachDB Serverless from a FaaS.
For the short term, connecting directly from Cloudflare Workers isn’t going to work well because CockroachDB requires a TCP connection but Workers currently only supports HTTP. It is possible to bridge the gap using something like Cloudflare’s Relational Database Connectors, but it’s a somewhat involved option because you’ll need to run
cloudflared yourself. We’re currently brainstorming ways to make FaaS and DBaaS a smoother pairing.
Instead of running a proxy layer, I think you’re exactly on the right by choosing to use a FaaS option that will let you use normal Node.js libraries and TCP. Deno Deploy is a great choice, as are AWS Lambda and Google Cloud Run.
Thanks, Paul. I just spent the evening trying to make CRDB work with Denoflare and then this
Cloudflare article. So I did discover, the hard way, what you just explained. It takes some doing to deploy a couple long-running cloud fixtures for tunneling which appears to not be very serverless.
I chose Deno Deploy and Cloudflare for their snappy v8 isolates. I had hoped to seat CRDB into that space. Even though I got it working in Deno Deploy, it probably wasn’t meant to be.
I like how Cockroach was modeled after Postgres SQL. This choice makes using it safer than other vendors since any models and data can be easily ported to an actual Postgres DB.
I’m subscribed to the thread so I’ll be notified when hitting an RDBMS from a Function becomes a more realistic possibility. Have a good one!