Serverless Architecture and APIs review – Part 2

AWS Serverless Platform Capabilities

AWS provides all the core capabilities identified in the previous section as requirements for a complete serverless platform. The cloud logic layer is provided by AWS Lambda, a high-scale, provision-free serverless compute offering based on functions. AWS Lambda is complemented by AWS Lambda@Edge, which provides similar support for executing extremely low-latency Lambda functions using edge-optimised routing, and AWS Greengrass, which enables Lambda functions to execute on connected devices, including appliances such as AWS Snowball. Lambda functions can be easily triggered by a variety of first-party and third party events, enabling developers to build reactive, event-driven systems without the conventional hassle of setting up and managing infrastructure. When there are multiple, simultaneous events, Lambda simply runs more copies of the function in parallel, responding to each individual trigger. Lambda functions scale precisely with the size of the workload, down to the individual request. As a result, there is no possibility of an idle server or container. The problem of wasted infrastructure expenditures is eliminated by design in architectures that use Lambda functions.

faas diagram
The relationship between event-driven computing, FaaS, and Serverless

FaaS, or Function as a Service, is one approach to building event-driven computing systems that relies on functions as the unit of deployment and execution. Serverless FaaS is a type of FaaS where no virtual machines or containers are present in the programming model and where the vendor provides provision-free scalability and built-in reliability.
 
 
 
 
 
The AWS serverless compute capabilities provided by Lambda are a key element of the following managed services offered by AWS, all of which integrate seamlessly with one another:

  • Amazon API Gateway – HTTP endpoints for Lambda functions, including a full range of API proxy and API management capabilities.
  • Amazon S3 – Lambda functions can be used as automatic event triggers when an object is created, copied, or deleted.
  • Amazon DynamoDB – Lambda functions can be used to process any or all of the changes made to a database table.
  • Amazon SNS – Messages can be routed to Lambda functions for processing, adding the ability to dynamically respond to published content.
  • Amazon SQS – Messages in queues can be easily processed by Lambda functions.
  • Amazon Kinesis Streams – In-order record processing of streaming data is provided by Lambda functions, making it easy to build near real-time analytics engines.
  • Amazon Kinesis Firehose – Lambda functions can be applied automatically to the records ingested by a Firehose, making it easy to add transformation, filtering, and analysis capabilities to a data stream.
  • Amazon Athena –Lambda functions can be automatically triggered for each object in a query’s result set.
  • AWS Step Functions – Multiple Lambda functions can be orchestrated to create long-running workflows for both human-centric and automated processes.
  • Amazon CloudWatch Events – Lambda functions can be used to automatically respond to events, including third-party events.
  • Amazon Aurora – Database triggers can be written as Lambda functions.

Lambda provides an integration library with blueprints for a wide variety of third-party services, including Slack, Algorithmia, Twilio, Loggly, Splunk, SumoLogic, Box, and others, enabling developers to build responsive applications that include analytics, advanced algorithms, communications, and more with just a few lines of code. A wide variety of web application frameworks, including Express (for NodeJS applications) and Flask (for Python applications) have been enhanced to work well with Lambda functions. Open source web application projects include the Serverless Framework, Sparta, Chalice, and many others.
Serverless apps are typically composed of several pieces: one or more functions, a serverless database such as Amazon DynamoDB, and either an API for clients to call or an event source that triggers the app. To keep these pieces organized, AWS uses SAM, the open specification Serverless Application Model. With SAM, developers can easily describe the functions, APIs, event sources, database tables, and other parts of a serverless app. Using SAM also helps developers manage all of the steps in the software development lifecycle, and AWS offers a range of tools and services to help. This includes native support for local testing and debugging in their IDE of choice (or via command line) via SAM Local, deploying SAM apps using AWS CloudFormation, support for building SAM apps in AWS CodeBuild, and support for GitHub-based CI/CD for SAM apps built into AWS CodePipeline. In addition to first-party support, a number of open source frameworks, CI/CD providers, and performance management vendors offer support for SAM and Lambda functions, including Serverless Framework, Claudia, CloudBees, Datadog, and many more. For additional examples, see Serverless Application Developer Tooling.
After a Lambda function (or in the case of a SAM app, potentially several Lambda functions operating together) has been created, developers can easily monitor it using automatically created metrics and logs available in Amazon CloudWatch and CloudWatch Logs. AWS also offers AWS X-Ray, a cross-service request tracing and performance analysis solution that enables developers to trace the operation and behaviour of individual functions and the events that they process.
AWS serverless platform offerings have a global reach, with support for AWS Lambda and Amazon API Gateway in virtually all of the AWS worldwide Regions. Lambda@Edge is available in all edge locations.5 Lambda offers a range of features to help customers improve the reliability of their applications, including automatic retries for asynchronous and ordered events and deadletter queues to capture events that were not processed successfully by the application. The deep integration with Amazon Virtual Private Cloud (Amazon VPC) and the flexible range of authentication and access control capabilities provided by AWS Lambda enable organisations to create secure applications that adhere to best practices, such as the principle of least privilege. End user security and management is equally easy – Amazon Cognito offers authorisation and authentication that can be easily combined with Amazon API Gateway and AWS Lambda, enabling serverless user registration and sign-in capabilities, including integration with social providers like Facebook and corporate directories.

