Cloud Functions Flashcards
What is Cloud Functions?
Cloud Functions is a FaaS solution offered by GCP.
For which type of applications should Cloud Functions be used for?
Lightweight, single-purpose, event-driven applications.
What are the 2 main differences between Cloud Run 1st generation and 2nd generation?
- First generation is not built on Cloud Run and Eventarc. Second Generation is built on Cloud Run and Eventarc.
- First generation does not support concurrency. Second generation supports up to 1000 concurrent requests.
What is the billing structure for Cloud Functions 2nd generation?
The same as Cloud Run
What are the 2 different types of Cloud Functions and what are their execution guarantees?
- HTTP Functions, they are invoked at most once. This is because in the case of an error, the caller of the HTTP function should decide to retry if needed.
- Event-driven functions, they are invoked at least once. This is because event-driven functions are asynchronous.
By default, when an event-driven function fails with an error, will the function be invoked again automatically?
No. An event-driven function will only be re-invoked if Retries on Failure is enabled. This can be enabled when creating a Cloud Functions instance. Keep in mind, retries will occur up to 7 days.
Which HTTP methods does an HTTP Function support?
GET
POST
PUT
DELETE
OPTIONS
What is CloudEvents and how is it associated with Cloud Functions?
CloudEvents is a specification for describing event data in a common way. This is what Event-driven Cloud Functions uses to handle events. Essentially, you import the CloudEvents package into your source code and use its classes and interfaces in your function code.
When are event-driven function executions considered complete?
When the function returns.
What is a background activity and what is Google’s stand on it when using Cloud Functions?
A background activity is anything that happens after your function has terminated. Google recommends not running any background activity code when using Cloud Functions. However, if you do, it is imperative that you make sure all asynchronous activity are finished before you terminate the function.
When you write to local disk using Cloud Functions, where are you actually writing data?
To a temporary directory which consumes memory resources. This is important to remember because data that you write to this directory can sometimes persist between invocations potentially leading to an out-of-memory error. Make sure to delete temporary files if you write to them when using Cloud Functions.
What are the 2 ways to develop and test Cloud Functions locally?
- Functions Framework
- Functions Emulator
What are the 3 ways to deploy your code to Cloud Functions second generation?
- From local source code
- From Cloud Storage
- From Cloud Console inline
What happens to your source code when you deploy to Cloud Functions?
When you deploy to Cloud Functions, your source code is stored in a Cloud Storage Bucket. Then, Cloud Build automatically builds a container image and pushes that image to Artifact Registry. Cloud Functions then uses that image to create instances to run your code.
Does Cloud Functions have the ability to integrate with Cloud Secret Manager like Cloud Run?
Yes.