logo

Building with node.js

From server side javascript to serverless

I love using node.js to build the server part of web applications. Being able to use the same language and patterns on the server as the client feels incredibly productive. I based my full stack web applications on Express for years. That is an incredible library with superb documentation that I was very happy and successful with. I led a project porting Wordnik from rails to node.js based on Express and we radically reduced time to first byte while slashing server costs.

The advent of serverless where you can deploy an application into an initially low cost but highly scaleable environment and have all the OS level issues managed is a big relief. Most of the web applications I've built fall into the sweet spot to take advantage of serverless: there is some minimal server side code running aggregating APIs or hitting the database, keeping secrets but not a lot of cpu intensive code at that level so I now look forwards to simplifying the responsibilities of the application management by by running server side code on functions as a service like AWS Lambda.

Serverless libraries

You can take Express with you to Lambda. I have used libraries like https://claudiajs.com/ to try this and they work well but you are still deploying everything at once and end up with a larger code bundle which hurts your cold start time. The cold start time on AWS Lambda is getting lower all the time but you still have to be conscious of the amount of code you are putting in your serverless bundle because its execution increases the response time when your application is getting a first request in several minutes or is scaling up to handle spikes by launching new nodes.

When I am building new applications from scratch now I create a node.js API based on Architect. I love how this library creates a local dev environment, takes over bundling, deploying and setting up the triggers like API Gateway with a short config. The Architect getting started guide is pretty brief but does what it advertises. I've built several Architect based applications now and led a training class teaching a dozen front end developers of all skill levels how to use Architect and they all successfully deployed their own serverless application in a few minutes. The built in creation of both staging and production environments on application setup and the testing recommendations that run without a lot of dependencies and the support of the JS Foundation are excellent. The ability provided by Architect to split an application up into smaller parts and easily deploy them separately is nice. There is so much less stress involved in making a small fix to an endpoint and being able to run tests and a deploy in seconds without modifying the rest of your server side application.

Serverless in all its forms allows me as a web application developer to focus more on delivering business value than worrying about server configuration. Architect amplifies this by putting several AWS steps into a single command but is still based on the Cloud providers services. I can manually take apart anything Architect has setup for me or modify it using AWS commands.