11 ms·
Introducing Cloud Functions for Firebase
- chuinard 10y agoAs a 2+ year user of Firebase, this is long overdue. I built my own cloud function infrastructure using their Java SDK and Digital Ocean and I couldn't have built my app (ProBooks.com) without it. It's good to see Cloud Functions moving from Alpha to Beta!
- kiliankoe 10y agoJust out of curiosity, what kind of functionality were you only able to build this way?
- inlined 10y agoPart of the primary power of cloud functions is you can extend firebase services instead of intermediating them. This lets you still take advantage of all the great features in the firebase SDKs.
- chuinard 10y agoOne feature of my app is the PDF creation of invoices and estimates. I use a Java library to make these PDFs. Developing an iOS, web, and Android app that syncs in real-time is much easier (or even possible) when your PDFs are made on the backend.
- gfosco 10y agoYeah, I remember when Parse offered these cloud functions back in 2012... It was a game-changer for "Backend-as-a-Service."
- elastic_church 10y agoWait till Google axes Firebase with no warning How many times can devs be burned, are we all masochists or just not have any memory of the last project that offered all this
- sdflkd 10y agoMasochists, no?
- elastic_church 10y agoyes, edited
- imtringued 10y agoI don't understand all the firebase and parse clones. They are not significantly better than firebase and they all entail vendor lock-in. The only real alternative is couchdb which unfortunately lacks document level read permissions (and filtered replication wastes storage) and still requires you to have an additional minimal server for the signup and passwort reset process.
- brendanlim 10y ago(Cloud Functions for Firebase PM here) We’ve been developing this product for years, and we’ve had it in private alpha testing for well over a year, so we’re incredibly excited to finally take the wrappings off and let all of you try it. Firebase has always focused on empowering you all to build extraordinary experiences for your users, without needing to worry about building common infrastructure. While we’ve made big strides towards this vision in the past, we always had one big hole: trusted code execution. Today, we’re completing the story with Cloud Functions for Firebase so that you can easily run server-side code in response to events from your Firebase app. We think you’re going to love it, and we can’t wait to see what you build with it!
- TY 10y agoBrendan, this is exciting news for lots of people! I'm developing a product on Firebase now and trusted code execution has always been my biggest concern. Sure, it could be mitigated, but all the workarounds added unnecessary overhead and breaking points. Want to thank you and your team for working on this. Firebase is a great product and this will make it just fantastic. One thing if I have your ear - I'd love to give Firebase team some money by purchasing paid support - ideally as a part of the new Google Cloud support options announced yesterday. I hope this is on your roadmap as well :-)
- kawera 10y agoAre there plans to allow functions written in other languages than javascript?
- inlined 10y agoCloud Functions for Firebase tech lead here. We'll get there in the future. We're looking forward to getting more feedback from users & prioritizing what is next.
- drumttocs8 10y agoFrom an onboarding and testing perspective, it would be nice to be able to integrate other services ("Outbound networking"?) in the free tier. Maybe limit to one connection?
- tedmiston 10y agoSo it looks like very roughly AWS Lambda in JS only for Firebase with nice user event hooks and Firebase Cloud Messaging. I'm wondering how they handle: 1 - pricing 2 - support for long-running tasks (where Lambda does not) 3 - official tooling for packaging and deployment (perhaps the biggest critique of Lambda) It sounds like one could build an entire real app in this, which is quite cool.
- habosa 10y agoYou can see pricing details here: https://firebase.google.com/pricing/ https://firebase.google.com/pricing/ It's based on invocations, GB-seconds, CPU-seconds, and network egress. And there's a free tier, so you should be able to try with your use case and estimate your total future cost.
- IanCal 10y agoBased on https://cloud.google.com/functions/pricing https://cloud.google.com/functions/pricing it seems like you can't pick and choose ram and CPU speed, so I'm not sure what the reason is to split the pricing between the two. I was quite interested in this because I've just found myself having to provision ~4x the amount of ram I actually need on lambda because I need more compute power. Edit - It's interesting to see another player in the field though, so I'll be watching how things go.
- deleted 10y ago[deleted]
- nivco 10y agoOn the Google Cloud Console you can change the memory allocation of your Cloud Functions: https://console.cloud.google.com/functions/list?project=_ https://console.cloud.google.com/functions/list?project=_ we'll be providing better integrations with Firebase tools and also looking into providing more options in the future.
- 10y ago
- flaviuspopan 10y agoI'm surprised by the progress and uptake of the node vm lib; it's really found a ton of cool business models. From powering the Screeps game world, enabling smart message routing for PubNub BLOCKS, to stuff like this. I'm excited to see more advances with time.
- drumttocs8 10y agoOh man. This is great. Firebase is now a one-stop shop for the majority of app infrastructure needs, and really is the closest thing to a "serverless" infrastructure. Vendor lock-in aside, I can't think of a reason not to use it, at the MVP level at least.
- self 10y agoI'll give you one: this won't work in China. I'm in the process of migrating a few GAE services to AppScale on AWS (Beijing) to set up a separate backend for the China-localized version of a mobile app. AppScale supports a lot of App Engine functionality, but not other Google services. No Firebase or GCM for me.
- subpixel 10y agoFirebase offers a lot, but it's no longer the only game in town that offers a sorta-serverless baas. Here are some compelling alternatives (I'd love to see a complete list of the best Firebase alternatives): - https://www.syncano.io https://www.syncano.io - https://www.graph.cool https://www.graph.cool - https://www.backand.com https://www.backand.com I'm omitting things like feathers.js b/c the most attractive feature of Firebase-like tools is not having to manage your own server/database.
- stemuk 10y agohttps://www.deepstreamhub.com https://www.deepstreamhub.com might be worth to take a look as well
- pier25 10y agoWe are moving from Firebase to Feathers js + PostgreSQL running on Heroku. Zero server/database configuration or managing needed. Being able to have data relationships and real querying is a big plus over Firebase.
- mparis 10y agoAnd https://scaphold.io https://scaphold.io!
- 10y ago
- deleted 10y ago[deleted]
- nodesocket 10y agoI plan on doing a benchmark and blog post of a simple node http function that just returns 200 and using Blitz.io to benchmark average startup latency of Google Functions. Curious to see how it scales as the number of concurrent requests increases and what the variance is.
- inlined 10y agoLet us know what you find. Be keep an eye on your usage and quotas in the Google Cloud console if you hit any limits.
- deleted 10y ago[deleted]
- mayop100 10y agoCloud Functions for Firebase is not a dupe of Cloud Functions. It is an extended offering with additional features. It's also prob of more interest to HN users.
- rshm 10y agoNo native python, java support like aws lambda. Are AWS 128MB instances constrained to 200MHz cpus ?
- inlined 10y agoOne of Cloud Functions unique offerings is the ability to scale CPU and memory separately.
- keithwinstein 10y agoThis looks like a worthy competitor to AWS Lambda, but I'm disappointed by the unalterable limit of 400 concurrent invocations of a function. (The "Quotas" page says "Max concurrent functions" is 400, with "Can be increased" as "No." https://cloud.google.com/functions/quotas https://cloud.google.com/functions/quotas) One of the cool things about AWS Lambda is that you can use it as a short-term supercomputer with thousands of threads. We (Stanford/UCSD ExCamera) are using AWS Lambda to do massively parallel low-latency video encoding with 4,000+ concurrent threads. Our colleagues at U.C. Berkeley who built PyWren are doing machine learning on Lambda with similar numbers of threads. AWS has been encouraging to us for these kind of workloads, even if they aren't what Amazon initially envisioned. So a hard limit of 400 (that can't be increased) would be a real bummer. I wonder if we can get around this by defining 20 identical functions and then invoking each one 400 times in parallel...
- inlined 10y agoIf you need more than 400 concurrent invocations please reach out to support (not promising whether or not we'll be able to satisfy arbitrary scale just yet). We're on day one of a Beta product and it'll keep getting better.
- phpencil 10y agoAnd just to clarify, Cloud Functions for Firebase is covered under the Firebase free support, who you can reach here: https://firebase.google.com/support/contact/troubleshooting/ https://firebase.google.com/support/contact/troubleshooting/
- dorianm 10y ago"You have 5 questions remaining" Limit is 5 per year, that's brutal
- ealexhudson 10y agoThe support comes from a genii. Make sure not to ask "Is the limit really 5?" with your first question.
- skybrian 10y agoHow does this compare to App Engine? The most obvious difference I see is that App Engine lets you handle HTTP requests using a variety of languages, not just JavaScript.
- habosa 10y agoIt's a pretty different model, so not really an apples-to-apples comparison. Cloud Functions are bits of code that run in response to events, whether those are events from Google Cloud / Firebase or HTTP triggers. These functions scale up and down as the event load changes. App Engine is a more traditional PaaS offering where you upload and entire web app, something you might otherwise run on your own server or a bare VM.
- skybrian 10y agoOkay, but App Engine also scales up and down on demand. And an HTTP trigger is just an HTTP request; it can be stateless if you like. So that sounds an awful lot like a function in the cloud. The part I'm not clear about is whether you can send non-HTTP events to App Engine or not? It seems like it might be useful.
- deleted 10y ago[deleted]
- camus2 10y agoBoth can be used as a swarm of workers, that's basically what "functions as a service" are. The difference is usually in the pricing strategy. with "FAAS", you pay only when the worker works, you're not paying when the server running them is idle, as opposed to classic server instances. App Engine standard has a few nice ideas in the way it implements push and pull worker queues, but given its limitations it was never going to be a huge success. But "FAAS" is obviously not suitable to serve a "user facing" website, and rely heavily on vendor locked in API that cannot be transferred to another vendor. Containerized worker jobs make more sense than "FAAS" IMHO. SAAS like iron.io provide that.
- boulos 10y agoLike many of you, I'm incredibly happy about how this: > This has been the most requested feature since Firebase launched is finally in place. Firebase is a great option for quickly getting something together, and now that you can extend it with little compute, this really is a massive expansion of what you can achieve. Disclosure: I work on Google Cloud (and sit near the Firebase folks!).
- marknadal 10y agoLook, I'm going to be honest - this is exciting, and Firebase is one of the best. But Google pushing this feature spells even more vendor-lock-in doom. My disclosure is obvious, I'm an Open Source competitor, switch to us ( https://github.com/amark/gun https://github.com/amark/gun ) and get "cloud functions" for free which can deploy to any services ( Docker enabled, Heroku 1 click install, run on GCS, AWS, etc.). And don't worry, we just load tested the system doing a sustained almost 2K throughput messages/second across a distributed system on low end hardware. We plan on getting this up to 10K inserts/second on a free Heroku box.
- Andrex 10y agoThanks to the mods for un-duping this and linking to the blog post, which went live like 7 minutes after I hit submit, haha. Anyways, this was the last piece of the Firebase puzzle for me. Between this, Authentication, Analytics, the DB (obviously) and Storage, Firebase has been indispensable in getting my side project app up and running -- and most importantly, feeling "real." My only request at this point would be a bit more TLC given to how Firebase integrates with React Native. I'm sure it's coming as it's likely a "still-small-but-growing" subset of use cases. As an example, there's not an obvious way to say, get Twitter auth working in a React Native app (last I checked a few weeks ago.) There are workarounds, of course. PS- The Firebase console and docs are some of the most slick and well-designed examples of what they do I've seen. I really enjoy the web console and the CLI tool. Just a real joy to use, and I'm not being sarcastic. :)
- digitalmaster 10y ago+1 For React native support! In fact emailed tech support about just yesterday. Got a really quick response in which they essentially said -- "....We're exploring potential solutions, but I can't share any details or timelines at this time." I'm optimistic. :)
- Andrex 10y agoThat's awesome! I might do the same thing in a bit. It's neat we can use the Web SDK with RN (in a limited capacity), but an official (or even semi-official) library would be the best.
- brilliantcode 10y agoThis is a major coup against AWS. I might actually use Firebase now. If they keep this up, they can put pressure on AWS.
- Kiro 10y agoI don't really understand how to use this to build a real backend. Everything seem to be revolving around reactions (new thing happening in the DB, file uploaded etc) but isn't the more common use case that you actually want to call the function directly? I'm building a simple React Native/Expo app where I want users to join random chat rooms so I obviously need some logic to delegate this process. Is Firebase/Cloud Functions something I can consider? My first thought was "oh, maybe I can let my app call the function directly to add the user to a random chat room" but I don't see how that is possible.
- mbleigh 10y agoYou can definitely do this! There are two ways that readily come to mind: 1. Use the Realtime Database as a communication channel to trigger a Cloud Function that then sets up the thing you need. 2. Create an HTTPS function and call it directly from your app, then do the work you need.
- inlined 10y agoWhen it hits YouTube, check out our talk "Cloud Functions and Firebase". We have a much more complex chat room example than has been possible in the past
- inlined 10y agohttps://youtu.be/GNR9El3XWYo https://youtu.be/GNR9El3XWYo
- Kiro 10y agoOh, I completely missed that there were HTTP triggers as well. Thank you!
- phpencil 10y agoThere are a few ways! For example when the user signs in, you could assign them a random chat room https://firebase.google.com/docs/functions/auth-events https://firebase.google.com/docs/functions/auth-events lets you trigger on initial sign in. You can also hook up to regular HTTP triggers, and make it like an API call: https://firebase.google.com/docs/functions/http-events https://firebase.google.com/docs/functions/http-events
- subpixel 10y agoThis was a long time coming, so congrats first. I also recently read this from an experienced Firebase developer: https://medium.freecodecamp.com/firebase-the-great-the-meh-and-the-ugly-a07252fbcf15#.7duy5djwl https://medium.freecodecamp.com/firebase-the-great-the-meh-a... Interestingly, he lists several things that he things Firebase needs in order to be awesome, and server-functions is last on the list: > 1. Real querying capabilities. Search, joins, the whole enchilada. > 2. Some sort of references likes MongoDB or RethinkDB. > 3. Real offline persistence with Javascript. > 4. Give me moar analytics. > 5. A cache API. > 6. Some way of adding server side code without needing to resort to a VPS.
- thawab 10y agoWe use flashlight[1], an elasticsearch plugin to querying firebase. There is another implementation using cloud functions and Algolia[2]. [1]https://github.com/firebase/flashlight https://github.com/firebase/flashlight [2]https://github.com/firebase/functions-samples/tree/master/fulltext-search https://github.com/firebase/functions-samples/tree/master/fu...
- mbleigh 10y agoWell, Cloud Functions for Firebase isn't the only thing we're working on... ;)
- rutierut 10y agoNr. 3 would be the end for me, I still don't get why they haven't implemented this, it exist for Ios and Android, why not web!!
- Andrex 10y agoI understand wanting a native version, but wouldn't it be relatively straightforward to connect to something like PouchDB for web persistence?
- pier25 10y agoAuthor here. That list wasn't really ordered in any way. And btw I've removed point 6 from that list.
- batuhanicoz 10y agoWe've been using this product in production for about 6 months now and it's been great once we've figured out best implementations (for us) like database structures.
- mmedal 10y agoWhat version of Node.js is currently running in Cloud Functions for Firebase? I assume it's LTS?
- mbleigh 10y agov6.9.1
- systemz 10y agoIs there any protection for not spending fortune if your cloud function endpoint is DDoS attacked?
- randylubin 10y agoVery cool - congrats on the launch! Is there any ability to set reoccurring functions or anything like a cron job?
- jwngr 10y agoNot a built-in way per-se, but you do have a handful of options. You can use a third party scheduling service like https://cron-job.org/ https://cron-job.org/. You could also use something like https://cloud.google.com/solutions/reliable-task-scheduling-compute-engine https://cloud.google.com/solutions/reliable-task-scheduling-... which uses Google App Engine and Cloud Pub/Sub. We actually have a sample that shows just this (HTTPS function using an external cron job service): https://github.com/firebase/functions-samples/tree/master/delete-unused-accounts-cron https://github.com/firebase/functions-samples/tree/master/de...
- randylubin 10y agocool - thanks for the tip!
- bikamonki 10y agoFinally! This was the feature that made me go with parse.com when I started making backend-less apps. For Firebase apps I have to spin-up tiny node.js bots to capture events and do some cloud code magic. Will start testing now!
- aphextron 10y agoQuite exciting. I just recently used Firebase for the first time in years and I was absolutely amazed at the level of productivity. The best part is how seamless and brain-dead everything is compared to AWS. Also the client side JS library for database storage makes handling application state a dream. Auth and static hosting require almost no configuration, and the only thing I couldn't use firebase for was server side compute based tasks. This is the final missing piece will allow me to develop an entire app on the google cloud with no more server admin. Can't wait.
- primitivesuave 10y agoI have been waiting for this feature for a long time. This was the final missing piece for building an entire software product entirely on Firebase. Right now, I'm running servers on Google Cloud that use firebase-queue to handle server-side requests like payments and restricted actions. Google Cloud Functions would have been overkill because it would involve setting up a whole new workflow for the team. This is perfect because it is integrated to the CLI and easy for anyone to use. All they need to work out now is educating their customers on the benefits of using Firebase over building a backend from scratch, especially in the trade-off between developer productivity and not owning your data.
- Dawny33 10y agoWow! Great to see GCloud going the serverless way. CloudFunctions vs Lambda would not be quite a clash now!
- intellegacy 10y agois the cloud notifications something I could use for push Notifications in Android and iOS app?
- phreack 10y agoThis is just great, the two things missing from Firebase that we kept hacking around were its very limited database querying abilities, and simple hooks around database events. Now one is part of Firebase and the other is more easily hackable than before, closing that little gap would make this the ultimate platform tool.
- quantumjs 10y agoAfter spending weeks getting to grip with AWS lambda I think I will try build something with firebase to see how it compares.
- johngorse 10y agoIs it possible to setup a Stripe server side .js code on this?
- timshim 10y agoBuilt our app, Wander, an IRC-like chat app, 100% with Firebase. We've been using Firebase Queue to get server scripting abilities. Can't wait to migrate to using Cloud Functions instead, just waiting for the (awesome) team at Firebase to iron out any teething beta-related issues. If only Realm made their server-side scripting available for free (or much less than the $1.5k/mo they're asking for Enterprise). That would give Firebase a run for their money.