Serverless architectures let you build and deploy applications and services with infrastructure resources that require zero administration. In the past, you had to provision and scale servers to run your application code, install and operate distributed databases, and build and run custom software to handle API requests. Now, AWS provides a stack of scalable, fully-managed services that eliminates these operational complexities. In this session, you will learn about serverless architectures, their benefits, and the basics of the AWS’s serverless stack (e.g., AWS Lambda, Amazon API Gateway, and AWS Step Functions). You will also get practical tips and tricks, best practices, and architecture patterns that you can take back and implement immediately.
So what is serverless?
When we say serverless, we mean it’s the removal of the undifferentiated heavy lifting that is server operations. This is an important distinction for customers because it allows customers to focus on the building of the application rather than the management and scaling of the infrastructure to support the application.
This means not thinking about infrastructure or scaling. It means you only pay for what you value, and it means availability and security are built in.
---
These are the tenets that define serverless as an operational model (unless you know better ones):
No infrastructure to provision or manage (no servers to provision, operate, patch, etc.)
Automatically scales by unit of consumption (scales by unit of work/consumption rather than by server unit)
Pay for value billing model (if you value consistent throughput or execution duration you only pay for that unit rather than by server unit)
Built-in availability and fault tolerance (no need to architect for availability because it is built into the service)
AT AWS this spans many many different services. Today we’re going to talk about compute.
FINRA is a great example of how serverless can enable rapid innovation.
FINRA protects investors, and ensures market integrity through the regulation of broker-dealers.
FINRA audits 99% of equities trades and 65% of options trades in the US,
and must validate stock data daily as soon as it arrives.
FINRA wanted to move an on-premises Hadoop cluster to AWS, because it was hard to maintain, only ran in batches and couldn’t scale easily. And, it was idle 50% of time. <!>
Using serverless building blocks like AWS Lambda, Amazon S3 and Amazon SQS,
FINRA developed a serverless stock trade validation system in only 3 months.
They increased cost efficiency by a factor of two vs their previous on-premises system.
They also reduced their processing times and can now easily scale to handle up to half a trillion validations every day.
Let’s quickly look at the two serverless computing options from AWS.
First, we have serverless functions in the form of AWS Lambda. Lambda can offer great agility and economic benefits. With Lambda, developers write code in units called functions, and define a trigger to run the code. Lambda starts, stops and scales automatically based on the usage load it receives.
For another class of applications, you may want a little more control over networking, or how services communicate with each other, or what your packaging should look like.
Here your unit of work goes from being a piece of code to a set of container image stored in a registry
But you don’t want to have to think about how you take that bundle and where in some cluster you will launch it or what that will look like. You can just define it, and deploy it. This is what Fargate does.
----
Offload operations:
You never have to worry about provisioning, scaling, patching, or managing the underlying servers.
AWS takes care of managing the compute fleet, including cycling, OS and security patches and updates, scaling horizontally and starting and stopping the underlying instance to fit the exact needs of the workload, and deploying your application.
The only configuration choice that a developer needs to make is the choice of language & runtime.
Availability: Lambda automatically deploys to multiple availability zones, so you don’t need to architect for high availability or fault tolerance.
Security: Lambda also enables you to secure your modern applications with very little administration. AWS secures the infrastructure and takes care of security patching servers multiple times a day. You secure the software stack.
Cost: You pay only for the compute time you consume – there is no charge when the code is not running.
Use cases: Lambda is a great choice for applications that don’t have specific infrastructure requirements. Because of its event-driven nature, AWS Lambda is great for data-driven applications that need to respond in real-time to changes in data, shifts in system state, or actions by users for use cases such as batch processing, stream analytics, and machine learning inference.
Lambda can actually react to events from over 18 AWS services
Fargate
With Fargate, you no longer have to manage or patch the hosts your clusters run on. However, you are responsible for updating and patching the container.
First implementation of serverless containers on the market Runs containers launched by Amazon ECS or Amazon EKS Fargate is a great choice for building long-lived processes such as backends for web and mobile and PaaS platforms. With Fargate, customers get the control of containers and the flexibility to choose when they run without worrying about provisioning or scaling servers. Fargate offers full control of networking, security, and service to service communication and is natively integrated with AWS services for security, networking, access control, developer tooling, monitoring, and logging. For customers that want control of their underlying infrastructure (including the OS, runtime, networking, or how their application scales) and for customers who use container-based build and deploy technologies and pipelines (such as Docker as a build/deploy technology, ECS or Kubernetes as an orchestration/deploy technology, or service-mesh technologies such as Envoy), Fargate is a great choice. Fargate is a technology built on ECS and it is also a container-native compute engine for ECS and EKS, so it requires no change to your existing development practices if you have already been working with containers and are committed to Docker as a build/deploy technology, or if your application needs service-mesh technologies such as Envoy, or if you want to use a container orchestrator and deployment technology such as ECS or Kubernetes. If you have an application where you want the ability to configure and tune the network/OS settings, or even where you need to tune application settings to provide more CPU to apps that need higher throughput, and reduced CPU for lower throughput apps, Fargate can be a great choice. With Fargate, you can choose to configure the networking, how your application scales (such as setting up the scaling characteristics for the containers using Auto Scaling), and your runtime environment (such as choosing combinations of OS distribution and programming language). With Fargate, we extended serverless to containers so developers can recognize the benefits of agility, flexible scaling, and high availability for their container-based applications, all without needing to manage infrastructure Fargate is a great choice for building long-running processes such as microservices backends for web and mobile and PaaS platforms Customers simply define how they want their containers to run and the containers automatically deploy and scale across multiple availability zones When to use each Every application has its own requirements and needs Containers and functions work harmoniously together A Lambda-based or Fargate-based approach can be applied to virtually any use case. Choose the architectural approach that best fits with yourc use case or technical requirements Our customers often choose to use a powerful combination of both. For more detail on how to select the right compute option for your application, see <SESSION>.
These are unique, game changers etc. these are core to that transformation
While EC2 is the largest compute service in terms of sheer volume of utilization, we have developed a breadth of options that are best of breed in all three modalities of instances, containers and serverless. In fact, no other cloud treats all three as equals.
And while it is common for customers to use a combination of all three across their application portfolio, picking the best approach based on their business and technical requirements, I would like to walk you through the core strengths of each category and show you how customers are using them to solve for specific challenges.
Fargate is so important because it addresses long running steady capacity workloads that are stateful.
This is essentially a recap of what we discussed earlier with databases. There is a spectrum of shared responsibility you have over your options for compute. With EC2, you can build and run things, but you manage integrations, scaling, security config, provisioning, patching etc. in addition to your code.
Compare that to Lambda, where all you mange is your application code.
We just talked about how we remove responsibility for managing infrastructure with Lambda. But you still have to write the code. And we want to make it easier to write application code with Lambda. Lambda serves trillions of executions each month, and so we’ve prioritized making it easier to build lambda functions quickly.
Abstracts the implementation so that you can switch from Lambda to EC2 or Combine multiple backends. Similarly you can use mapping templates to unify different versions of your APIs
Network protection is something we do very well and requires hyperscale, you won’t be able to auto-scale to meet an attack, let us do it
Centralize authorization decisions in a policy and remove the concern from the code in your backend, fewer bugs
The first thing we want to look at is the standard flow of an API call, including all components in the system
First, a request comes in from a client, this could be a mobile device, a web application or a backend service
The requests arrives at one of our CloudFront PoP locations, it’s accepted and routed through to the API Gateway in the customer’s region
The API Gateway receives the request, then checks for records in the dedicated cache (if it is configured). If there are no cached records available then it will forward the request to the backend for processing
The backend can be a Lambda function, a web service running on Amazon EC2, or any other publicly accessible web service
Once the backend has processed the request the API call metrics are logged in Amazon CloudWatch and the content is returned to the client
Two new API Gateway features:
Access endpoints in your VPC: On the back end, API Gateway can now take advantage of the newly launched PrivateLink support to set up tunnels for an API to an integration point, like a service running on EC2, that resides in your own VPC.
Regional API Endpoints: On the front end, we want regionalized APIs that we can call from Lambda that don’t route traffic out to CloudFront POPs and back in again.
Web application pattern - this is one of the common usecase where customers are leveraging Serverless services. These are some of the key aspects of typical web application. And we want to build a reference architecture using Serverless services with these key characteristics in mind.
There is static content, images, java scripts, css, etc being renedered in your website, your application users might be seeking dynamic content, and you might have created bunch of microservices! Ofcourse, You want to provide a way for your users to authn and authz. And all of this while being able to scale and globally present!
Combing Lambda and Kinesis is a popular architecture model for streaming applications, there's a couple different components to Kinesis today you can use two streams Kinesis firehose can use analytics and actually lambda can interface with all of those but primarily what we're seeing customers do is ingesting data and then they need to do some sort of near real-time compute against that data and so in this case we have a Kenisha stream coming in that data is then being processed by lambda one of my lambda functions is going to take that data and put it in s3 the other ones gonna maybe process that data and pull out some metadata about something put into dynamo and maybe put some data into cloud watch logs maybe i'm processing an event stream from one of my own products and so there's a lot of different things that you can do in this space and this is again one of the larger use cases for service applications today.
Bustle.com 52 million monthly users, and 100 million events daily.
There's also a batch a serverless batch processing pattern that I want to showcase for your analytical processing needs this is more of a DIY approach where you have a lambda function that takes your source data and splits it up somehow maybe by lines or by by size and hands it off to a bunch of mapper functions that run in parallel to process your data and then write results to a persistent store and then we have a reducer function in this example collecting that data and storing the results in a durable store like S3.
this is a pattern that's also well live well leveraged by customers
Fannie Mae actually leverages a pattern very similar to this to process Monte Carlo simulations and cash flow projections for their mortgages they actually used to do this on more of a server based approach and by adopting this approach they were able to reduce the time it takes to run simulations by a factor of four.