Case Studies

Companies have applied serverless architectures to use cases from stock trade validation to e-commerce website construction to natural language processing. AWS Lambda and the rest of the AWS serverless portfolio offer the flexibility to create a wide array of applications, including those requiring assurance programs such as PCI or HIPAA compliance. The following sections illustrate some of the most common use cases, but are not a comprehensive list.

Serverless Websites, Web Apps, and Mobile Backends

Serverless approaches are ideal for applications where load can vary dynamically. Using a serverless approach means no compute costs are incurred when there is no end user traffic, while still offering instant scale to meet high demand, such as a flash sale on an e-commerce site or a social media mention that drives a sudden wave of traffic. Compared to traditional infrastructure approaches, it is also often significantly less expensive to develop, deliver, and operate a web or mobile backend when it has been architected in a serverless fashion.
AWS provides the services developers need to rapidly construct these applications:

  • Amazon S3 offers a simple hosting solution for static content.
  • AWS Lambda, in conjunction with Amazon API Gateway, provides support for dynamic API requests using functions.
  • Amazon DynamoDB offers a simple storage solution for session and peruser state.
  • Amazon Cognito provides an easy way to handle end-user registration, authentication, and access control to resources.
  • AWS SAM can be used by developers to describe the various elements of an application.
  • AWS CodeStar can set up a CI/CD toolchain with just a few clicks.

IoT Backends

The benefits that a serverless architecture brings to web and mobile apps also makes it easy to construct IoT backends and device-based analytic processing systems that seamlessly scale with the number of devices. For an example reference architecture, see Serverless Reference Architecture for creating an IoT Backend on GitHub.

Data Processing

The largest serverless applications process massive volumes of data, much of it in real time. Typical serverless data processing architectures use a combination of Amazon Kinesis and AWS Lambda to process streaming data, or they combine Amazon S3 and AWS Lambda to trigger computation in response to object creation or update events. When workloads require more complex orchestration than a simple trigger, developers can use AWS Step Functions to create stateful or long-running workflows that invoke one or more Lambda functions as they progress.
Some additional use cases are: Big Data, IT Automation and many more.

Conclusion

Serverless approaches are designed to tackle two classic IT management problems: idle servers that drain a company’s balance sheet without offering value, and the cost of building and operating fleets of servers, and server software, that distract and detract from the business of creating differentiated customer value. AWS Lambda and the other AWS serverless offerings solve these longstanding problems by eliminating the servers, containers, disks, and other infrastructure-level resources from the programming and billing model. As a result, developers can work with a clean application model that helps them deliver faster and organisations only pay for useful work. The easiest and fastest way to architect reactive, event-based systems and to deliver cloud-native microservices is through the use of serverless architectures.
After extensive research, Assignar team have decided to adopt the Serverless framework, which allows us to rapidly build applications. The speed of development is absolutely essential for us at this stage of our journey in order to stay relevant and innovative in a highly competitive market.

« Back