Serverless Architecture- Why and How It’s a Smart Choice?

What is Serverless?

  • FaaS (Function as a Service): Stateless functions containing server-side business logic. These functions are run in independent containers and are event-triggered. These functions are fully managed by third-party providers, such as AWS lambda or Azure functions.
  • BaaS (Backend as a Service): This involves using third-party services to achieve the means, for example, firebase, Auth0. The applications utilising BaaS are typically client-rich applications such as SPAs or mobile apps. The client handles most of the business logic with the help of external services like authentication, database, user management etc.

Characteristics

  • Eliminates server management altogether
  • Stateless
  • Scales automatically
  • No operational cost
  • Cost is driven by events
  • Needs a startup time for the first event

Example — Application Architecture

  • Authentication function: This is a FaaS for managing user authentication (login).
  • Vehicle management service: A microservice for handling the vehicle-related operations like listing vehicles, viewing vehicle details, comparing vehicles etc. This service could be written using any language/framework. This service will interact with the database and will operate independently.
  • Vehicle bid function: This is another FaaS which will be used to place bids from users. This function will also interact with the database to register the bids.
  • API gateway: This acts as the entry point and reverses proxy for all the services. Call from client land here and then the gateway decides which service to redirect to based on routing rules.

Serverless vs. PaaS

Similarities

  • There is no server management involved on the developers’ end.
  • Developers just need to focus on writing application code.

Differences

  • PaaS offers more control over the way you can deploy your application. But serverless if very opinionated and restrictive for deployment.
  • Serverless scales automatically whereas PaaS deployment needs to be configured for scaling.
  • Cost of serverless is driven by events as compared to the fixed cost in PaaS.
  • Once the code is deployed, the PaaS application is always up and ready to serve the request. In the case of serverless, it might take some time for the first event to start processing, depending on the frequency of events.

Use Cases

  • Cost — Serverless can be very cost effective depending on your load. If you have an ad hoc service, like sending emails.
  • Server management — Serverless can greatly reduce the operational cost of managing the servers.
  • Scaling — Serverless scales automatically
  • Response time — It takes some time for FaaS to initialise. If the load a very less (like one event per hours), each request will encounter this cold start, resulting in slower response times overall.
  • Faster release cycle — Since these functions are very small units, the release cycle becomes very small.

Following are some of the common use cases:

  • Web applications
  • Batch processing and schedulers
  • Mobile and IOT backend
  • Chatbots

Why Serverless Architecture?

  • Reduced server management
  • Reduced operational costs
  • Automatic scale up and scale down
  • Security is better compared to always running services
  • Cost is driven directly by the number of requests/events served
  • Simpler packaging and deployment
  • Reduced release cycle
  • Out of the box monitoring

Limitations

  • Startup latency
  • Vendor lock-in and reduced control over the servers
  • Performance optimisations are limited to code
  • Capped execution duration (like AWS lambda has 15 minutes of capped execution time)
  • The cost can be unpredictable
  • The difference in development and production environment
  • Complexity in testing and debugging

Winding Up

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
SYSTANGO

SYSTANGO

London’s leading digital agency Systango offers full service from strategy, scoping to launch & maintenance, innovative campaigns to enterprise infrastructure.