Yes and no... if your traffic is low enough that only a single instance is
started, that instance can cache data in memory, however when traffic
increases and a second instance is started, this approach breaks down as
the two instances are in separate containers and possibly separate
machines.  The instance will be shut down after a while if there are no
requests, but this probably isn't a problem here as I believe the timeout
is more than 90 seconds.

You can force your function to only run with a single instance using the
--max-instances flag at deployment time, but this will limit scaling;
you'll see "429 Too Many Requests" errors if the single instance can't
handle it all.  Details here:
https://cloud.google.com/functions/docs/max-instances

Cheers,
Phil

On Wed, Apr 8, 2020 at 8:20 AM MrGadget <ch...@langsenkamp.com> wrote:

> I'm looking at Google Cloud Functions <https://cloud.google.com/functions>
> and can't find a clear answer on whether data can be shared between
> requests.
>
> I have this tiny NodeJS API.  Some requests will post a small chunk of
> data, other requests will retrieve a subset of the data posted.  All data
> is transient (expires in 90 seconds).  If there is no posting or retrieval
> activity, the app can shut down and forget everything.  No database...all
> data is held in memory (key value pairs).  No logging needed.  Nothing
> visual: the posters and requesters are using a fat client to push and pull
> the data.
>
> I assume there can only ever be a single "instance" so that posted data
> doesn't end up in one instance and requesters are pulling from a different
> one and therefore wouldn't get some or all of the data.
>
> Is this feasible for a serverless cloud API?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-appengine+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-appengine/4b525a7e-ca00-46c4-bada-3af48f21ff4f%40googlegroups.com
> <https://groups.google.com/d/msgid/google-appengine/4b525a7e-ca00-46c4-bada-3af48f21ff4f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/CADCZVujarHM1R-JvsNP%3D%2B52GcNSCFWJkFfykQd%2BL%2BgFgkt2d9g%40mail.gmail.com.

Reply via email to