Théo Champion
Théo Champion

Reputation: 1988

Is file system shared between cloud function instances?

I'm working on an image resizing cloud function (based on that code) that makes use of the available tmp to store temporary images in the function instance.

I noticed that, when multiple instances of the function are running simultaneously, the tmp from the last execution is not cleared leading to a race condition.

Is the filesystem shared for function instances? And how can I avoid such race conditions?

Upvotes: 0

Views: 386

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317958

Nothing is shared between server instances allocated for Cloud Functions. However, server instances will be reused between function invocations that happen to hit the same instance. This implies that you should clean up memory and disk space before a function terminates, else the instance could run out of memory before it's eventually deallocated.

Watch my video on exactly this topic for more discussion.

Upvotes: 3

Related Questions