Home > Enterprise >  Are Firestore direct writes faster than writes via cloud functions?
Are Firestore direct writes faster than writes via cloud functions?

Time:01-06

Are there any performance tradeoffs when conducting a Firestore write operation through a call to a cloud function that performs writes via the admin SDK versus directly performing that write through the Firestore client SDK (assuming the cloud function runs in the same region as the Firestore instance and no cold starts)?

To add some more details: In https://stackoverflow.com/a/52175817/7446235 it is mentioned that reads through cloud functions are less performant than direct calls because of the "two hops".

However, also direct calls first have to pass the security rules - so isn't that an extra "hop" as well?

PS Unfortunately I don't have enough rep to comment so I have to ask this question here.

CodePudding user response:

Security rules are executed on the Firestore server itself, so there is no "extra hop" involved in rule evaluation. For practical purposes, a warm function in the same region as a Firestore DB will add a small amount of latency to a request, but likely not enough for that to be the deciding factor between using a Cloud Function or writing directly.

  •  Tags:  
  • Related