Skip to main content

over 3 years ago Syntax Podcast

“Serverless” Databases

Wes Bos

Wes Bos Host

Scott Tolinski

Scott Tolinski Host

Topic 0 20:47

Other proprietary and open source options

Scott Tolinski

Remember that?

Wes Bos

like a pretty good option as well. They got some And then there are also lots of open standards like, with most traditional databases, Ken. So that is Yeah. At least as I understand it, not as big of a deal 40% The connection from your cell phone to the actual server. So that's called backbone or backhaul, meaning that like these every ISP Serverless.

Wes Bos

does, but in Postgres instead of my SQL.

Scott Tolinski

we had a security breach email, so it kinda made me a little bit concerned for them. But,

Wes Bos

big big They may have just taken that out of

Scott Tolinski

design on this website.

Scott Tolinski

Stores the data in a graph.

Scott Tolinski

some heavy hitters. Wes Guillermo,

Scott Tolinski

really great

Wes Bos

Yeah.

Scott Tolinski

Yeah. That was a while ago. So Oh, yeah? Oh, at least they sent it. Yeah. No. Oh, no. No kidding. Yeah. Because it's not about Yeah. This railway seems pretty cool. There's a a lot of companies in the space right now. When I used it, the,

Wes Bos

Because, like, remember, we were like, what the heck is a graph? I know.

Scott Tolinski

Have you seen Fauna? Is I thought Fauna was like a graph database.

Scott Tolinski

Yeah. I actually tried out Railway before, and I found the experience to be really nice. But I I got infrastructure and then oh, yeah. Wait. That seems like a harder task than just hacking together a quick little demo. Yeah. Redis, Cassandra,

Wes Bos

Tom Preston Warner. Oh, yeah? Yeah. Awesome.

Scott Tolinski

It is

Scott Tolinski

After, like, a couple of months of being on Railway, I did get, like, a at least they're fat pipes, though, you know, they're fat pipes. Exactly. Exactly.

Scott Tolinski

You're not gonna lose the special sauce if you wanna host it yourself. Us. Next one is Neon at Neon dot tech,

Wes Bos

serverless Postgres.

Scott Tolinski

well. Yeah.

Wes Bos

which we talked about. You don't have to have a connection. There's no connection pooling. It's just request in, request out, and it has GraphQL and that is

Scott Tolinski

which seems pretty good. It's on a super base.

Scott Tolinski

Let's see. No. It just says GraphQL. Okay. I was thinking that Fauna was, like,

Wes Bos

is another popular one. It's distributed, so I think they will distribute them around the world. It's SQL.

Scott Tolinski

This just this seems like it's, Yeah. It's its own NoSQL. I don't see any word where it says graph database on their site. That's the only reason why it has, like, hesitate on that. Oh, yeah. Yeah. I See, that's like a lot of the other graph databases. Like, graph database, you know, and

Wes Bos

It says you bring the code, we'll handle the rest. So they they are a host, a deployment Yeah. Yeah. So I asked, like, what should I use?

Topic 1 19:06

Overview of Fauna serverless database

Wes Bos

they got that this kinda locked in. So let let's talk about them really quickly. Cloudflare has 2 solutions. They just rolled it out last week. D one unreal. It's so Obviously, It handled it. No problem.

Wes Bos

40% Supabase,

Wes Bos

Is there,

Wes Bos

And those things are both built for Cloudflare, which is serverless edge the package because it's it's a MySQL database. So you can literally you could use You could use Prisma if you wanted. Yeah.

Wes Bos

like, nothing, Just to just show, like, some load on there. So I made a simple little website with Deno that is server rendered, I put that on begin.com So the Yeah. Tell them. The other thing that we should know about edge databases is that These entirely. Right? around building your website. They encourage you to Think of your website as a slice machine, framework. Actually, it's from Planet Yeah. It's a node package, but I ran it in Deno no problem. I deployed it to Deno Deploy, Boss and Scott

Wes Bos

SQL based database? It still is proprietary, So that is a very good option. AWS DynamoDB. And then they have AWS hosting. We'll talk about all the solutions in just a second.

Scott Tolinski

And I remember when you did that. That was Yeah. A fun idea. It got, like, half a 1000000 hits and didn't even stumble, by understanding

Wes Bos

but it is an SQL database.

Wes Bos

Scalable they will try to scale that up for you,

Topic 2 08:05

Fast deployment times with Deno Deploy

Scott Tolinski

instances or you access that database instance. And then anytime you Wow.

Wes Bos

So the solution I would pick Atlas that actually Scott and I both use. They now offer a serverless offering,

Wes Bos

You're not going to be able to connect to your database which is essentially every little you either That is running. They are all connected on fat pipes, and they can talk to each other much more quickly than your cell phone That is half underground in the subway, Which is amazing. I remember Brian Lewer, who runs begin, was like, we were watching that. We were wondering if we'd have to scale it up, but Then you've just introduced a single is that,

Scott Tolinski

connection.

Wes Bos

Your your app starts. Right? And when your app starts, you connect to your database, and then you have this reference to your database but other than that, it was I only went Like, I can run at my SQL commands, but they will handle all of the connection pooling for you.

Wes Bos

that that working. There's generally a limit to the amount of at times that you can connect to an actual database.

Wes Bos

you connect to them.

Wes Bos

tweets out your your thing, and all of a sudden you have a 1000000 people on your website in one go.

Wes Bos

So in my case, I use PlanetScale

Wes Bos

a 100 times without Deno is

Wes Bos

that is running westb0 s s.com It's connectionless, I thought, okay. I need to I was just realigning in. Yeah. I need to do something about it's probably a lot of you listening to the podcast because

Scott Tolinski

Run your queries. It's using that already preexisting

Wes Bos

and you could query and pull data and save data. Right. Like you're used to that, right? Scott, I mean, you it doesn't matter that it's MongoDB. All databases kind of work that you do one connection. You you run a server somewhere because of the type of query I wrote, they had to queue up.

Wes Bos

40, 50 different things running or if you have a spike

Scott Tolinski

You export whatever database

Wes Bos

Yeah. Right. A single point. Yeah. Yes.

Wes Bos

and then you

Wes Bos

In traffic, somebody very popular that has to, like, replicate extremely quickly across .com, I think if I were to do it today,

Topic 3 18:23

Benefits of open standard databases

Wes Bos

database because of all the benefits. We're gonna go all in on it. This is not going anywhere. Other people say, no problem. Actually, I went over the free plan on Deno. And, like, I don't I didn't tell Deno folks I'm gonna do this or whatever. I just signed up and deployed it within like 10 minutes. And Dino handled it without,

Wes Bos

We'll lock into the proprietary is running on probably 40 different machines around the world, Colorado, I hit the 1 here in Toronto, and somebody else will hit 1 in Europe depending on on where they're going. And so I I've been feeling pretty comfortable with serverless over the last couple years, but The database aspect of it has always been but it seems like a really good option.

Wes Bos

CS service as well that will allow you to scale up. And I always think about, like, what happens if I wanna move out of this type of thing? And for a lot of people, I say, it's fine. We'll and then you you jump into your Next or Nuxt or or or React or whatever it is that you're working with, It. So as long as you you you connect to it in a specific way that you show that you're doing connection pooling, rather than you having to run from some infrastructure there. So you you still are doing it, but they are sort of, like, handling that Sauce under the thing, which I think is a really neat and all of those machines need to connect to database. So that's kind of our next step is that, like, why can't you just use a regular But at a certain point, the database at least at least from my and then I, and A lot of you say, alright. Well, that's how you spell boss. Right? My boss is one s. So I thought I'll make a silly little website as I do, 250,000 It. So, that is pretty popular as well, Okay. The initial request from your phone to the server, but there still will be some connect built baked into it. So that seems like that that I think pretty sure this is all, Like, will this really hold up? And like like, obviously, I'm nowhere near, I decided to go straight into the database. That is not a limitation of 20,000, you shouldn't have to change your too much database code. Right? Yeah. No kidding.

Wes Bos

Postgres, which I That's the bottle that's kind of the bottleneck at at that point is that, okay, now you have a single server. So so the solution to that is,

Wes Bos

because the rest of the 20% was scattered on the rest of the stuff that I have here. So I was, on all their servers around the world, and it's really cool. It shows you popping up in Africa and in Europe and in,

Wes Bos

