Lambda and Fargate.
Lambda is a serverless compute service that lets you run code without provisioning or managing the underlying servers. Its like you’re running code without computers.
Runtime – you pick an available runtime or bring your own.
Permissions – you need to attach a role for an AWS API call
Networking – you can define the VPC, subnet, and security groups your functions are a part of. Can run in or out of a VPC.
Resources – defining the amount of available memory will allocate how much CPU and RAM your code gets.
Trigger – whats going to alert your Lambda function to start? Defining a trigger will kick Lambda off if that event occurs
Lambda functions have a 15 minute timeout period. 10 GB of RAM is the limit on RAM, and CPU scales automatically.
Lambda is how you “add” features to AWS.
Lambda is great for microservices.
A container is a standard unit of software that packages up code and all its dependencies, so the application runs quickly and reliably from one computing environment to another. Dev, QA, Staging, Production – same environment. Its a way to standardize to run the application. Its like creating a micro-environment with everything needed to run the application.
Dockerfile used to build an image. Image file contains the code, libraries, dependencies, and configuration files needed to run an application. Registry – stores docker images for distribution, they can be private and public. Container – a running copy of the image that has been created.
Portability – can run on premise, in aws, easy to move environments and mirgrate from on-premises to AWS. Dev is prod, prod is dev.
Running containers in ECS or EKS
ECS – proprietary managed container service by Amazon. ECS can manage 1,10, hundreds, or thousands of containers. It will appropriately place the containers and keep them online. Containers are appropriately registered with the load balancers as they come online and go offline. Containers can have individual roles attached to them, making security a breeze. Ease of use – extremely easy to set up and scale to handle any workload.
Open Source – Kubernetes saves the day. Not use proprietary AWS tools. Can be used on-premises and in the cloud. AWS has managed version of Kubernetes called Elastic Kubernetes Service (EKS).
ECS vs EKS. ECS – ease of use, best used when looking for something simple. Doesn’t work on prem. EKS – open source comfort of kubernetes, not all in on AWS. There are some workarounds needed to work for compatibility inside the cloud. ECR – elastic container registry. Both are great for one-off or long-running applications.
ECS – you must define how much RAM and CPU will be used. Will create EC2 instances that containers are running on.
Removing servers with Fargate
AWS Fargate is serverless compute engine for containers that works with both Amazon ECS and Amazon EKS. AWS owns and manages the infrastructure. Requires use of ECS or EKS. Linux-only workloads.
EC2 – you are responsible for underlying operating system, EC2 pricing model for the pricing model (reserved instances, spot instances). Excels for long-running containers. Multiple containers share the same host.
Fargate – no operating system access, pay based on resources allocated and time ran. Excels at short running tasks – batch processing, responding to an API call, processing data uploaded to an S3 bucket. Runs, disappears when done. Isolated environments. Must define CPU and memory for the task. Minimum .5GB RAM and .25 vCPU.
Fargate vs Lambda. Fargate allows more consistent workloads to use docker and a greater level of control by developers. Lambda is for unpredictable or inconsistent workloads. Perfect for applications that can be expressed as a simple function.
Fargate doesn’t work by itself – it uses ECS or EKS as a requirement. Fargate is more expensive than EC2, but easier to use. Fargate is for containers that need to run longer, Lambda excels at short and simple functions.
Amazon Eventbridge (Cloudwatch events)
It is a serverless event bus. It allows you to pass events from a source to an endpoint. It’s the glue that holds serverless applications together.
Define pattern: do you want the rule to be invoked based on an event happening? Or do you want this to be scheduled?
Select Event Bus. Is this going to be an AWS-based event? A custom Event? or a partner?
What happens when this event kicks off? Do you trigger a lambda function? Post to an SQS queue? Send an email? You need to tag everything.
Sit back and wait for the event to happen, or test to make sure its working correctly.
Fastest way to respond to an API call.