Unveiling the Secrets of Serverless

Prerna Mittal
5 min readMar 23, 2024

--

Ever heard of ‘serverless architecture’ and thought, ‘Wait, how can it be serverless if it’s still on the internet?’ Well, let’s clear up that confusion! Contrary to what the name suggests, serverless doesn’t mean there are no servers involved; it just means you don’t have to babysit them!
In this post, we’re going to dive into what serverless architecture is all about, how it works (with a dash of magic), and why it’s shaking things up in the tech world. So, buckle up, and let’s unravel the mystery of serverless together🔮

Imagine you’re hosting a big party at your house and want to ensure everything runs smoothly. You decide to hire a catering service to handle the food, drinks, and serving so you can focus on entertaining your guests. This catering service operates on a “serverless” model.

1At its core, serverless architecture means you don’t have to worry about managing the underlying servers or infrastructure to run your applications or services. It’s like hiring a catering service where you don’t have to worry about the kitchen, cooking equipment, or cleaning up afterwards. Instead, you simply provide the requirements and let the catering service take care of the rest.

2️Now, let’s talk about scalability. Just like how the catering service adjusts the amount of food and staff based on the number of guests, serverless architecture automatically scales up or down based on demand. If your party suddenly becomes twice as large, the catering service brings in more staff and resources to accommodate the increased workload. Similarly, in serverless computing, additional resources are provisioned automatically to handle spikes in traffic or usage.

For example, if your application experiences a surge in incoming requests, AWS Lambda will spin up additional instances of your function to handle the increased load. This elasticity ensures that your application can scale seamlessly without manual intervention.

3️But how does serverless architecture work without traditional servers? This is where cloud providers come into play. Instead of managing servers directly, you rely on cloud services like AWS Lambda or Azure Functions. These services allow you to deploy code in the form of small, stateless functions that are executed in response to events.
It’s like having the catering service deliver individual dishes directly to your guests as soon as they’re ready without needing a centralized kitchen.

Here’s a breakdown of how serverless works:

Event-driven execution: Serverless platforms operate based on an event-driven execution model. Events can range from HTTP requests database changes, file uploads, scheduled tasks, and more. When an event occurs, the serverless platform identifies the corresponding function configured to handle that event.

Function invocation: Once the event is detected, the platform invokes the corresponding function. Functions in a serverless architecture are typically small units of code that perform specific tasks or operations. For example, a function might be responsible for processing an image upload, generating a thumbnail, and storing it in a database.

Statelessness: Functions in serverless architectures are designed to be stateless, meaning they don’t retain any information or context between invocations. Each function execution is independent and isolated from previous invocations. This design simplifies scalability and ensures that functions can be dynamically scaled up or down based on demand without worrying about managing session state or shared resources.

Resource allocation: When a function is invoked, resources are allocated dynamically to execute it. This resource allocation is based on the requirements specified for the function, such as memory allocation and timeout limits. The platform ensures that there are enough resources available to handle the function’s execution efficiently.

Managed infrastructure: Behind the scenes, serverless platforms manage a fleet of underlying servers to execute functions. These servers are abstracted away from the developer, who only needs to focus on writing and deploying functions. The platform handles tasks such as server provisioning, scaling, monitoring, and maintenance, allowing developers to focus on writing code and building applications.

Optimized resource utilization: Resource utilization is optimized dynamically by allocating resources based on demand. When there are fewer incoming requests or events, the platform scales down the number of servers or resources allocated to minimize costs. Conversely, when there’s a surge in traffic or events, the platform automatically scales up resources to handle the increased load efficiently.

Execution Environment: Each function is executed within a container or runtime environment provided by the platform. This environment is ephemeral, meaning it’s created on-demand for the duration of the function’s execution and destroyed afterwards. Functions are isolated from each other, ensuring security and preventing interference between different executions.

Pay-Per-Use Pricing: One of the key benefits is its pay-per-use pricing model. Developers are only charged for the resources consumed during the execution of their functions rather than paying for idle resources or fixed capacity. This makes going serverless cost-effective, especially for applications with variable workloads or sporadic usage patterns.

4Le’ts see how Serverless compares to traditional architectures like Monolithic Architecture and Microservices-Based Architecture!

Sounds Interesting! But how do I get started with Serverless?

For a comprehensive tutorial on Azure Functions, including hands-on labs and interactive modules, I recommend checking out the Microsoft Learn tutorial on Azure Functions. Follow along with the guided steps to get started with serverless development.

If you want to get started with AWS Lambda, you can follow the tutorial video by AWS Developers YouTube channel here:

So, whether you’re hosting a big party or building the next groundbreaking application, remember that with serverless architecture, the only limit is your imagination. From the simplicity of writing and deploying functions to the automatic scaling and cost-effectiveness of serverless platforms, the benefits of serverless architecture are clear. The future is serverless — let’s make it extraordinary ✨

--

--

Prerna Mittal

Upcoming SWE @Microsoft | Ex-Intern @Microsoft, Cadence | Samsung PRISM Intern | NXP WIT Scholar'22 | UIUC+ Research Intern | Beta MLSA | GATE CS qualified