they are like a Sivana seems like a good Supabase SQL relational database.

Topic 4 00:30

Talking about serverless databases

Scott Tolinski

exactly why users are leaving at various points in your funnel.

Scott Tolinski

As in what LogRocket gives you is a set of replay tools that allow you to understand conversion,

Scott Tolinski

increase it. Your conversion and optimize your adoption

Scott Tolinski

Databases.

Scott Tolinski

allow you to understand what users are doing user behavior, it. But also

Scott Tolinski

Now there's also user experience analytics, front end performance monitoring, and so much more. So head on over to logrocket.comforward/syntax,

Scott Tolinski

And you'll get 14 days for free.

Scott Tolinski

understand where there are issues.

Scott Tolinski

In fact, you can get access to a scrubbable video replay to solve bugs that gives you then access to the network tab error log and all that and more.

Scott Tolinski

LogRocket is an incredible service to really get visibility in how people are using your thing.

Scott Tolinski

serverless

Scott Tolinski

You know, when you get into serverless anything, one of the question that always comes up is, what about databases? So we're gonna be answering that question for you and quite a bit more today. This episode is sponsored by 2 amazing companies today, Prismic and LogRocket.

Wes Bos

We are also sponsored by Prismic.

Topic 5 26:50

Preferred solutions for new serverless projects

Scott Tolinski

Word. Cool. Well, thank you so much for for this.

Scott Tolinski

for a full archive of all of our shows. And don't forget to subscribe in your podcast player it. Or drop a review if you like this show.

Scott Tolinski

Head on over to syntax.fm

Scott Tolinski

I I've left smarter.

Wes Bos

something that was either Postgres in this case, is that if you have a Slim experience. There's probably people that are much larger experts than me learning in 1 week.

Topic 6 03:27

Benefits of serverless computing

Wes Bos

I got an email the other day. It says, hey. Your website's down. And somebody screenshotted it, and it was west b o s s s.com, and I realized I had not been redirecting that. So I looked at the cloud flare stats and, like, seems like a, really good solution. So, integration database.

Wes Bos

something like 400 people a week were going to the wrong domain.

Wes Bos

onto 40 different servers around the world. And And they said, no. It's not a connection pooling limit, but Toronto and in all all around the world, and it's it's actually kind of cool. So that code Did they do images as well? I'm curious.

Wes Bos

Generate a PDF or send a push notification Really gorgeous. That is a very nice website. Oh, cool. Yeah, they did. They're doing an awesome, awesome job. Railway is another one that people were recommending. I think Railway is

Wes Bos

And However, connections, meaning that you send a request the database the database handles the request and then sends a response back much like a HTTP and what are what are the other ones here? Supabase, Neon.

Wes Bos

where the function is running is very important, meaning that your edge function

Wes Bos

a little bit, like, shaky to me. So I thought, okay. Every time I come up with a new project that I need to do,

Wes Bos

the you you let's say you have some code that will, 327,000 So apparently, that will go even higher on a paid plan. So I thought that was kind of cool. And I think you probably like, we had the show on serverless limitations.

Topic 7 02:49

Redirecting traffic from wrong domain names

Scott Tolinski

why is a database

Scott Tolinski

and whatever this idea of serverless database stuff goes. So I am going to be asking you some dumb questions as you talk through some of this stuff, and, hopefully, that can provide some insight for the listener who might also not know anything about this. So Do you wanna maybe give a little bit of an overview as terms of, like,

Scott Tolinski

myself, am admittedly

Scott Tolinski

in both serverless

Scott Tolinski

Have to be different for serverless solutions? Or what's what why does it have to be different? Yeah. So I I think, like, real quick, a host.

Topic 8 12:36

Edge database replication is tricky

Scott Tolinski

the latency that you're removing by being at the edge in the 1st place, if it's having to then do Some other connections and talking before that data is,

Scott Tolinski

secret sauce was. I thought they were doing, like, an edge a database,

Wes Bos

but it's just connection pulling. No. They do they do a lot more than that. They do scaling and and whatnot. And I I talked to a couple of people from

Scott Tolinski

Any of

Wes Bos

Don't isn't that sort of foregoing the whole benefit of Edge? Because the idea with Edge is that the code is running as close to AU as possible, right?

Wes Bos

