Serverless in Nest JS | Arshnoor Singh

Serverless in Nest JS

Serverless computing is a cloud computing execution model in which the cloud provider allocates machine resources on-demand, taking care of the servers on behalf of their customers.

When an app is not in use, there are no computing resources allocated to the app.

Pricing is based on the actual amount of resources consumed by application

With a serverless architecture we focus purely on the individual functions in your application code.

Services such as AWS Lambda, Google Cloud Functions, and Microsoft Azure Functions take care of all the physical hardware, virtual machine operating system and web server software management.

Cold start

A cold start is the first time our code has been executed in a while. Depending on a cloud provider we use it may span several different operations, from downloading the code and bootstrapping the runtime for code.

This process adds significant latency depending on several factors, the language, the number of packages application require.

The cold start is important and although there are things which are beyond our control, there's still a lot of things we can do on our side to make it as short as possible.

While you can think of Nest as a fully-fledged framework designed to be used in complex, enterprise applications, it is also suitable for much "simpler" applications or scripts.

For example, with the use of Standalone applications feature, you can take advantage of Nest's DI system in simple workers, CRON jobs, CLIs, or serverless functions.