Serverless Compute

A microservices architecture is the inverse of a monolithic architecture. Instead of having all system functions in one codebase, components are separated into microservices and operate independently. A microservice does one thing — and does it well. Operations, updates, and scaling can be done on a per-microservice basis.


Inflexible scaling: Either increasing the instance size or duplicating the instance


Microservices operate as independent applications. They allow direct communication between components and the end user. If one part of the system requires more capacity, that service can be scaled and updated as needed.

 

API

You access the AWS Console via a user interface, which is designed for a human being. An API (or application programming interface) is an interface accessed (consumed) by another service or application.


An API endpoint hosts one or more APIs and makes them available on a network (private or public internet). APIs remain static — they are abstracted from what the code inside the service is doing. API consumers don’t care how things are done — only that the interface works. That’s what allows lower-risk changes.

The AWS CLI tools use the AWS APIs.

 

 

When using an event-driven architecture, a system operates around “events” that represent an action or a change of state – e.g., a button being clicked, a file being uploaded, or a temperature dropping below a certain level.

It’s efficient because events are generated and pushed, rather than things being polled. Polling requires always-on compute and doesn’t scale well.

 

Serverless architecture consists of two main principles, including BaaS (or Backend as a Service), which means using third-party services where possible rather than running your own. Examples include AuthO or Cognito for authentication and Firebase or DynamoDB for data storage.
Serverless also means using an event-driven architecture where possible, using FaaS (or Function as a Service) products to provide application logic. These functions are only active (invoked) when they are needed (when an event is received).

 

Lambda is a FaaS product. Functions are code, which run in a runtime. Functions are invoked by events, perform actions for up to 15 minutes, and terminate. Functions are also stateless — each run is clean.

 

API Gateway is a managed API endpoint service. It can be used to create, publish, monitor, and secure APIs “as a service.” API Gateway can use other AWS services for compute (FaaS/IaaS) as well as to store and recall data.

Pricing is based on the number of API Calls, the data transfered and any caching required to improve performance.

APIs can be migrated to API Gateway in a monolithic form, and gradually moved to a microservices architecture and then once components have been fully broken up a serverless & FaaS based architecture.

 

Step Functions is a serverless visual workflow service that provides state machines. A state machine can orchestrate other AWS services with simple logic, branching, and parallel execution, and it maintains a state. Workflow steps are known as states, and they can perform work via tasks. Step Functions allows for long-running serverless workflows. A state machine can be defined using Amazon States Language (ASL).

Without Step Functions, Lambda functions could only run for 15 minutes. Lambda functions are stateless. State machines maintain state and allow longer-running processes. Step Functions “replaces” SWF with a serverless version.