0
0
GCPcloud~3 mins

Why Event triggered functions in GCP? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if your app could instantly react to anything happening, without you lifting a finger?

The Scenario

Imagine you have a website where users upload photos. Every time a photo is uploaded, you want to resize it and save a thumbnail. Doing this manually means constantly checking for new uploads and running resizing tasks yourself.

The Problem

Manually watching for new uploads wastes time and energy. You might miss some uploads or resize the same photo twice. It's slow, error-prone, and you have to keep your computer running all the time.

The Solution

Event triggered functions automatically run your code when something happens, like a new photo upload. You don't have to watch or check anything. The cloud service listens for events and runs your function instantly and reliably.

Before vs After
Before
while True:
  if new_file_uploaded():
    resize_image()
  sleep(10)
After
def on_file_upload(event):
  resize_image(event.file)
What It Enables

You can build apps that react instantly to changes without wasting resources or missing important events.

Real Life Example

When a user uploads a document to cloud storage, an event triggered function can automatically convert it to PDF and send a notification email.

Key Takeaways

Manual checking for events is slow and unreliable.

Event triggered functions run code automatically when something happens.

This makes apps faster, more efficient, and easier to maintain.