Serverless Architecture and FaaS: Code without Servers
💡 Quick Tip
Pro Tip: Serverless doesn't mean there are no servers, but that you don't have to manage them or pay for them when not in use.
The Concept of Serverless
Serverless Architecture is the logical evolution of cloud abstraction. Developers write individual functions for specific tasks. These functions execute in response to events (like file uploads or HTTP requests). The provider provisions hardware, boots the runtime, executes code, and shuts it down immediately after.
FaaS: Function as a Service
The core component is FaaS. Unlike traditional 24/7 servers, a FaaS function (like AWS Lambda) is ephemeral.
- Pay-per-use: You only pay for the milliseconds the code runs.
- Infinite Scalability: If you receive 10,000 requests, the provider launches 10,000 instances in parallel transparently.
The "Cold Start" Problem
A major technical challenge is the Cold Start. If a function hasn't run in a while, the provider must download code and start the container, introducing up to 1-2 seconds of latency. This is critical for apps requiring millisecond responses.
📊 Practical Example
Real-World Scenario: Automatic Invoice Processing with AWS Lambda
Step 1: Trigger Definition. We configure cloud storage (S3) to send a notification to a Lambda function every time a '.pdf' file is created.
Step 2: Function Writing. We program Python code to open the PDF, process it, and connect to a SQL database. Timeout is set to 30 seconds.
Step 3: Memory Management. We adjust the RAM. In Serverless, assigning more RAM usually allocates more proportional CPU power, which can reduce execution time and cost.
Step 4: Monitoring. We use CloudWatch to see logs. Processing 100,000 invoices costs just a few euros monthly, eliminating the cost of an underutilized dedicated server.