What is serverless computing and how does Node.js fit in?

Answer

Serverless computing (Functions as a Service — FaaS) allows you to deploy individual functions that run in response to events, without managing servers. The cloud provider (AWS Lambda, Google Cloud Functions, Azure Functions, Vercel, Netlify) handles provisioning, scaling, and infrastructure. Node.js is the most popular runtime for serverless functions due to its fast startup time, small footprint, and JavaScript's suitability for event-driven architectures. Benefits: no server management, automatic scaling (scales to zero when idle — saving cost), pay-per-invocation pricing, high availability built-in. Limitations: cold starts — first invocation after idle period has higher latency as the runtime initializes (Node.js cold starts are faster than Java/Python); execution time limits (AWS Lambda: 15 minutes max); stateless (no persistent connections — use connection proxies like RDS Proxy for databases); vendor lock-in. Best for: API endpoints, webhook handlers, background jobs, scheduled tasks, event processors. Less suitable for: long-running processes, WebSocket servers (though possible with API Gateway), heavy stateful computation. Frameworks: Serverless Framework, AWS SAM, SST for structured serverless development.