I'll talk about because mine did go down.

Scott Tolinski

all of the instances. Right? Right. And at that point, does that negate

Wes Bos

I'll talk about that in just a second.

Scott Tolinski

I always thought this is what PlanetScale's

Scott Tolinski

or or locked in there. I forget what the The term is that they typically use. Also, I I always thought this is what

Wes Bos

Across the globe? I think that's kind of tricky because, like, if I update mine databases, use a service that will be able to handle and scale up the connection pooling for you.

Scott Tolinski

you know Yeah. Considered to be official You can also

Topic 9 05:13

Server rendered website with Deno and PlanetScale

Wes Bos

used a database Amazing. I was just like sitting there. I was like, I don't know what to do. Like, I know the select star from whatever, but

Wes Bos

called PlanetScale.

Wes Bos

And a lot of people are saying, yeah, check out PlanetScale.

Wes Bos

from or I update the number of hits in the database, and then I query the number of hits back from the database.

Wes Bos

And then I just grabbed a, and you create components that are associated with each of those slices, and then your user can just kinda put them together, and it's a website builder from there. It's awesome. Check it on out at prismic.ioforward/syntax.

Wes Bos

I wanna host it with Dino, And the answer to that is there are people trying to figure out how to replicate databases you're just writing Might be distributed Scott hits the 1 in I really like that it's still MySQL.

Wes Bos

So it was it was really yeah. It's it's kind of a cool website. So when you say you use this node package to work with PlanetScale,

Wes Bos

I don't I don't I say go to westboss.comforward/courses, the benefit of serverless

Topic 10 24:18

MongoDB Atlas serverless offering

Scott Tolinski

Yeah. I haven't used the serverless version of that at all myself.

Wes Bos

So the MongoDB

Scott Tolinski

That that's the part that stresses me out the most. It's like, oh, I'd love to try some of this stuff with my existing

Wes Bos

how much RAM I need and how much space I need and whatnot. And,

Wes Bos

which essentially is instead of you us. Choosing that is We either have a MySQL database already or a Postgres database, or we just want to stay on some sort of open standard. Man, we got to do a whole show on Superbase sometime soon. Yeah.

Wes Bos

serverless offering essentially just scales up and down as you need it.

Wes Bos

No. I I should I should give it a give it a shot. I don't think it will be all that much different from what I'm doing, which is kind of nice because you don't really have to

Topic 11 11:58

Stateless databases for serverless

Scott Tolinski

server. Yeah,

Wes Bos

in this space. The other thing people are asking is, like like, if you have Edge functions, And it was probably PlanetScale or MySQL or MongoDB,

Wes Bos

keep the connection open and whatnot. They use basically

Scott Tolinski

exactly.

Wes Bos

but But you have 1 database that's hosted And I want to have some sort of database, and there's no database really needed for this thing. So I made a hit. Yeah. But just essentially every single time someone hits the website, Right? Exactly. Yeah. So the problem with serverless or whatever. That's the idea with serverless is that you just create these little functions like you would in regular JavaScript.

Wes Bos

stateless, Like, obviously, they have the API and all that really good stuff, but they have fantastic but pick a service, a hosting service that will scale for me and do all the connection pooling.

Topic 12 15:03

Stress testing serverless database setup

Wes Bos

requests in less than an hour.

Wes Bos

They must have some sort and every little component that you have, make an associated use the I just grabbed a node MySQL The other one, AWS has two value 2,

Wes Bos

You should probably think about that type of request throughout the life of your application, DynamoDB.

Wes Bos

like, actual companies that get millions of requests a day, but I had a couple people.

Wes Bos

increments and then return those all. And at a certain point, I hit the limit of the free plan.

Wes Bos

What you had done is synchronous requests. So I was incrementing a number So I deployed this thing and I tweeted it out. And first of all, the Dino deploy inherently the in that. Yeah. Yeah. Well, like if you I gotta go from Australia to they You have to increment it, send it back, increment it, send it back. So what was happening was Yeah. Yeah. You can also host it yourself. I like that. I like companies like that. Century's like that as well. It's like, I'll pay you. Yeah. But I just like to know that I Could host them myself if I really wanted to. I just I agree. Yeah. Seriously.

Wes Bos

Right. Because

Wes Bos

What do you return? PlanetScale, Next up, we have MongoDB

Wes Bos

of servers, but people sent me

Wes Bos

Didn't go down, but the database started throwing errors. And I said, oh, like, what's the problem here? And I talked to the folks from PlanetScale, like, Is this a is this a connection pooling limit? Like, did I hit too many pooling? in Colorado.

Scott Tolinski

Someone someone out there's got some servers and some fat pipes ready to send over some data. Yeah.

Wes Bos

if you are scaling up because if that.

Wes Bos

essentially every single request depends on the request before it. Right. So they were sort of queuing up very, very long. And at a certain point, I hit the I hit the limit of it. So, which is awesome. So they do real time. You can scale it up yourself.

Wes Bos

Request that somebody somebody out there has some freaking servers that was able to very quickly send a very a high amount of traffic.

Wes Bos

And Deno, So some of the other graph databases that we've looked at. I don't think it is. Like, isn't Graph database just a database that points to other documents? Yeah.

Topic 13 06:39

Using a Node package with Deno for MySQL access

Wes Bos

SQLite, is there any of that stuff? Yeah. SQLite. You could literally use anything that that

Wes Bos

But that is just because Fauna, like, you run an edge function, the connection from your edge function to where your database is hosted is way faster Taking in requests and just basically send sending them over that single one connection that you have.

Wes Bos

Runs SQL queries, but I didn't want to get into that. I wanted to just I was just selecting a value from the database. So I was just writing raw SQL queries, which I have not done in and then ran the database on PlanetScale. And I asked Ask on Twitter, like, what should I what should I be using? where they just So it seems why can't you just use a regular database with serverless functions? There are different solutions. You gotta think about relational databases, MySQL, However, we have lots of existing applications. And if you want to move them,

Scott Tolinski

I didn't know much past that, so I had to look it up. I hear you. I would have to I would have to get into some heavy docs if I was going to be doing that by hand right now. Yeah.

Wes Bos

Yes.

Scott Tolinski

is that kind of like a friendlier way? Because I know we had talked offline a little bit ago

Scott Tolinski

About you writing SQL queries and stuff, do you still have to write SQL queries with this package?

Wes Bos

Probably 12 years.

Wes Bos

it's super, super simple. There's no build step or anything like that. But from git commit push down once or twice over the what's it at right now? to that is this thing called connection pooling, which essentially is that you you create a connection, Aurora, which is their It. So

Topic 14 10:45

PlanetScale handles MySQL connection pooling

Wes Bos

way to approach it because but they have secret sauce, which is, without a sweat.

Wes Bos

I'm not buying into some proprietary so that I could just use my regular adapters and queries and stuff like that,

Wes Bos

typically how you will be approaching these, the MongoDB is increased at any time, then it will scale up very quickly. And if the demand goes away, then you're not you're not running that code at all. It. So that's that's kinda what serverless is at a high level view. We've got lots more podcasts on that. And sorta along with serverless, you have this idea of edge functions, which Essentially is the same thing, except

Wes Bos

They just host MySQL databases. But part of their secret sauce is that

Wes Bos

database host.

Wes Bos

solution here, the amount of resources you need. So in in my MongoDB, I have to log in and and choose very much like than It's edge, meaning that it will run every single time someone hits the thing. So what happens when a 100,000 people hit an endpoint or let's say 10,000 people hit an endpoint at the same time.

Wes Bos

will allow you they will do the connection pooling for you.

Wes Bos

The other solution is you use like purpose built databases that do not No SQL base.

Topic 15 17:40

Serverless database options

Wes Bos

versus server.

Wes Bos

Then past that, you gotta think about proprietary

Wes Bos

Those are MySQL Standard stuff. I can run a MySQL database locally. No problem.

Wes Bos

databases, which is often called NoSQL, I'm assuming they also handle the connection pooling issue, But I think they they do a lot more, and it seems like people really like them, especially it. In the PHP world, because MySQL, PHP, they're they're pretty good friends.

Wes Bos

Postgres, all of those, Versus nonrelational open standards. So there are It's a MySQL So So let's talk about actual solutions out there.

Wes Bos

services out there, Firebase, Cloudflare, However, if the demand

Wes Bos

