25 February 2020
Serverless computing for beginners: questions & answers
Recently we’ve organised our eighth online webinar, and for the very first time, it focused on serverless computing. Mariusz Richtscheid, our Lead Node.js Developer, conducted a thorough introduction for beginners while I was answering the questions from the inquisitive participants. Obviously, we’re not gonna keep all this precious serverless knowledge for ourselves, so there you go – below you will find all the necessary materials on what is serverless computing and a summary of the Q&A session. Enjoy!
1. Will you share the webinar presentation?
And if you’d rather just read the presentation itself, it’s available here.
2. What is serverless computing?
In short, going “serverless” means that you don’t need to take care of the servers running your app. Mariusz has already written a beginner’s guide: “Serverless computing in Node.js” so if you want to read more, I highly recommend this article.
3. How long does it take to do a cold start in Node v.12 typically? I presume this time differs between languages?
It depends on the language and dependencies you’re going to use. Java and .NET are the slowest ones, Node.js is much faster – for simple APIs involving caching it might be 50-100ms, but as I said it all depends on dependencies. 😉
4. Is there a service where you can write serverless functions using TypeScript, or do you need to translate it to pure JS and deploy it?
The serverless framework has a special plugin that allows you to write a code in TypeScript. It is transpiled just before you deploy it on AWS.
5. I use Fargate for daily tasks. I’ve been struggling with memory issues though. Does Fargate support Docker-compose and Docker –link?
I think Fargate supports docker-compose syntax, not sure if it supports docker-compose file directly.
6. Can Fargate be used as close to serverless as possible?
Fargate is just a different concept of serverless. Instead of running functions, you are going to use Docker images with your “app” to be executed. If you use docker heavily then it’s a good idea to try Fargate.
7. What’s the use case of [email protected]?
To be honest, we haven’t used [email protected] yet, but I can imagine it might work as some middleware, allowing you to enrich requests/responses. It could also work as a kind of a backend-for-frontend, so we send a request, but get a little bit different response for specific device types.
8. How can you test code written in serverless on the local machine and prepare a development environment? How work in serverless look in a team where few people working on one big feature and how they can test each part (Lambdas) together before it will go to even pre-production?
Using serverless framework you’re able to invoke functions locally. What’s more, you can even use local databases for testing. You can also deploy each function to some special testing environment, called stage, and use it for testing.
9. 1000 concurrent execution per lambda?
The limit is on account, not per lambda!
10. Is there a cold start when you use the functions in Node.js? What if you want to use a lot of external dependencies?
Yes, the cold start is there, however, is much lower than for .NET or Java. That’s exactly why a lot of people would recommend you to use Node.js for Lambdas instead. As far as the second question does, you can share some dependencies using AWS layers.
11. Is AWS Lambda really the cheapest available solution?
AWS Lambda is the cheapest available solution on the market, as long as it’s configured properly. It is a tricky solution and can easily drain your credit card if used for things that it is not meant to be. So be careful!
12. With stateless approach is WebSocket API possible with serverless?
It wasn’t possible for some time, but lately, AWS allowed AWS API Gateway service to handle WebSocket connections. Underneath it reacts to WebSocket messages, sends an event from API Gateway and then your functions handle it.