jthegedus / svelte-adapter-firebase

SvelteKit adapter for Firebase Hosting rewrites to Cloud Functions for a Svelte SSR experience
https://github.com/jthegedus/svelte-adapter-firebase
MIT License
283 stars 34 forks source link

RFC: Deprecate Cloud Run support #118

Closed jthegedus closed 3 years ago

jthegedus commented 3 years ago

Describe the problem

We have basic Cloud Run support, though it may no longer be required in the near future.

:+1: if you agree with deprecation

:-1: if you wish to see Cloud Run support remain

Please comment if this would be disruptive to your workflow and WHY you use Cloud Run over Functions with this Firebase Adapter

jquesada2016 commented 3 years ago

I personally think this would be great going forward.

jthegedus commented 3 years ago

I personally think this would be great going forward.

You think deprecating Cloud Run or keeping Cloud Run would be great?

jquesada2016 commented 3 years ago

I personally think this would be great going forward.

You think deprecating Cloud Run or keeping Cloud Run would be great?

I think deprecating Cloud Run would be a good idea.

CaptainCodeman commented 3 years ago

I can see how going with "functions" would be much simpler, but I much prefer to use cloud run

Edit: Actually, scratch that - my Cloud Run vs Function bias is todo with using Golang services ... the functions route is probably the sensible choice for the Svelte SSR and endpoints.

jthegedus commented 3 years ago

@CaptainCodeman I prefer Cloud Run too. I updated the PR with a link, I suggest you take a look.

CaptainCodeman commented 3 years ago

Sorry, I'm not sure I understand what link you mean and what I am meant to be looking at.

Do you mean the link at the top of this issue? That just links to a list of firebase issues: https://github.com/firebase/firebase-tools/pulls?q=is%3Apr+sort%3Aupdated-desc+cloud+run+is%3Aclosed

jthegedus commented 3 years ago

Yes, I meant that link. The existence of issues matching that filter indicate why this RFC exists.

SrZorro commented 3 years ago

https://github.com/jthegedus/svelte-adapter-firebase#function-vs-run

The only problem I see its that we would lose the Cold start mitigations, does the "stay tuned" in functions means there will be an equivalent for functions?

My current path its develop locally with functions to use the functions debugger, and when Im ready to deploy I was going to use cloud run to prevent cold start.

There is another way with functions? If so I would be happy to ditch cloud run.

jthegedus commented 3 years ago

does the "stay tuned" in functions means there will be an equivalent for functions?

As I understand, yes. Given Google Cloud Next 2021 is on mid October, I figure some announcements will be made then.

CaptainCodeman commented 3 years ago

Cloud Run has another significant benefit over cloud functions.

The default concurrency is 80 requests per instance and it can be configured as high as 1,000

Cloud functions on the other hand has a limit of ... drum roll ... 1. Yes one concurrent request per instance.

I think if you're doing anything non-trivial there should be benefits to using Cloud Run.

jthegedus commented 3 years ago

Cloud Functions now has min_instances support.

Official release blog post - https://cloud.google.com/blog/products/serverless/cloud-functions-supports-min-instances

Firebase supports this in https://github.com/firebase/firebase-functions/releases/tag/v3.15.5

You can use it like so:

const myRuntimeOptions = {
    memory: "1GB",
+   min_instances: 1,
}
exports.myFunc = functions.runWith(myRuntimeOptions).https.onRequest(async (request, response) => {
    ...
});

Official docs - https://firebase.google.com/docs/functions/manage-functions#min-max-instances

Idle (not handling requests) instances are billed at 10% of the running instance cost (which varies depending on memory/cpu type)

Typically, to keep one idle function instance warm costs less than $6.00 a month. The Firebase CLI provides a cost estimate at deployment time for functions with reserved minimum instances. Refer to Cloud Functions Pricing to calculate costs. -Firebase docs

See the full runtime options available here - https://github.com/firebase/firebase-functions/blob/d46ec6191e61f560f3f21f13333e0f3285d3de90/src/function-configuration.ts#L101

Note: this is still single concurrency, though like I said above, watch this space.

Also Node.js 16 is available as of https://github.com/firebase/firebase-tools/releases/tag/v9.17.0