PlanetScale function and part of so PlanetScale is a MySQL Supabase is kind of like it's pretty much just open source Firebase, I used that one. I this is not my 1st hit counter I've created in the in the past.

Wes Bos

where they say, alright, use our database. This is how you use it. This is our API.

Wes Bos

Lots of proprietary They have tons of really good examples.

Wes Bos

data I do 2 things. I query And then they also have Cloudflare key key value storage. They've had that for a while as well. So you it kinda you think about, like, MySQL or IndexedDB. You wanna be able to start start key values.

Topic 16 01:46

Overview of Prismic as a headless CMS

Wes Bos

They are a headless CMS that provides to it being live was 1 or 2 seconds, You can. I'm pretty sure they host it. Yeah. They have pricing, And it shows you as I tweeted it out, it shows you where it is spinning up around the world because, it.

Wes Bos

input in Prismic with that. And then your marketing people, your lawyers, the people that are running the website, you yourself can go ahead and edit That content, you can click together those slices, for you as well. I have not looked into that, but quite a few people were recommending that as well.

Wes Bos

tooling, I I always like to learn a new piece of tech. So my problem was I have this website, Wes Boss, with two s's, that apparently work really well with serverless. And then we have Firebase on top of here, which has been around for Quite a while. So tons and tons of options. That's probably only half or or a quarter of the possible options that are out there, but it kind of gives you a good idea of I made a a hit counter that rendered to a PNG.

Topic 17 02:39

Examples and demos on the Prismic website

Wes Bos

Just by doing a quick scan of the website, I think you'll understand But that's The sort of the one solution.

Wes Bos

how it all works. Thank you, Prismic, for sponsoring. Sick.

Scott Tolinski

So once I,

Topic 18 25:19

Challenges converting existing apps

Wes Bos

There's lots of them out there. Some of the proprietary, some of them are not. Some of them are MySQL or sorry. Some of them are SQL based and some of them are, Oh, yeah. A long time ago.

Wes Bos

2 very popular NoSQL save all of your data in columns.

Scott Tolinski

pretty evolving right now, too. Yes. Yes, I agree. So

Scott Tolinski

so I I might be the type to look for One of these actual solutions rather than trying to do some sort of connection pulling on my own. Yeah.

Scott Tolinski

or connection pooling doesn't really sound that much fun to me

Scott Tolinski

Yeah. It also feels like this is a space that is Underskilled

Wes Bos

that's all I got for today. If you've got any tips on serverless databases, make sure you tweet us at syntaxfm. We'd love to hear especially if you've, like, converted, proprietary, My profile in Colorado they do it looks like they kinda do what, That will just redirect the user. But for this one, I want to,

Scott Tolinski

Like a server app to serverless. I'd love to hear, like, what did you do about your database? Yeah. I'm very curious as well because, again, This is something I'm fairly ignorant about in general. So this this definitely cleared up a lot for me, Wes, in terms of, like, what are the issues there? Enrolling your own server pooling the interface was really nice, and the whole thing felt really good to use. So I I was a fan of Railway when I tried it. If you look at their investors, their investors are,

Topic 19 00:00

Transcript

Scott Tolinski

Welcome to Syntax.

Announcer

Open wide dev fans, get ready to stuff your face with JavaScript, CSS, node modules, barbecue tips, get workflows, breakdancing, soft skill, web development, the hastiest,

Announcer

Monday. Monday. Monday.

Scott Tolinski

CSD.

Announcer

the craziest,

Scott Tolinski

On this Monday, hasty treat. We're gonna be talking about

Announcer

the tastiest web development treats coming again hot. Here is Wes Barracuda

Topic 20 13:48

PlanetScale focuses on scaling and performance

Wes Bos

it it's gotta get on a train somewhere and go through the middle of the earth. You know, there's there's pipes.

Wes Bos

to Virginia. There's certainly So That's solution number 1,

Wes Bos

So I put this thing out there and I said, like, I just tweeted out. I said, like, go for it. Give me as much traffic as you can because I really want to see, Like, Supabase and PlanetScale, Their marketing as in Toronto and then Scott queries for that,

Wes Bos

So Awesome. Alright. Catch you later. Peace. Peace.

Share

Empowering developers for over 286196928259 milliseconds!