Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Add max instances to runtimeOptions? #566

Closed
alexlouden opened this issue Oct 9, 2019 · 25 comments
Closed

Question: Add max instances to runtimeOptions? #566

alexlouden opened this issue Oct 9, 2019 · 25 comments

Comments

@alexlouden
Copy link

I've been reading through #425 (@merlinnot's proposal to add retry to runtimeOptions) and I was wondering whether it would make sense to add max-instances too? Or should this wait until max-instances is out of beta?

interface RuntimeOptions {
  maxInstances?: number;
  retry?: FailurePolicy | boolean ;
  memory?: '128MB' | '256MB' | '512MB' | '1GB' | '2GB';
  timeoutSeconds?: number;
}

At the moment all our firebase cloud functions are deployed via CD - we try and avoid using the gcloud CLI or the web console. (I've actually only recently discovered that retry and max-instances existed!)

@google-oss-bot
Copy link
Collaborator

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@antonyharfield
Copy link

I was looking for this today +1

@jeffwhelpley
Copy link

I would love to have this. Is it just a matter of updating the typing? I can enter a PR if it would help.

@andieromero
Copy link

Hi there, thanks for request! We don't have plans to implement this, but I'm happy to discuss your idea with the team. Can you provide more details for this proposal and implementation?

@andieromero andieromero added the Needs: Author Feedback Issues awaiting author feedback label Dec 19, 2019
@google-oss-bot
Copy link
Collaborator

Hey @alexlouden. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@jeffwhelpley
Copy link

@andrianabeltran I am not sure about retry or runtimeOptions but for maxInstances I believe the idea is to simply pass whatever value that is set to the function configuration on GCP per this spec:

https://cloud.google.com/functions/docs/max-instances

@google-oss-bot
Copy link
Collaborator

Hey @alexlouden. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot
Copy link
Collaborator

Since there haven't been any recent updates here, I am going to close this issue.

@alexlouden if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@alexlouden
Copy link
Author

Hi there, thanks for request! We don't have plans to implement this, but I'm happy to discuss your idea with the team. Can you provide more details for this proposal and implementation?

Hey @andrianabeltran, sorry for my delayed reply - had my laptop away for the holidays!

At the moment you can specify timeoutSeconds and memory for a cloud function by using:

exports.myLongRunningFunction = functions
    .runWith({
        timeoutSeconds: 540,
        memory: '2GB'
    })
    ...

When you edit the deployed cloud function via the GCP Cloud Functions web interface in addition to the above there are the following options - you can enable "Retry on failure", and specify "Maximum function instances":

image

The ability to specify a failure policy (basically a way to enable "Retry on failure") was just added - see #482 and firebase/firebase-tools#1858 (@samtstern is working on this).

I'd like to be able to specify timeout, memory, retry and also maximum function instances all via the runWith runtimeOptions - e.g.

exports.myLongRunningFunction = functions
    .runWith({
        timeoutSeconds: 540,
        memory: '2GB',
        retry: true,
        maxInstances: 15
    })
    ...

The aim is to make the source code the source of truth for the cloud function's config, so we don't have to manually edit functions' config via the web interface at all - this proposal would mean the GUI, CLI and the runtime options would all be at parity :)

I hope this makes sense! Please let me know if you have any more questions :)

@mbleigh
Copy link
Contributor

mbleigh commented Jan 7, 2020

This seems reasonable. There's an internal process for approving new API changes, and I've just kicked it off to take a look at this. I can't guarantee when we'll be able to implement, but if anyone in the community has the time to make PRs we'd be happy to review 😄

@google-oss-bot
Copy link
Collaborator

Hey @alexlouden. We need more information to resolve this issue but there hasn't been an update in 7 days. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@alexlouden
Copy link
Author

Thanks for that @mbleigh! Is there a way to stop the bot from automatically marking this as stale?

@samtstern
Copy link
Contributor

Sorry about that! The bot will back off now.

@StatusQuo
Copy link

this feature would be great for us to handle with contingents and limit the progress of work of pubsub topic

@efiShtain
Copy link
Contributor

I've patched the code to support max instances
if any one needs the patches I can share them
it requires a patch to firebase-functions and firebase-tools
and can be easily applied using the npm patch-package module

@rafaelrene
Copy link

Adding this to runtime options would be incredibly useful. Can we do that @efiShtain?

@efiShtain
Copy link
Contributor

efiShtain commented Feb 27, 2020

@rafaelrene
That's exactly what I did

I use it like this:

export const polling = functions
    .runWith({ maxInstances: 1 })
    .pubsub.schedule('every 1 minutes')
    .onRun(PollingService.Run);

@StatusQuo
Copy link

@efiShtain that sounds great did you make a pull request? Maybe reference it from here would be great. Thank you 🙏

@efiShtain
Copy link
Contributor

@StatusQuo
I've opened 2 pull requests on firebase-functions and firebase-tools
It's my first time creating a pull request for google code, so not sure about the process
but you can just look and copy the copy, not so many changes

@bolds07
Copy link

bolds07 commented Mar 15, 2020

any news on that?

@efiShtain
Copy link
Contributor

@bolds07
I'm waiting for reviewers to approve the pull request, out of my hands

@samtstern
Copy link
Contributor

@efiShtain I am really sorry about the delays here, I ran into some technical issues on the backend with a different but similar PR (the one to enable retryOptions) and I am trying to get those resolved as I think they will affect this to.

@samtstern
Copy link
Contributor

This issue was fixed by #624, so I am closing it. Thank you again to everyone for your contributions and your patience, we should have moved faster and we will try and do better in the future.

@bolds07
Copy link

bolds07 commented Apr 24, 2020

How does google server take in consideration the maxInstances value?
imho this is just a placebo parameter... there isnt any side effects of changing it...

I've a function with maxInstances set to 1... this function does simple return the currentTimeMillis so takes maximum 0.3 seconds to run (worst case).

AND STILL GCF HAS 200 INSTANCES OF IT

Clipboard01

so what is the point of that?
Documentation says that infrastructure will "try the best" to reach the maxInstances set but with no garantee and SOMETIMES the current instances value will exced it...

well as my graph shows THERE WASNT ANY TIME wihtout exceeding the maxInstances set... and most of the time it was 15.000% over the desired value...
15.000% in what plannet this is an acceptable deviation?

im sorry if i'm being rude but it is clear that this whole parameter is just a waste of time for either you engineer team as for any developer trying to use your infrastructure

@ianitsky
Copy link

ianitsky commented Feb 3, 2021

How does google server take in consideration the maxInstances value?
imho this is just a placebo parameter... there isnt any side effects of changing it...

I've a function with maxInstances set to 1... this function does simple return the currentTimeMillis so takes maximum 0.3 seconds to run (worst case).

AND STILL GCF HAS 200 INSTANCES OF IT

Clipboard01

so what is the point of that?
Documentation says that infrastructure will "try the best" to reach the maxInstances set but with no garantee and SOMETIMES the current instances value will exced it...

well as my graph shows THERE WASNT ANY TIME wihtout exceeding the maxInstances set... and most of the time it was 15.000% over the desired value...
15.000% in what plannet this is an acceptable deviation?

im sorry if i'm being rude but it is clear that this whole parameter is just a waste of time for either you engineer team as for any developer trying to use your infrastructure

For me worked without problem. Verify any typo mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests