notesonly.in

One notebook for every subject — open it anywhere.

Log in

Serverless Computing Introduction: Complete Beginner's Guide

Serverless computing is a way to run code without managing any servers. You write a small function — for example, "resize this uploaded photo" — and the cloud provider runs it automatically whenever a triggering event happens, such as a file upload or a web request. You never provision, patch, or scale a server; the platform handles all of that, and you pay only for the milliseconds your code actually runs.

It removes the most tedious part of building software: a student or startup can serve one user or one million with the same code and no server administration. Idle apps scale to zero and cost almost nothing — impossible with traditional servers.

Key Concepts

  • FaaS (Function as a Service): the core model — you deploy functions, the provider runs them. Examples: AWS Lambda, Google Cloud Functions.
  • Event-driven: functions run in response to events — an HTTP request, a file upload, a database change, or a timer — not continuously.
  • Cold start: the small delay on a function's first run after idle, while the platform prepares its environment — usually milliseconds to a couple of seconds.
  • Stateless: functions do not remember anything between runs. Any data they need must come from a database or storage service.
  • Pay-per-use: billing by number of executions and execution time, typically with a generous free tier.

How It Works

  1. You write a function and tell the provider which event should trigger it, such as "when a user calls this web address."
  2. The provider stores your code and waits. Nothing runs and nothing is billed while idle.
  3. An event arrives — a request, an upload, a message. The platform instantly allocates resources and runs your function.
  4. Ten thousand simultaneous events run ten thousand copies in parallel; zero events scale back to zero.
  5. You are billed per execution: count × milliseconds × configured memory.

Worked Example

A photo app processes 1M uploads/month; its function runs 200ms per photo at 128 MB. Requests: the first 1M/month are free on most providers — zero. Compute: 1,000,000 × 0.2s × 0.125 GB = 25,000 GB-seconds. At ~0.0000167 dollars per GB-second: 25,000 × 0.0000167 ≈ 0.42 dollars/month. An always-on server for the same job costs tens of dollars monthly even when idle — serverless wins big for spiky, event-driven work.

Common Misconceptions

  • "There are no servers at all." Servers absolutely exist — they are just invisible to you. The provider owns and manages them; "serverless" means you never see them.
  • "Serverless is always cheaper." For spiky or low traffic, usually. For nonstop high-volume functions, a regular server can be cheaper — serverless bills every millisecond.
  • "Serverless functions can run forever." Providers cap execution time — commonly 15 minutes per run. Long background jobs must be split into smaller steps or run on regular servers.

Real-World Applications

Serverless powers thumbnail generation on upload, chatbots and webhooks, and scheduled jobs like nightly reports. Startups build entire backends from serverless functions plus managed databases, launching products with near-zero infrastructure cost. In India, many student hackathon projects and small business websites run on serverless free tiers, paying nothing until they grow. It is also the engine behind many IoT systems, where millions of tiny sensor events each trigger a short function.

To recap: serverless lets you run event-triggered functions with no servers to manage, automatic scaling from zero to thousands, and billing only for actual execution time. Remember the trade-offs — cold starts, time limits, and statelessness — and it becomes one of the fastest ways to ship software.