Cloud Functions Flashcards

1
Q

What is Cloud Functions?

A

Cloud Functions is a FaaS solution offered by GCP.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

For which type of applications should Cloud Functions be used for?

A

Lightweight, single-purpose, event-driven applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 2 main differences between Cloud Run 1st generation and 2nd generation?

A
  1. First generation is not built on Cloud Run and Eventarc. Second Generation is built on Cloud Run and Eventarc.
  2. First generation does not support concurrency. Second generation supports up to 1000 concurrent requests.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the billing structure for Cloud Functions 2nd generation?

A

The same as Cloud Run

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the 2 different types of Cloud Functions and what are their execution guarantees?

A
  1. 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.
  2. Event-driven functions, they are invoked at least once. This is because event-driven functions are asynchronous.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

By default, when an event-driven function fails with an error, will the function be invoked again automatically?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which HTTP methods does an HTTP Function support?

A

GET
POST
PUT
DELETE
OPTIONS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is CloudEvents and how is it associated with Cloud Functions?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When are event-driven function executions considered complete?

A

When the function returns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a background activity and what is Google’s stand on it when using Cloud Functions?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When you write to local disk using Cloud Functions, where are you actually writing data?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the 2 ways to develop and test Cloud Functions locally?

A
  1. Functions Framework
  2. Functions Emulator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the 3 ways to deploy your code to Cloud Functions second generation?

A
  1. From local source code
  2. From Cloud Storage
  3. From Cloud Console inline
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What happens to your source code when you deploy to Cloud Functions?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Does Cloud Functions have the ability to integrate with Cloud Secret Manager like Cloud Run?

A

Yes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the default timeout for Cloud Functions invocations?

A

60 seconds

16
Q

Does Cloud Functions support split traffic?

A

Yes. It’s exactly the same as Cloud Run.

17
Q

Spring Cloud Function has out-of-the-box support for Cloud Functions.

A
18
Q

What is an event?

A

An event is something that happens at a specific point in time.

19
Q

What is a webhook?

A

A webhook is a push request from a server to a client specific endpoint. In other words, the client gives the server an endpoint to call whenever a specific event occurs, and the server pushes a request tot the client.

20
Q

Depending on the programming language used, a Cloud Functions Entry Point is either a …

A

Function or class

21
Q

What is the Functions Framework?

A

The Functions framework is an open source FaaS (function as a service) framework and library that lets you write lightweight functions that run in different environments that include Cloud Functions, your local development machine, and Cloud Run.

22
Q

Since Cloud Functions 2nd generation uses Cloud Run, is it possible to navigate to Cloud Run on Cloud Console and inspect your deployed revisions?

A

Yes

23
Q

Is it possible to bind a function to more than 1 trigger at a time?

A

No. However, the same event can trigger multiple functions that have the same trigger.

24
Q

Is it possible to use a YAML file to provide environment variables when deploying a Cloud Function?

A

Yes. However, this is only possible when deploying using gcloud.

25
Q

If you declare a variable in global scope, its value can be reused in subsequent invocations to a function instance without having to be recomputed resulting in significant performance improvements.

You can use this approach to cache objects like API client objects and network connections that may be expensive to recreate on each function invocation.

When accessing URLs from your functions, you should create persistent HTTP connections to those URLs. By creating persistent connections and caching them in your function’s global scope, you can reduce the CPU time spent to establish a new connection with each function invocation. You can also reduce the likelihood of exhausting your connection quota.

A