#2: Hosting: Server or Serverless
What this lesson covers
This lesson tackles the first hosting decision for the T-shirt store: run the code on a computer the team owns, or rent compute from a cloud provider. A spare laptop or desktop could serve requests, but hardware faults, power outages or being locked out of the house can take the service down, and moving the code elsewhere is slow. Cloud providers can replace a failed machine quickly and handle operating system installs and upgrades, which makes the design simpler, and at small scale the saved implementation effort outweighs tooling costs. Manual hosting is rejected. Within the cloud, the video compares two options. With a self-managed server, the provider looks after the operating system but the team deploys code and restarts the server through a console. With serverless, the team only writes code and the provider, AWS in the example, runs and scales it end to end, adding capacity when traffic rises and not charging for idle capacity after a sale ends. The lesson lists two drawbacks of serverless: it is less cost efficient per request than managed instances, and it can be less responsive because scaling reacts to traffic instead of capacity being booked ahead of an event such as a Diwali or New Year sale. Since these drawbacks are small for a low-volume business, the startup goes serverless, with managed servers and scaling revisited later in the course.
- Self-hosting on a spare machine risks outages from hardware faults and power loss
- Cloud providers recover failed machines quickly and manage operating system upgrades
- Serverless scales automatically and does not charge for unused capacity
- Managed instances usually serve more requests per dollar than serverless
- Serverless can lag during sudden spikes because scaling reacts to traffic