logo
Course

What is Serverless Backend

Imagine you want to run a restaurant, but instead of owning and maintaining a massive kitchen, you:

  • Only pay for the exact cooking time
  • Get chefs who appear instantly when an order comes
  • Never worry about kitchen equipment maintenance
  • Scale instantly from serving 10 people to 1000 people

That’s exactly how serverless backends work in the tech world. You write code, and Cloud providers like AWS, Google Cloud, Azure, or Vercel handle everything else for you.

While the term “serverless” might sound like there are no servers involved, servers do exist—they are just fully managed by a cloud provider, abstracted away from you, developers. But why this abstraction?

This abstraction allows you to focus on writing application logic while cloud providers handle infrastructure, scaling, and maintenance of your backend.

How is it different?

Let’s say you’re developing an API for a food delivery app or anything that comes to your mind.

  • With Traditional Backend

    You deploy your backend (e.g., a Node.js Express.js API app) on a Heroku dyno or an AWS EC2 instance. In this case,

  • You have to choose the server size (CPU, RAM)
  • You have to configure scaling for traffic surges
  • And manage everything related to that server for your API depending on the demand

While you get the whole freedom and your own server, you’ve to face some challenges,

  • Monitor traffic and manually scale up servers
  • If your servers are too large, you waste money; too small, and your app crashes
  • You pay for the server to run 24/7, even at 3 a.m., when no one is doing anything on your site

If you know enough about this and the domain of DevOps and rest related, you shouldn’t feel these as challenges but rather a piece of cake.

  • With Serverless Backend

    You write an API function that handles requests like, say, creating an order. You deploy this as a serverless function (more on that later).

  • This function runs only when a request comes in (e.g., someone places an order)
  • The cloud provider automatically scales it during peak hours and scales back down when traffic slows. You basically don't have to do anything apart from writing that serverless function—the main logical code and paying the cloud provider to do the rest of things. That's the beauty

I hope now you have the idea of how a Serverless backend is actually Serverless and is different from a Traditional backend.


Serverless Functions

A serverless backend is a collection of different serverless functions that work together to form an application's backend logic.

You write it, deploy it, and the cloud provider takes care of hosting, scaling, and executing it.

But what does a Serverless Function Look like?

It’s different for different providers.

If you’ve used Next.js to do some backend, you’ve already used Serverless functions. Congrats.

Below are examples of serverless functions for famous different providers:

That’s it for now. More so, all of them look similar. It’s basically: Learn Concept and Do Anything play. If you learn to build serverless backends using, say, Vercel, you won’t have that much of a problem with others.


So, should you use a Serverless Backend for Everything?

I wouldn’t say so. Never ever.

Depending on my knowledge so far, below are the perfect candidates for serverless backend:

  • Startups/Small Teams

    Serverless allows you to focus on building and iterating on the product instead of dealing with infrastructure, which is a perfect fit for small teams or startups.

    In this case, you don’t need to worry about scaling your servers as your user base grows, and you can quickly deploy without upfront hardware costs.

    Especially if you’re a student/developer with some SaaS plan, I would suggest going with this. Just get that prototype done first and then overcomplicate things if you would like.

  • Businesses with Unpredictable Traffic

    If your website or service has fluctuations in traffic (e.g., high traffic during sales or special events), then serverless is a perfect fit, as it can automatically scale to meet demand and handle a surge of users without requiring you to invest in and manage excess server capacity

Okay then,

Who Should Avoid Serverless Backend?

While serverless computing is efficient and cost-effective for many scenarios, it’s not a one-size-fits-all-solution.

Below are the cases where I think you better go with traditional backends:

  • An application requiring constant performance

    If you work or have an application like a trading platform, real-time gaming server, or even live streaming where applications require continuous availability and minimal latency, then the traditional backend is the way to go.

    Serverless in these scenarios may introduce some delay, especially if the function hasn’t been invoked recently. That’s its drawback, famously known as a “cold start”.

  • Complex, Long Running Processes

    Serverless is generally better for short-lived tasks.

    Complex, long-running processes like training machine learning models or rendering videos may not be a good fit because serverless functions are designed for fast, short executions.

  • Organizations with Specific Compliance Needs

    Industries like Healthcare or finance have a strict regulations around data handling, including where data is stored and processed.

    Since serverless functions are typically managed by cloud providers, you may not have full control over the physical servers or the location where your data is processed. This could be a barrier for organizations with strict data residency or security compliance requirements.

Got it?

By now, you should be able to decide what to use for your next portfolio project, that SaaS app idea, or the company project you'll be working on.

Learning

Remember, serverless isn’t a universal solution. It’s a tool, and like any tool, it’s used in the right context.

0 Comments

"Please login to view comments"

glass-bbok

Join the Conversation!

Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.

Upgrade your account
tick-guideNext Lesson

Introduction to Route Handlers