10 ms·
Supabase Edge Functions
- poetril 5y agoI'd love to learn more about how its making use of Deno. I have been loving Supabase lately, both for hacking away at side projects. I have been thinking about moving some of my own backends over to Supabase.
- kiwicopple 5y agoFeel free to ask any specific questions about our Deno usage which isn't covered in the blog post. Inian is in the comments and will be able to cover anything technical
- jimmy2020 5y agoIt feels the CDN edge functions are the new Jamstack. It's fast but comes at a high cost and the excitement shifted from static pages to literally data distributed near the user.
- kiwicopple 5y agoedge functions was an obvious complement for us. we already have database functions [0] which can be executed through a REST api (database co-location is great for data-intensive operations). Edge Functions are deployed to 29 regions globally, which means that you can use them for low-cost, low-latency operations. [0] Postgres Functions: https://supabase.com/docs/guides/database/functions https://supabase.com/docs/guides/database/functions
- marcus_cemes 5y agoStatic pages relied on the client being able to run JS to populate user-specific data. Also, a lot of data is fine with being eventually consistent, which is a good fit for edge functions. An example is rendering the account icon and username on the top write, without hitting a central database/static file server.
- jackrvaughan 5y agoSupa interesting! Asked these on twitter but probably better here: - Where are the 30+ data centers located? - What is the average cold start time?
- jackrvaughan 5y agoAnswering my own question. Locations from Deno: https://deno.com/deploy/docs/regions https://deno.com/deploy/docs/regions
- awelfkjlkj34t 5y ago
- productceo 5y agoLove it! Congrats!
- getcrunk 5y agoThis uses deno deploy under the hood, which interestingly enough still doesn't list pricing because it is pre-release.
- deleted 5y ago[deleted]
- paxys 5y agoAnd Deno deploy itself likely uses AWS or the like under the hood. So you are paying base infrastructure costs plus the premium for every provider in the stack.
- KyleJune 5y agoThe latest preview screenshot I've seen from the Deno discord had the following. I believe official pricing will be out in a few weeks. Free plan: 100k requests per day with up to 10ms CPU time per request. Pro plan: $5/mo + $0.50/million requests per month with up to 50ms CPU time per request.
- onelovetwo 5y agoSupabase is becoming quite impressive, I think the main thing missing is a native iOS/Android sdk.
- MacAndSmeg 5y agoLove me some supabase... probably the most fun platform out there at the moment.
- moralestapia 5y agoAwesome! Congrats for shipping! 90% of the projects I work on are built on Firebase, our main worry with that is that we are locked-in, not only to "Firebase", but to Google as well which has a nasty history of just pulling the rug from under your feet without even telling you why. Having alternatives to try and implement is always a priority for us and Supabase now (w/ edge functions) seems to cover most of our use cases, so we are definitely looking to switch to it.
- jimmy2020 5y agoI am curious how the edge functions can replace Firebase?
- imilk 5y agoSupabase offers a lot more than edge functions (db, auth, etc). Take a look at their website
- jimmy2020 5y agoI know but the same goes for Firebase. As matter of fact, Supabase started as an open-source replacement for Firebase.
- aaaaaaaaata 5y agoSo what's the question?
- inian 5y agoIf you are using Firebase Functions, it should be easy to port it over to Supabase Edge Functions. We also offer a Realtime database (Postgres), Auth and Storage as part of our stack.
- deleted 5y ago[deleted]
- moralestapia 5y ago
- kiwicopple 5y agohey everyone, supabase ceo here. The team is extremely excited about this release. This one has been a long-time coming. It's one of our most requested features. We spent a long time getting the Developer Experience right - we investigated several approaches (Containers, Isolates, WASM), and eventually landed with Deno. Big shout-out to the Deno team. Their open source and DX-focused philosophy made it an obvious choice in the end. We've wrapped their open-source runtime to make the Supabase experience as integrated as possible, from the local CLI development, to realtime logs on the Dashboard. Edge Functions are still Experimental, so make sure you send your feedback to make the experience even better. We'll have a few of the team in the discussion ready to answer any questions.
- ignoramous 5y agoCongratulations on launching this oft requested feature! Any timelines for support for Functions over QUIC/HTTP3 and raw UDP/TCP? Cloudflare Workers, the closest thing to Deno Deploy, announced intention to support raw TCP a few months back (while "HTTP3" has been supported for quite a long time now). Re: Database Functions: I really like the dual nature of Cloudflare's database offerings: Durable Objects (run functions close to data) as an option for apps that need that kind of strong consistency guarantees. KV (move read-only data close to functions) as an option for apps that can tolerate race but desire speed.
- kiwicopple 5y ago> Any timelines for support for Functions over QUIC/HTTP3 and raw UDP/TCP? I'll ask the Deno team. I'm curious what your use-case is for these (especially UDP)? > Cloudflare's database offerings DO and KV are both incredible products. I think we'll tackle these a little differently since our "base" is Postgres. We are announcing more "edge-like" products tomorrow which will lay the groundwork
- ignoramous 5y ago> I'm curious what your use-case is for these (especially UDP)? Custom network devices like TURN/STUN, L4/L7 load balancers (relays, gateways), authoritative / recursive DNS, Wireguard tunnels, WebRTC etc. > We are announcing more "edge-like" products tomorrow which will lay the groundwork. Exciting. Thanks! (:
- latchkey 5y ago> Serverless compute options can be broken down into two broad categories: > Containers as a Service (e.g. Google Cloud Run, Fly.io) > Functions as a Service (e.g. Cloudflare Workers, Fastly Compute @ Edge, Suborbital) There are also Google Cloud Functions, which is odd to not mention here. For what I'm working on, I've put CF Workers in front of my GCF's. This allows me to terminate the SSL at the CF Worker (along with easy control of DNS) as well as control the URLs (and even content) that ends up being sent to the GCF workers as well as caching of results in CF. It gives me a huge amount of flexibility and very little complexity. Currently doing 1m hits/day through CF workers and it is ~$6/mo + ~$20 for GCP (including a Postgres db and heavy use of pub/sub). All the other important things are done... CI/CD for the whole development flow with Github actions doing deployments on push to main, logging and graphs comes standard. The developer experience with both GCP and CF is top notch. Supabase continues to be an interesting alternative, but I really don't see a reason why I'd go with them.
- rvnx 5y agoThe Google Cloud Functions are not really good compared to CloudFlare Workers :/ The GCF are regioned, slow to start and behaving like an on-demand temporary cloud instance, than an actual FaaS offering.
- latchkey 5y agoUsing golang cloud functions. I have a constant stream of hits, so there are always available functions. Connecting to cloud sql postgres and serving a request that hits the database takes under 1s. Hot request/responses are ~20ms. My hits are all US based, so I plopped myself into Central. No issues there either.
- marcus_cemes 5y ago> Using golang cloud functions. I have a constant stream of hits, so there are always available functions. There is no way to avoid cold starts althogether, there will always be tail latencies unless there is a generous amount of idle instances running that GCP charges for. > under 1s. Hot request/responses are ~20ms. Those numbers are great, I think Go plays a huge part in this. Google's Node.js firestore SDK is terrible... I've had 15 second cold starts, which is unacceptable for client-facing functions, there's a whole thread about it here [1]. GCP doesn't have a very wide range of language SDK support for those that don't want to use Go or Node.js... > My hits are all US based Edge compute, like Fly.io or Cloudflare Workers truly shines when you need to serve traffic close to the user around the world. Otherwise normal region-locked functions are fine. Vercel requires you to choose a single region, and it's locked to US-east for free-tier users. For us Europeans over here, SSR has to effectively cross the Atlantic ocean. [1]: https://issuetracker.google.com/issues/158014637 https://issuetracker.google.com/issues/158014637
- marcus_cemes 5y agoAmazing work, kudos to the Supabase team! > However, Supabase already offers a flexible solution for that - Database Functions! As such, for Supabase [Edge] Functions, we decided to deploy far-and-wide so that they are as close to your end-users as possible. Does this mean that a choice has to be made between high latency (Edge Functions) and specialised SQL-only functions (Database Functions)? I see that cron-like triggers are still on the roadmap, is there a plan to have TypeScript functions that can run close to the database (or other resources)? Call me new school (as in not old school), but I prefer processing complex queries in a language that I feel comfortable working in, SQL is not that. I know a lot of folks are huge fans of writing pure SQL, the lack of type safety and lack of good intergration with source control (I dream of a world where database schemas, functions, security access and the rest can be saved to source control for reproducibility) scare me.
- inian 5y agoWe can look at offering an option to restrict edge functions to just launch in the same region as your database (probably can't call it "edge" at that point though). This might also be useful if you are processing data in your function that you do not want to leave a particular geographical region. We are also exploring running Deno directly inside your database - https://github.com/supabase/postgres-deno https://github.com/supabase/postgres-deno
- kiwicopple 5y ago> is there a plan to have TypeScript functions that can run close to the database (or other resources)? Just to double-up on Inian's comment - there is definitely a world where this happens, perhaps even inside the database itself (like plv8). We were focused on the Edge experience this time, but I'm excited about the future that an open-source TS runtime like Deno enables. > I dream of a world where database schemas, functions, security access and the rest can be saved to source control for reproducibility this was one of the main reasons we started supabase. we hope to make database development as easy as application development
- nextaccountic 5y ago> I know a lot of folks are huge fans of writing pure SQL, the lack of type safety and lack of good intergration with source control (I dream of a world where database schemas, functions, security access and the rest can be saved to source control for reproducibility) scare me. Hey there are some migration tools that play nice with source control. For example, Flyway has repeatable migrations https://flywaydb.org/documentation/tutorials/repeatable https://flywaydb.org/documentation/tutorials/repeatable, here's some links about this https://stackoverflow.com/questions/25839666/flyway-strategy-for-migrating-frequently-changing-functions-stored-procedures https://stackoverflow.com/questions/25839666/flyway-strategy... https://github.com/flyway/flyway/issues/819 https://github.com/flyway/flyway/issues/819 https://github.com/flyway/flyway/issues/128 https://github.com/flyway/flyway/issues/128
- yesbabyyes 5y agoSupabase and Deno?! This is the best news in a while. I like the feeling of you biting at the heels of Cloudflare and even bigger competitors. I believe in this and am excited to build something new!
- ilrwbwrkhv 5y agoI am so torn between Supabase and Render. My two favourite cloud providers right now. Please don't become enterprise-y guys.
- digianarchist 5y agoTwo solid products and the choice between them is down to whether you want to write your backend.
- anurag 5y ago(Render founder, Supabase fan) You can use both! Render will always be developer-focused even as we move into the enterprise. It's the only way to avoid Heroku's fate.
- ajuhasz 5y agoTwo questions: 1) Do the functions "freeze" once the response body has been sent back? Is it possible to return a response to the user (for a quick API response) and then continue doing some background work? This is has been a source of pain with AWS Lambda based services like Vercel that freeze execution once the response has been sent.[1] 2) How does keeping a connection pool work between function invocations? For example using Prisma for the nice typed DB functions. [1] https://vercel.com/docs/concepts/limits/overview#streaming-responses https://vercel.com/docs/concepts/limits/overview#streaming-r...
- kiwicopple 5y ago> Do the functions "freeze" once the response body has been sent back? Just checked with the Deno team. These functions should not be used as "background workers" - perhaps that is something we explore in the future. It will work for a short time in theory, but it's not guaranteed. > How does keeping a connection pool work between function invocations Supabase offers several options here. You can either use the API (PostgREST)[0] - an autogenerated REST API, or the connection pooler (pgbouncer)[1] which we offer with every project. > For example using Prisma Supabase is a popular database hosting service for Prisma users because of the built-in pooling - it's a great product, especially their typed interface. [0] PostgREST API: https://supabase.com/docs/guides/api https://supabase.com/docs/guides/api [1] pgbouncer: https://supabase.com/docs/guides/database/connecting-to-postgres#connection-pool https://supabase.com/docs/guides/database/connecting-to-post...
- ajuhasz 5y ago> These functions should not be used as "background workers" Thanks for checking on it. We actually had to create a Cloudflare worker based "fire-and-forget" system to allow our Vercel functions to shoot off background tasks. Was hoping to replace that. > Supabase is a popular database hosting service for Prisma Agreed! We actually use Supabase as our backend for Willow[1] and use Prisma when writing backend functionality. It's been a real easy and fast process to use Supabase's JS client on the frontend to access data (with RLS!) and then Prisma+Supabase on the backend to modify data (with types!). We would love to allow user's to directly change data everywhere directly from the browser but we need to do some background tasks (sending notifications or updating related rows). The dream would be to have a great DX experience around using insert/update triggers to call Supabase functions to run background tasks. Some type of Terraform-esque configuration (in a SCM) to set it up and keep it in sync would be awesome. We have some triggers that make http calls but we're limiting usage as keeping track of them outside of our other code isn't simple. [1] https://heywillow.io https://heywillow.io
- kylehotchkiss 5y agoI'm excited about the new functionality and find the cause of not defaulting to Cloudflare Workers commendable, I worry a little about the long term viability of Deno Deploy - is there a backup platform that Supabase edge could deploy to in the event of a Deno Deploy acquisition, or even better, is Supabase going to acquire Deno Deploy?
- kiwicopple 5y ago> is there a backup platform that Supabase edge could deploy to in the event of a Deno Deploy acquisition Yes, we could host this all ourselves (since the Deno runtime is open source) on AWS, or more likely we'd work with someone like Fly who have a globally-distributed platform like Deno Deploy. > is Supabase going to acquire Deno Deploy There's no chance of that happening. We couldn't afford them. Deno will be a huge company - and rightfully so, their product is best-in-class
- kylehotchkiss 5y agoThanks for taking the time to respond to my concerns kiwicopple - I'm looking forward to giving your edge functions a spin then!
- jFriedensreich 5y agoglad to see this is using deno, wich is an obvious choice at this point and seems to get more and more traction.
- tylermcginnis 5y agoSo impressed with Supabase's ability to continue to ship quickly even as they grow. Congrats team.
- zwarag 5y agoCongratulations on the launch Supabase-team! Can't wait to try it out. I love that you went with deno for that.
- tagnifi 5y agoDo you see a future where a language like Dart could run on edge functions (via WASM), all while integrating nicely with the DX?
- inian 5y agoLooks like Dart doesn't support Wasm as a target yet but is considering it as part of their 2022 roadmap[0]. In the mean time, we will start off with supporting other languages like Rust which already have good support for compiling to Rust. [0] Wasm target for Dart - https://github.com/dart-lang/sdk/issues/32894#issuecomment-1010221532 https://github.com/dart-lang/sdk/issues/32894#issuecomment-1...
- andrew_ 5y agoThese folks are absolutely killing it. Can't wait to try this out.
- badestrand 5y agoI love the concept of Supabase, I only worry about performance in this case. Almost all API calls in my applications execute some SQL to gather data from the database. Having the edge function execute several select queries on the database on the other side of the world is a few times slower than having the API server near the database. Basically, the distance between API and database is much more important than the distance between user and API. I guess the only solution is to have read-copies of the database on the edge as well..?
- yawnxyz 5y agoI can't seem to find this anywhere, but what is the max execution time of these Edge Functions? 10secs like Vercel / Cloudflare?