home
aboutsubscribe

Serverless

April 10, 20201 min read

Photo by Kate Townsend on Unsplash

Recently explored more on Serverless architecture.

Serverless is the latest part of the progression in architecture trend: Monolith → Microservices → Serverless

In essence, serverless architecture incorporates Backend-as-a-Service (BaaS) services and/or codes run in Function-as-a-Service (FaaS) services, such that we have no need for a centralised dedicated server software and hardware.

Martin Fowler wrote a great in-depth article on this.


Traditional monolithic architecture

image credit: https://martinfowler.com/articles/serverless.html

Traditionally, applications were built on a monolithic architecture where we have a always-on centralised server application that manages all backend functions and logic - authentication, search, cronjob, page navigation, etc. All our codes exists inside a single codebase, and the entire application with all our modules are deployed at the same time. The challenge comes when the application grows larger and the infrastructure becomes more complicated to manage with additional modules, dependencies, and moving parts and bugs.


Example Serverless architecture

image credit: https://martinfowler.com/articles/serverless.html

Serverless is a recent architecture trend that moves away from monolithic architecture thanks to growing sophistication of 3rd-party cloud platform and services e.g. AWS, Azure, Firebase. It removes the need for a centralised always-on server component, and instead abstracts away the different backend modules to BaaS and FaaS.


BaaS examples:

  • cloud databases (Firebase Firestore, AWS RDS)
  • authentication (AWS Incognito, Firebase Authentication, Auth0)
  • AWS API Gateway

FaaS examples:

  • AWS Lambda, Google's Cloud Function
  • e.g. finalising Stripe payment for customer, cronjob, sending email
  • It allows us to write discrete pieces of logic and export them to these cloud functions that are event-triggered
  • with FaaS, the provider handles all underlying resource provisioning and allocation

Benefits of Serverless:

  • architecture is more flexible and amenable to changes
  • better division of concern
  • reduced engineering time and cost
  • reduced need of managing underlying infrastructure

Trade-off of Serverless:

  • more moving parts to monitor
  • significant reliance (incl. security) on service provider

...

A tweet thread of an example implmentation of serverless and its cost savings:

Running a serverless insurance startup, selling home, auto, renters, and umbrella in five states (http://ourbranch.com) on AWS. April AWS bill was just under $740.

DynamoDB - $202
CodeBuild - $116
Cloudwatch - $100
S3 - $66
AWS Directory Service - $36

@JoeEmison

...

Do keep in mind that serverless architecture is not the end-all-be-all solution. There are still cases where Monolithic architecture or Microservices architecture can be a better fit.



Thank you for reading

If you'd like a monthly email on new posts, please pop your email here.

If you like this article, please click on the meaningless heart icon below.

0 loves




© 2020 yinhow

built with

Gatsby Logo