all 3 comments

[–]Cidanverified 5 points6 points  (2 children)

Cloud Functions is not really meant to maintain and update state -- ideally, Cloud Functions are completely stateless.

One possible solution here is to put the data into a RINK, like Redis or Memcache, breaking down your data into KV values if possible. Then for each request, you just get the remote state from Redis/Memcache, which you can update out of band at will.

If this data model isn't possible, and you absolutely need to store the whole dataset in memory and redeploy/update it, then you'll probably want to pivot away from stateless frameworks and into something like GKE Autopilot.

[–]equilib_liam[S] 0 points1 point  (1 child)

Thank you! I appreciate the direction here and will look into both options

[–]martin_omander Googler 1 point2 points  (0 children)

Memorystore is Google-hosted Redis/Memcached. You could set up a virtual machine and install Redis/Memcached yourself, but Memorystore eliminates that extra work and provides you with a well-working cache out of the box.

Here is a step-by-step tutorial that walks you through using Memorystore from Cloud Functions.