DEV Community

Cover image for Serverless application development in 5 minutes with Node.js
Mateusz Gajda
Mateusz Gajda

Posted on • Updated on

Serverless application development in 5 minutes with Node.js

Serverless is one of those trends that excite both developers and business people, due to all the potential benefits it can provide. Want to quickly get up to speed with it? Let’s create a serverless application in a couple of minutes with Node.js! It’s a great opportunity to find out more about the strengths and weaknesses of serverless application development.

What if I told you that you can create your REST API, deploy it on a server, and connect it to the database in just 5 minutes? What’s more, it won’t drain your wallet. Sounds good? Let’s talk today about serverless.

Let’s establish an important fact. Unfortunately, serverless doesn’t mean that our code will magically run without a server 😢. What we get is a solution which allows us to deploy the code without having to manage the whole server infrastructure. Everything runs automatically. All we have to do is bring our code to one of the popular platforms and all of our worries about buying servers, monitoring, or scaling can be forgotten.

But it’s not all roses. An important aspect to consider is vendor lock-in. When our configuration is big, it can be hard to migrate from one vendor to another. Each one of them has specific services and different ways to configure them. Once we decide on one of them, it can be very difficult to change it.

With that said, let’s take a closer look on the bright side of serverless 😉

Benefits of serverless app development

I noticed that most developers don’t find it very hard to create custom software or design its architecture. This is our daily bread and we feel comfortable about it. The problem occurs when we need to deploy our application somewhere. I think that people are a little bit afraid of the server layer. Managing and deploying applications correctly might give you a headache.

What if we didn’t have to do it? That is one of the reasons why we should try this new fancy solution called serverless. It allows us to focus solely on writing an app, without having to care about infrastructure.

But what about the cost? Unlike with traditional servers, we only pay for the resources used or for the functions called out. But what does it mean?

Let’s say we have an application, which is used mostly during standard working hours (9-17). For the rest of the day, the application “sleeps”. With the traditional approach, we will pay for the whole day all the same, even if no one has used the application for almost 16 hours. In a case like this, we can save up a lot with serverless. Why? Because when our service is deployed as a function, we pay only for each execution or for the execution time. The cost is tied to actual usage.

What else can functions give us? For once, they are extremely scalable. Depending on the traffic, the functions scale up to a level that will allow for handling of all the requests. They are also highly available, so we don’t have to worry about service availability.

That’s the theory – what about practice? Let’s make a quick serverless for beginners project to really get you started!

Serverless application development frameworks

We’re going to use the Serverless Framework, one of the most popular tools for building serverless applications. It is an open source solution and you can find it on GitHub. This framework supports a lot of providers such as AWS, GCP, Azure, OpenWhisk and many others. It also supports different languages such as Node.js, C#, Java, Go, Python etc. With a large community around it as well as impressive popularity, it’s definitely worth a try.

Let’s create our REST API!

Below you will find a rest of an article! Have fun! :)
https://tsh.io/blog/serverless-application-development/

Top comments (0)