Google Cloud Functions 00:00:01 A field photographer publishes a cloud function Rina uploads wildlife photos from a field station. A small function should produce preview images. This lesson follows the Cloud Run functions deployment model. The source she writes and the revision that ultimately receives traffic are different artifacts. In the illustrated source deployment, Rina submits the function source for the build workflow. Cloud Build uses buildpacks and the Functions Framework to make a container image. The image goes to Artifact Registry. Cloud Run creates a revision from the resulting image and configured runtime settings. The build produces an image with a Functions Framework entry point. A revision gives the team a concrete version to test. Keep the selected deployment generation and trigger configuration explicit when comparing provider behavior. 00:00:50 Separate setup time from image work An early-morning request reaches a service with no warm instance available. The first photo waits for initialization as well as handler work. A second photo may arrive when an instance is already available. Assume this service currently has zero running instances. A minimum-instance policy or billing mode would change the cost discussion. A request arrives and waits. An instance starts and runs the global code. The handler runs and answers. This request took start, setup and work. This later request can use an available initialized instance. It still pays for the actual preview generation. Move suitable reusable clients into initialization, while keeping per-photo data isolated. A warm process is a performance opportunity. It is not a promise about which earlier request state the next image will find. 00:01:46 Fit concurrent work into real instances The station receives six hundred requests per second, each averaging a fifth of a second. Under steady demand that is about a hundred twenty requests in flight. Guess the minimum mathematical instance count if each handles twenty at once. 600 requests per second at 0.2 s are 120 at once. With concurrency one, that same in-flight demand would require about a hundred twenty instances. Compare it with the explicit limit in this example. Above the available capacity, pending requests may wait and can eventually be rejected. The configured limits and actual traffic burst determine what happens. With concurrency 20 it is 6 instances, and more in practice because the scaler aims at 60%. Dividing a hundred twenty by twenty gives six fully occupied instances in the ideal calculation. Autoscaling target utilization, startup and uneven load generally require headroom. CPU-heavy image decoding may reduce the useful concurrency per instance. 00:02:50 One photo event reaches the function twice An object upload produces a storage event delivered through Eventarc. The handler writes a preview, then the success response is lost. The source photo and the first preview still exist when redelivery occurs. A photo is stored. Eventarc gets event 7. The function is called, makes the small picture and writes it. The instance stops before it answers. Eventarc sees no success. In this design a repeated event targets the same durable preview identity. A conditional or otherwise idempotent write prevents a second business effect. Use an event identity and a destination operation that handles duplicates safely. Check object generations when the same name can be overwritten, so suppressing a retry does not accidentally suppress genuinely new work. 00:03:42 Prevent a preview from generating its own preview Where should Rina write the derivative image? If the same creation trigger matches both originals and generated previews, one successful invocation can create the input for the next invocation. One photo, one event. The result goes into the photo bucket, which makes a new event. This example writes previews to a different bucket whose creates do not activate the original-photo function. Separate output destinations or filter events so outputs are ineligible. Test with one original and verify that exactly the intended preview is created. The field station can now reason about cold starts, concurrency and duplicate or self-generated events independently.