Skip to content

Serverless Computing Introduction — What Is Serverless?

DodaTech Updated 2026-06-28 5 min read

In this tutorial, you will learn about Serverless Computing Introduction. We cover key concepts, practical examples, and best practices to help you master this topic.

Serverless computing is a cloud execution model where the provider dynamically manages resource allocation, scaling infrastructure up or down instantly while you pay only for compute time consumed.

What You'll Learn

By the end of this lesson you will understand what serverless computing is, how it differs from traditional server-based hosting, and when to choose serverless for your backend applications.

Why It Matters

Traditional servers require capacity planning -- you guess how much traffic you will get and pay for idle capacity. Serverless eliminates that entirely. Your code runs only when triggered. Doda Browser uses serverless functions to process user-uploaded files, generate thumbnails, and validate malware signatures without maintaining any servers.

Real-World Use

A photo-sharing app uploads images to S3, which triggers a Lambda function to compress and resize the image, store metadata in DynamoDB, and notify the user -- all without any server infrastructure to manage.

flowchart LR
    U[User Upload] --> S[S3 Bucket]
    S --> L[Lambda Trigger]
    L --> C[Compress/Resize]
    L --> D[DynamoDB]
    L --> N[SNS Notification]
    style L fill:#f90,color:#fff

How Serverless Works

Serverless platforms wrap your code in a function, deploy it to the cloud, and expose it through triggers. When an event occurs, the platform provisions a container, loads your code, executes it, and tears down the container when done.

# simple_serverless.py
# A serverless function concept

def handler(event, context):
    """Process an incoming event and return a response."""
    name = event.get("name", "World")
    message = f"Hello, {name}! This ran on a serverless platform."
    print(f"Processed: {name}")
    return {
        "statusCode": 200,
        "body": {"message": message, "event": event}
    }

# Simulate invocation
test_event = {"name": "Alice"}
result = handler(test_event, None)
print(result)

Expected output:

Processed: Alice
{'statusCode': 200, 'body': {'message': 'Hello, Alice! This ran on a serverless platform.', 'event': {'name': 'Alice'}}}

Key Characteristics

Serverless functions are stateless -- each invocation starts fresh with no in-memory data from previous calls. They auto-scale from zero to thousands of concurrent executions. You pay per request and compute duration, never for idle capacity.

# stateless_demo.py
# Demonstrating stateless behavior

counter = 0

def handler(event, context):
    global counter
    counter += 1
    print(f"This is invocation #{counter}")
    return {"invocation": counter}

# Simulate multiple invocations
for i in range(3):
    result = handler({}, None)
    print(f"Result: {result}")

Expected output:

This is invocation #1
Result: {'invocation': 1}
This is invocation #2
Result: {'invocation': 2}
This is invocation #3
Result: {'invocation': 3}

In a real serverless environment each invocation would start with counter at 0 because the global state does not persist across invocations.

Serverless vs Traditional

Aspect Traditional Serverless
Scaling Manual or auto-scaling groups Instant, automatic
Cost Pay for provisioned capacity Pay per execution
Maintenance OS updates, patching Provider managed
Cold start None Initial latency
Max duration Unlimited Typically 15 minutes

Common Mistakes

  1. Thinking serverless means no servers: Servers still exist -- the provider manages them. You do not provision, patch, or monitor them directly.

  2. Assuming it is always cheaper: Serverless is cost-effective for variable or low traffic. Constant high traffic may be cheaper on provisioned servers.

  3. Ignoring cold start latency: The first invocation after idle incurs setup overhead. For latency-sensitive apps this matters.

  4. Writing stateful functions: Storing data in global variables or local files does not persist across invocations. Use external storage.

  5. Not setting appropriate timeouts: Default timeouts are short. Long-running operations exceed the limit and get killed silently.

Practice Questions

  1. What is serverless computing and how does it differ from traditional hosting? Serverless computing runs code on-demand without provisioning servers. You pay per execution instead of paying for idle capacity.

  2. What does stateless mean in serverless functions? Each invocation starts with no memory of previous invocations. No in-memory data, session state, or local files persist across calls.

  3. How does serverless pricing work? Charges are based on number of requests, execution duration, and memory allocated. No charges for idle time.

  4. What is the maximum execution time for serverless functions? AWS Lambda has a 15-minute limit. Azure Functions allows 10 minutes. Google Cloud Functions allows 9 minutes for HTTP functions.

  5. Challenge: Compare the monthly cost of running a Node.js API on a $10/month VPS versus AWS Lambda at 100,000 requests/day with 200ms average duration and 256MB memory.

FAQ

Is serverless really no servers?

No. Servers still exist but the cloud provider manages them. You do not provision, patch, or monitor servers.

Can serverless handle high traffic?

Yes. Serverless auto-scales to thousands of concurrent executions. AWS Lambda handles hundreds of thousands of requests per second.

What languages does serverless support?

Most platforms support Node.js, Python, Java, Go, Ruby, C#, and custom runtimes via container images.

When should I NOT use serverless?

Constant high-traffic workloads where cost advantage diminishes, long-running jobs exceeding time limits, and workloads needing specific hardware like GPUs.

How does serverless handle authentication?

Use API Gateway authorizers, Lambda authorizers, or platform-specific auth layers that run before your function code.

Mini Project

Write a serverless-style function that accepts an HTTP event, parses query parameters, fetches data from a simulated database, and returns a JSON response.

def api_handler(event, context):
    path = event.get("path", "/")
    method = event.get("httpMethod", "GET")
    params = event.get("queryStringParameters", {}) or {}
    body = event.get("body", "{}")
    import json
    
    if method == "GET" and path == "/users":
        users = [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]
        if "search" in params:
            users = [u for u in users if params["search"].lower() in u["name"].lower()]
        return {"statusCode": 200, "body": json.dumps(users)}
    
    if method == "POST" and path == "/users":
        data = json.loads(body)
        return {"statusCode": 201, "body": json.dumps({"id": 3, **data})}
    
    return {"statusCode": 404, "body": json.dumps({"error": "Not found"})}

event = {"httpMethod": "GET", "path": "/users", "queryStringParameters": {"search": "alice"}}
print(api_handler(event, None))

Expected output:

{'statusCode': 200, 'body': '[{"id": 1, "name": "Alice"}]'}

What's Next

Next: FaaS — Function as a Service to understand the core building block of serverless platforms.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro