What makes Node.js work so well in a serverless environment? Is it its lightness? Or its “plays well with all OS's” feature maybe? Or is it its high accessibility translating into a wide pool of developers for you, as a service technology(s) vendor, to select from? Is it accessibility (again) which, empowers you, the developer, to break all skill level restrictions and strict back-end vs front-end delimitations? Why would you want to build out your serverless app with Node.js?
As the headline clearly states, I'll start this post already presuming that:
- you know what a “serverless architecture” is, what functions-as-a-service are; in short: both the specific terminology and the mechanism “setting in motion” an event-driven architecture
- you're already, at least to some point, familiar with the Faas and API Gateway tools ecosystem
- you're well aware of the specific challenges that arise and the obstacles that you need to overcome when you move your fully-hosted app to a serverless environment, to using a FaaS delivered to you by one of the big cloud platform providers
- you already anticipate the main advantages of a serverless app over a fully-hosted one (it's lighter, more performant, easily scalable, easier to develop, faster, nearly free to host etc.)
… since you're now planning to go serverless.
This being said, what I'm also assuming is that (whether you're a company or a freelance web developer) you're in that phase where you're evaluating all the potential technologies that could power your app.
And that you need strong reasons for building out your serverless app with Node.js instead of any other equally tempting modern technology.
Not only that I'll be pointing them out to you (these reasons), but I'll be sorting them into 2 main categories:
- Those addressing you, the service technologies provider looking to build out such an app
- Those addressing you, the developer “seduced” by all the opportunities that this “going serverless movement” lures you with, determined to build your first serverless app; you, the developer who's still searching for technology that would best suit his/her serverless app
As a Provider, Why Should You Use Node.js for Your Serverless App?
Here are the biggest benefits that you can reap, as a company, from building out your serverless app with Node.js:
- It's easy (and almost free) to host (especially if you're a start-up company, tied to a shoestring budget this Node.js feature's the right kick-start you need)
- It's lightweight: much more lightweight than any other “rivaling” web technologies, which will help you minimize cold start (something you must surely expect when you can't rely on a server when first initializing your functions, right?)
- It scales horizontally, incorporating multiple nodes communicating with one another
- It runs smoothly on all operating systems (so no need to target only specific ones)
As a Developer, Why Would You Build Your Serverless App With Node.js?
A legitimate question considering all the other powerful, features-loaded modern technologies that you could choose over Node.js.
Here's how “serverless &Node.js”, when brought together in the same app's development cycle, instantly turns you into a more productive, more “versatile” developer:
- Even if you have close to zero experience with managing large back-end systems, you can still write back-end code (back-end serverless functions, for instance) with Node.js, even as a front-end developer; and that without worrying about... patching your server, for instance. Implicitly, going for a Node.js & serverless “duo” you'll become more productive and efficient as a web developer.
- Background processing is “nothing but a child's game” in a serverless environment: you're practically empowered, as a developer, to write a little bit of code and just add a function which will make 2 services communicate. Now that's power!
- Also, since when building your serverless app with Node.js you're free from managing an infrastructure, high scaling becomes such a breeze
- And speaking of “being freed” from a heavy infrastructure, this way you get to focus exclusively on your app's business logic
- You get to build lightweight purpose-focused microservices (a lot faster, obviously), too, and not just conventional “monolith” type of applications
- You get to make use of the pay-what-you-use cloud model
2 Inconveniences When Going Serverless with Node.js
Now you didn't think that it would be all just “rainbows and butterflies” now did you?
There are but 2, let's call them, “nuisances” to expect when building your serverless app with Node.js:
- The great majority of Node.js developers have chosen this open source technology due to its big, active community. And yet, many serverless implementations (most of them, actually) are vendor-specific and not open-source. For you, as a developer accustomed with open source development, this might come as a downfall.
- Cold start is a reality you'll need to adapt to when going serverless. And loading heavy Node.js packages won't help you in this respect. So, do keep load time in mind, all the time, and consider clustering your entire code in one single file as a solution for not getting penalized.
Now, have I tipped the balance in Node.js's favor as the best choice for your nerveless app? Or do you still hold your doubts? Feel free to share them in the comments section here below!