Aman Goyal

LeetCode LeetCode

Functions and Event-Driven Processing: Going Serverless

Core Concept

Often called serverless (but not exactly the same)


When to Use FaaS

Best for:

Examples:


Benefits

1. Extremely simple deployment


2. Auto-scaling


3. Strong decoupling


4. Cost efficient (for low traffic)


Challenges

1. Hard to debug & observe


2. No local state


3. Risk of hidden loops


4. Monitoring is critical


When NOT to Use FaaS

1. Long-running tasks

FaaS has execution time limits


2. Memory-heavy workloads


3. High sustained traffic


Key Patterns


1. Decorator Pattern (very important)

Example:

Lightweight and stateless → perfect for FaaS


2. Event Handling

Example:

Improves UX by offloading slow tasks


3. Event Pipelines

Example:

Signup → Send email → Subscribe user → Analytics

Like microservices but event-driven


FaaS vs Microservices

FeatureFaaSMicroservices
LifecycleShort-livedLong-running
TriggerEvent-drivenRequest-driven
StateStatelessCan hold state
ScalingAutomaticManaged

Key Insights


Trade-offs

Pros

Cons


One-line Summary

FaaS enables event-driven, stateless, auto-scaling functions that are ideal for lightweight, asynchronous tasks—but not suitable for long-running, stateful, or high-throughput systems.

#Distributed Systems #System Design #Serverless #FaaS #Event-Driven