Paul: Hi there and welcome to PodRocket. I'm your host Paul, and today we're joined with Mark Burggraf. He is a senior dev over at Superbase and we're going to be talking about Postgres in the browser, wild for running in WebAssembly. Welcome to the podcast, Mark. Mark Burggraf: Well, thank you very much. It's great to be here. Paul: Yeah, thanks for taking the time to come on. I mean, we've had all these interesting web assembly things happening in the past year or two, so every time something new pops up, it's like new shiny object syndrome but at the same time, there's immense value if you know how to use these tools right. So what is your involvement with the project? Is this something that your team put forth yourself, drawing inspiration from somewhere? Mark Burggraf: Yeah. I think originally we saw Crunchy Data do this thing first. It wasn't open source, so we all looked at that and it opened our eyes to say, "Hey, this is possible." But that project wasn't open source and we wanted to create an open source version and put it out there for the world because we saw immense value in it. So I love to do the hacking projects with the projects on the fringe that do all sorts of interesting cool things. So I just love doing stuff where you're not sure if you can do it or how you can do it, but you're going to pick away at it until you make it happen. So what happened was when the Crunchy article came out on Hacker News, SnapLit, another company was looking for people to collaborate with. I had already started on the project and so the two CEOs of SnapLit and Superbase, Paul and Peter got together and said, "Hey, why don't we collaborate the two companies on this?" So I started working with these SnapLit guys together on making Postgres work in the browser and it became a really fun synergy between the two companies. Paul: So did SnapLit approach you, you said? Mark Burggraf: Well, I think SnapLit put out a call for people. They basically said, "Does anybody want to collaborate on an open source version of this?" And I was working on it and Paul Copplestone, our CEO had seen their post and so he said, "Hey, do you want to work with the SnapLit guys on this?" I said, "Yeah, anybody wants to work on it game." So that's how it came to be. Paul: That's really interesting that, I mean this awesome thing about Superbase is we were talking about before the podcast is there's this open source drive that's really coming to backend as a service to just general utility to help us run the microservice world that we have today. So why did your CEO find interest in this project, you think and say let's allocate resources to helping build this out? Mark Burggraf: It's really interesting. It took me a while to get the philosophy of Superbase because I'd always developed in shops that were closed source and they guarded their source code. And Superbase is the exact opposite. Not only is everything open source and you can look at the code for the entire product basically, but they encourage us to work on anything that improves the community. Even if it's not related to Superbase, a lot of our players work on things related to Postgres, related to the database world. Anything that helps the open source community, we really push that because it's our goal at Superbase to make developers lives easier. And obviously that's through the Superbase product, but sometimes it's just utilities or articles that we write that we put out there for our competitors or anyone to use. As long as it gives value to back to the community, it's our philosophy that that's what we want to concentrate our effort on. Which is sounds counterintuitive, but it's worked really, really well in Superbase's doing fantastic. So it's been a great philosophy. Paul: I mean when you give valuable content out, you're going to get receive value back. I mean, we see this with the Log Rocket blog. People are writing back and saying, "Hey, this was really helpful." If you go to the Superbase stocks, you can see the philosophy come through in the writing. You guys are citing everybody that's involved in projects pointing to resources. It's a refreshing read, new flavor of ice cream with development. Mark Burggraf: Yeah, absolutely. And one of the other big things about Superbase is that they make it a point to not hire egos. So everyone that works there is it doesn't need to put their name on things. And this project here, it's a joint project and we don't care about Superbase getting the credit or me getting the credit. All we want is I wake up at four in the morning excited about the project and excited about putting stuff out there. So we don't really care about getting the glory or actually even saying, "Is this going to make us money? Is this going to be profitable?" Because it's almost like a karma thing. You put out great work, you just do great work and then you will be successful. And that's our company philosophy and I think that's fantastic. Paul: It is fantastic. And I mean bringing us back to the product that you were just referencing Postgres WASM. So WASM break it down for us in 30 seconds for the folks that might not be familiar. Mark Burggraf: Sure. WASM is web assembly. So it's assembly language, it's a way to compile, to bite code items that can run. Basically designed to run in the browser, but you can actually run WASM from your command line or on your desktop as well. So it's web assembly and it's a misnomer because this really is not Postgres running in WASM and pure WASM. It's not Postgres compiled to assembly language. What's running in assembly language is this product called V86, which is a terminal emulator, which basically allows you to run entire operating systems in your browser. And then what we're doing is we're running Postgres inside of that in a very stripped down Linux machine. So essentially it looks and feels the same, but it's not technically Postgres compiled WASM because that's not technically possible yet. But the bottom line is you can open up your browser, go to this webpage and be running Postgres server in your webpage, which is mind blowing if you know anything about Postgres. Paul: So one of the ways you can get data in is you could read a replica from a remote source. You could say there's a table, I want to bring it in. Are there other methods of reading data in and what are some of those? Mark Burggraf: Yeah, there's a few ways to do that now. That's one of the issues that we had with the original... Crunchy Data, did this first but they had no networking capability. And I see why now after I've worked on the project, that was really, really hard to do. To get the networking right and being able to move the data across the network because the browser gives you significant restrictions that we'll talk about later. So you're not allowed to talk to ports, you can't open TCPIP ports. So getting the network working was one of the core pieces that I worked on in order to go out. So I can go out to an existing Postgres database on a Superbase project or anywhere on the internet basically and bring that data in with pg_dump or PSQL or any of the standard tools. You can also, let's say you have a SQL script that publishes data or you have a CSV file, you can upload those files to the emulator and then run it within the machine. So you could upload a CSV and then do a copy from command inside of Postgres. So there's a few ways to get data in and data out the same way. Paul: Cause at the end of the day, we're really just talking about the engine. The engine is what is the product. The engine is in the browser, we can bring data from, we can bring data from remotely. You could slice this cake in a bunch of different ways. And I'm sure there's in infinite just roster possibilities about how you could market this. Have a high performance data set, it runs instantly. You don't have to go anywhere. Are there any other use cases that you would flash in front of people to say like, "Hey, I had this random idea in bed at night of how we could use this?" Mark Burggraf: Yeah. Actually what I'm working towards, the vision for me is to put the entire Superbase product into the browser so that you can have a development environment that has everything that Superbase offers. So that'll have off storage, functions, the database, everything in one place. So that's definitely a use case. Another huge use case is since you can take snapshots of this browser virtual machine in no time, it's almost instant. You click a button, it saves, it as a file. What you can do then is you can load up your database with data, create your functions, do anything you want, save that snapshot, and then send that snapshot over to a buddy to look at. Or you can do AB testing. You can save a version of the database, make some changes to it, maybe make an index, save another snapshot, and then go back and forth between the two. So it opens up a lot of things that could be done with a server, but are much more time consuming and much more complicated to do. The big thing about this project for me more than a use case is just making Postgres accessible to more people. First of all, it can be difficult to get your hands on a database because you either have to learn how to install Postgres locally, which can be difficult sometimes, or have access to a server that has Postgres running. And then sometimes you get on a database and you're a little bit scared to work with it because if you make a mistake you can drop data and you can cause all sorts of problems. So we wanted to make something where you can just spin up a browser, start learning to use SQL, test things out and not worry about messing it up or having to install. So it's quickly accessible. And if you make a mistake, you just hit refresh and you have a fresh copy and start over again. To make it almost as easy as working with a spreadsheet or a word processor. So we love SQL. We are unapologetically SQL. When people say, "Well, with Superbase, you got to learn SQL." We're like, "Yes you do and it's the greatest thing ever. We love that. So embraced it." That's what we want people to do. Paul: From your point of view, there's two categories of value add here. We have all the productized value add on one side, but it's also development workflow. There's easy to reach wins that you can provide to people trying to onboard either to the Superbase product or just SQL in general, runs right in the browser. Mark Burggraf: Yeah, absolutely. And I think people are real excited about WASM and running things within the browser environment. And this Hacker News post that we put out. I think it's our second most popular Hacker News post of all time. Second only to the launch of Superbase as a product. So there's really interest out there and if I see WASM in the title of anything, I will read that article and I will jump on that because it's cool. Paul: It is cool. Mark Burggraf: So it's just a mind blowing. The stuff that used to take all this power and servers spun up now you could just do it right in your browser. And to think in the future that the development environment, that the dev database is running locally in your browser and then when you're done, you'd hit a button and push that up to your staging or your production database, I think that's the wave of the future for developers to develop locally. Paul: And speaking of WASM and all these interesting technologies, I mean we had a podcast with Andre Cohen, maybe a month or two back, and he's working on DuckDB-WASM. And this is such a cool project because it's an analytical database in the browser. So I'm thinking dashboard apps, you could have really fast reloading graphs that you could scrub through data. I mean, D3 tried to tackle this problem of how do we dynamically load data in and provide interesting visualizations, but I don't even have to re-requests the database. It's right there. That's cool. Yeah, it's a really exciting space. Go check out that episode if you want to hear more about the WASM stuff. Mark Burggraf: Yeah, that's very cool technology. I love it. Paul: In terms of the system architecture change, one thing that's really interesting to me as a backend person is we're considering the client node as part of the architecture now, something you wouldn't do before. They were just attacks. How do we get the product to them and now they're part of the product? Like you were saying, you could do some SQL operations there, you could export it, you could reload it. Is there something that you would think is a low hanging fruit that people could reach for right now in your cookie cutter app if they wanted to try it out and find a win? Mark Burggraf: Yeah, I mean what would people use it for right now? I mean I love personally using it for bringing data down to my desktop for doing analysis, things like that. Also, like I said before, for testing things. It's great to be able to have multiple versions of the database and try different things out and not have to worry about... I'm always worried about messing up my production version or if I push something. So just as a quick and dirty development environment right now, it's really good. It's also good for pulling down data for doing reports or doing anything that, let's say you have something that is going to hit the database because it's CPU intensive, you're going to do a lot of heavy analysis. Well, you can do that inside your browser all day long and not affect anybody, which is really cool. And what's making that possible again, is this ability to use the network. Now getting back to the network issues, the first thing was just to open up the network. By the way, also you can go to wasm.superbase.com, exit out of PSQL, which is where you come up by default and you're at a Linux prompt and you can ping stuff and you can use all the busy box tools. Yeah, it's wasm.superbase.com. That's where our demo product is running. So you basically have a full Linux operating system inside the browser. So if you want easiest way to grab data from a Superbase database, so you drop to your command line and then you run pg_dump, which is also included pg_dump, PG SQL are included. So you can run pg_dump and then pass at the string from your external database and then pipe that to PSQL, which basically does a pg_dump of your remote database and inserts it straight into your local database all in one command. That's pretty cool. And you can go the other way too. You could do a pg_dump of your local database and then send it PSQL and send it to your external database so it moves back and forth. Now- Paul: It's a breathing pipe between them. Mark Burggraf: Exactly. And now the second thing we wanted to do, which was really difficult was provide outside access into the local running instance of Postgres. So which is, at first we were told that it's impossible to do that. Yeah. Well, they said it's impossible because we talked to the guy who made a Fabian, he's the author of V86, the emulator engine, and he said it's a black box and so you can't see it because even if you run through this proxy that we've created it's on a private IP, so it's not exposed to the internet. So what we did is we created a reverse proxy using engine X at the proxy that turns ports... Looks at the port number and then maps it to an individual virtual machine running in the local browser. So now when you start up the network, I gave you this little address on the bottom of the screen and if you put a password on your Postgres, so you have to set a password and it shows you that when you first come in. So you set a password, I can give you that location wherever you are in the world, and you can look at my database running inside my browser. And I can say, "Hey, I need help with this." So you can say, "Yeah. Let me look at it." You can log into PG admin or PSQL, bring it up and say, "Oh yeah, here's your tables," and it's going to make things really cool for support in the future I think connecting these databases through these tunnels. Paul: Yeah, I want that now. I mean you just reinvented Nat. You made Mark's Nat 2.0, but based on VMs and in engine X reverse proxy. That's something. So you've got to be mindful though. I don't want anybody connecting to my SQL. Mark Burggraf: Absolutely. Security is a big piece and that's why by default it's not allowed unless you, and this is a Postgres thing, this is nothing that I did. But Postgres doesn't allow it unless you turn it on and set a password and give somebody the address to it. Also, it is a temporary instance, so when you shut that browser tab or close your laptop, it doesn't exist anymore. So that's obviously with power comes the ability to shoot yourself in the foot. So just be careful that when you open this up, you don't have any data on there that's sensitive or anything like that. But the fact that we can do it is pretty cool. Some of the other things that we're doing, just because I can do it is I'm running Postgres on my iPhone in a browser when I'm sitting in the parking lot waiting for my wife to grocery shop and I want to write some SQL, I bring up my iPhone and bam, I can get a full Postgres instance on my phone. So I added a feature for that because I was pinging and I realized the iPhone doesn't have a control C key to break out of that ping. And I had to reboot my database, so I added a little button to bring up a virtual keyboard so I can hit control C, Control D and the arrow keys that the iPhone doesn't have. But to me it's cool that I can have Postgres running on my phone and then I've got a Fire Stick TV and I've got Postgres running on my television operating system inside on my big screen TV or running Postgres there. I'm thinking this is pretty cool that you could port it to just about anywhere. It's cool. Paul: So do you see major production systems taking advantage of this or are you seeing it mostly foraying itself into the masses as a development tool? Mark Burggraf: I think it's going to be a development tool, but I mean I'm not going to tell anybody what's going to happen because what I'm looking for, and the reason we put this out there is we want people to see the value in using WASM and think of new ways to use it. The ways that have never been done before. So I'm not going to say that it's not going to happen. In my mind it's a development tool because it's browser based and browsers aren't 24/7 servers are, but maybe one day we have distributed file systems where when you boot up your browser, you're actually hosting stuff as part of a distributed network. That's where the future could go with this. It's definitely possible. And we were already seeing people come up with ideas for using this that we hadn't thought of before like one of the Superbase. Paul: Yeah. What's one of them? I'd love to hear. Mark Burggraf: One of the Superbase people said, "Could I publish one of these snapshots, put it on the web and then send somebody a link that opens up the WASM site and downloads that snapshot automatically so they can see it?" I mean that would probably take five minutes to implement because we have all the tools. So what he wants to do is be able to say, "Here's an example database preloaded with everything in it and you can click and load that up and see it and interact with it basically instantly. And I thought, "Wow. That's a really good tool for this." Training, showing people things, even data sets. You might have preloaded data sets of public data that people can interact with and use locally on their machine just by clicking. So that's another really cool use for it. Paul: Yeah. What's something you guys are working on right now that you're excited, maybe hidden, not hidden? Well, it's open source, so everything's out there but? Mark Burggraf: The thing is, we ship so much code. About every three months we have these launch weeks where we take five days in a week and we launch something different every one of those five days. So our last one was about a month and a half ago. And I'm just blown away that, I mean I'm working at the company and there's stuff that comes up that I wasn't even aware of just because there's so many teams working on so many cool things. I'm personally excited on about some of the enterprise stuff we're doing. The point in time recovery. What we're doing with real time is amazing. This ability to have presence where you can have people pop up on the screen and disappear as they come online and go offline and it's scalable so that doesn't have to go through the database. In addition to all of the real time database stuff, you're going to see some really cool game engines and things like that using Superbase as a back end, that's really some cool stuff. Let's see what else? There's just, there's so much fun stuff besides just this WASM thing and this WAM thing's going to have a whole bunch of more stuff because- Paul: Yeah. What's something on the specifically within WASM bubble maybe? Mark Burggraf: Well for me, I want to get, like I said earlier, all of Superbase working within this thing. And in addition, I want to start opening up more Postgres extensions so you can do post gist for doing geographical data, things like that. And that's one of the reasons I love Postgres is just because it's so extendable and you can do all sorts of different things that you wouldn't think that you could do. For example, if you're writing functions, we have this, there's an extension called PLV8 that lets you write your Postgres functions in JavaScript in extending it. Now you can do that also with Python and other languages. So making more things happen within the Postgres space is what's really exciting to me, I think. But there's going to be more and more WASM stuff coming up. The first WASM piece that really excited me was when they put all of SQL light into WASM. I'm a big sequel light fan. I love it. I've used it for more than a decade. And to have the complete engine running locally in the browser was very cool. Another- Paul: Sorry, just want to ask, was that the first WASM thing you played with, was the SQL light one when it came out? Mark Burggraf: I think so. That was one of my first forays in into WASM. And then there was another one that was really cool that was running FFmpeg. Paul: FFmpeg, yeah. Mark Burggraf: Running that in the browser I thought was just fantastic because that's another tool where, and the goal of WASM, I think, and part of the reason it's so exciting, it's because it's infinitely scalable. For things that take a lot of processing power, like FFmpeg video processing rather than have one server, how many people can one server support? Maybe 1,000, 10,000 but if everybody runs it in their browser, it's infinitely scalable. So you've got this product that now can be run by literally billions of people because you don't care how many people there are. They're providing their CPU, they're doing it. And that's exciting to me. And when we talk about these dev environments, we don't have to pay for infrastructure to support that. People can do their development work, push it up to production or whatever, but we don't have to spin up a separate instance for every user, which A, it's better for the user because it's fast and it's available instantly and it's good for us because they're providing the processing power and the resources to be able to run it, which I think is fantastic. Paul: Having that development environment is huge. I mean if you think about Firebase... You have the Firebase emulator. And the problem with any emulator, when you have seven microservices running on your machine, you're just like junk gets created and it's a pain. And Mark, if you can get this in the browser, man, I'm telling you that's going to be a clean operating machine for people and people can boot in and boot out because being able to test these little services is huge and it'll accelerate developers everywhere. Mark Burggraf: And again, our bottom line is how do we make the developers life easier? And what's neat is we are developers. So when we're supporting developers, they've got questions. They say, "I'm running into this problem." Most of the time, I write back I've had that exact same problem. I feel your pain, I know exactly what you're going through and this is what we've done to solve that problem or make things easier for you. Over and over again, we run into that because we are developers and we want to make, as we solve problems... If it makes life easier for me, if it's something that I use and I think is cool, other people will think it's cool. The original Crunchy version of this Postgres in the browser was restricted to being inside of PSQL. So you could run SQL Commands, you could run anything that PSQL could do but you were stuck in PSQL. I've decided I want to exit out to the command line, I want to run Linux commands, I want to run pg_dump and I want to ping stuff and I want to run Curl. So I did that and one of the comments on Hacker News was, "Hey, did you know you can exit out of PSQL and there's a whole Linux environment there." I'm like, "Yes. Because I wanted that and I knew you would want that." It's cool. We want to open up these tools for people. Do cool things with it and then just tell us what you did. We want to push the envelope and- Paul: Push the envelope. Great. Mark Burggraf: Yeah. Get people doing stuff that we didn't even conceive. I want people to tell me, "Hey, guess what we're doing with this? Or could you add this feature because it would open up this whole world" And we're like, "Yeah, I'm there." Paul: So let's get some people tooled up so they can at least help in this niche that we're talking about. If somebody's listening and they want to go check this out, where are you directing them to Mark to go learn more about PSQL WASM? Mark Burggraf: Yeah. Well, the demo was at wasm.superbase.com. The official repo is at SnapLit. It's on github.com/snaplit/postgres-wasm, that's P-O-S-T-G-R-E-S dash WASM or if you just go to the SnapLit repo. There's also one on the Superbase-community site, which is a fork and we've added our version of the demo to that, but either one is fine. If you go to those repos, all the source code is out there and you are welcome to use it however you like or look at it and ask us, "How did you build this? Or how does this work?" We will respond to you. Or if you would like to join in and put in a PR, we'd love to have you work on it or we'll help you fit it into your product. If there's something where you say, "Hey, this would help our product by doing this," we'd love to talk to you about that. That's what we're all about because it helps us move the product forward and it moves both the SnapLit product and the Superbase product forward at the same time. Paul: It's crosspollination at its best. And if people wanted to hear more from you, Mark, are you on Twitter or do you write blogs anywhere or things like that? Mark Burggraf: I'm on Twitter. I have a few blog posts. I'm running blog posts on dev.to/burggraf. And I tend to write things like how to do custom claims in Superbase, how to increase the throughput on bulk loading into Postgres. Just interesting things. Paul: You write about things you care about. Yeah. Mark Burggraf: Yeah. Stuff that drives me and stuff that makes my life easier. Probably the best thing to do to get a feel for what I'm working on is just to go to my GitHub, it's github.com/burggraf and take a look at the projects. The first thing I did for Superbase before I started working there, I was contributing to the open source piece and I wrote something called Superscript, which basically brought the capabilities of Node.js, half Node.js, half Dino to Superbase. So you could write JavaScript and load external libraries like node libraries across the net, cash them in the brows or in the database, and then use those in your functions. So it made it because what it was for me was I was a JavaScript TypeScript developer trying to write functions in a language that I'm not comfortable with, which is PL, PG SQL. I can barely pronounce it and I can write it, but I'm 10 times faster at JavaScript. So I brought those capabilities over and so you take a look at that library and some of the other things, and you can reach me on Twitter as well. It's burggraft, uh twitter.com/burggraf2. But I'm happy to talk about any- Paul: Burggraf with two Gs. It's B-U-R-G-G-R-A-F, if you're looking it up. Mark Burggraf: And in German, that's two German words, Burg, castle and grass, count. B-U-R-G is a word, G-R-A-F. And that's why it's got two Gs. Paul: Well, Mark, thank you for your time. Thank you for talking about PSQL WASM, and hopefully we inspired some more people to come in and share the joy of development. Mark Burggraf: Thanks Paul. And it is October, so the hack Octoberfest is in progress, so I encourage you to jump on a repo and get some open source practice. If you've never made a PR to a repo, this is the month to do it. Hack on it and find the joy of open source software. You will really, really enjoy it. So get out there and hack some stuff for October. Paul: Right on. Thanks, Mark. Mark Burggraf: Thanks for having me.