Source

What is serverless computing

  • Servers in the cloud that require no configuration or maintenance from the developer
    • No need to manage infrastructure, scaling or maintenance of a resource
  • AWS Lambda, Google cloud functions, Azure functions, Firebase cloud functions
  • Allows us to run backend code across their global data centres
  • Useful for REST APIs, email, notifications and CRON jobs

Key features

  • Developers only need to write code and deploy it
  • Do not need to pick OS, configure networking, Patch dependencies or provision capacity
  • Easier to manage
  • Executes based on events in the cloud
    • Example: user places an order creates new database record triggers serverless function sends email confirmation

EC2 is not serverless

  • It is a cloud service, but not serverless
  • It is always running, and the developer is in charge of managing the operating system and maintaining the infrastructure
  • Manual scaling up and down
    • Auto scaling group exists, but it is not automatically done by EC2

Benefits

  • Runs on demand, not paying all the time, only when invoked
  • Automatically scaled
  • Developers do not need to directly manage the operating system
  • Most serverless architecture are distributed, no 1 instance that handles all the traffic

Cons

  • Less control over everything
    • Managing OS is abstracted away from developers
  • Lose control over OS level configurations
  • Can get expensive as developers are paying for the management instead of doing it themselves