Back to Blog
Cloud & DevOpsIntermediate

Going Serverless: Pros, Cons, and Use Cases

Simha Infobiz
June 2, 2024
5 min read

Serverless (like AWS Lambda, Google Cloud Functions) lets you run code without provisioning or managing servers. You upload your function, and the cloud provider handles the rest. You pay "per request" and "per millisecond" of execution time.

Pro: Infinite Scalability & Zero Cost for Idle

If no one uses your app, you pay $0. If 10,000 users hit it at once, the cloud instantly spins up 10,000 parallel copies of your function. You don't need to configure auto-scaling groups.

Con: The "Cold Start"

The first time a function runs after being idle, the cloud has to provision a micro-container, download your code, and start the runtime. This can take 500ms to 3 seconds. For real-time APIs, this latency is noticeable.

Use Cases

  1. Event-Driven Processing: "Whenever a user uploads a photo to S3, run this function to resize it."
  2. Cron Jobs: "Run this cleanup script every night at 3 AM."
  3. Glue Code: connecting different APIs or webhooks.

Verdict: Great for side tasks and uneven traffic. Bad for long-running processes (functions time out after 15 mins).

Key Takeaway

Serverless is not a silver bullet. Use it for "glue code" and event processing where its pricing and scaling model shines. Do not try to move your entire monolithic Rails app into Lambda unless you want a headache.

ServerlessAWS LambdaArchitecture
Share: