BeSA program - Week 09 - Serverless

BeSA program - Week 09 - Serverless

The serverless session was nothing short of amazing. Week 09/ 12, Almost wrapping up with the theory section in my preparation for the AWS Certified Solution Architect Associate Exam.

How do we know that an architecture is serverless?

According to AWS, a service is defined by four key criteria: no management, automatic scaling, pay for value, and availability and fault tolerance. These principles enable businesses to focus on their core competencies while AWS handles the underlying infrastructure. The benefits of using AWS services include greater agility, increased scale, and faster time-to-market.

Lambda allows developers to run code without provisioning or managing servers, and it automatically scales to handle incoming requests. Lambda provides features like load balancing, auto scaling, and failure handling, making it a full-featured managed service application component. Lambda functions can be triggered by over 40 different services, including AWS API Gateway, S3, and queues. It supports multiple Languages and runtime API( which allow users to bring almost any language that can run on Linux to Lambda and share code artifacts like application dependencies and libraries across an organization).

AWS Lambda has different invocation models for Lambda functions, including synchronous or push-based models and event-driven models. This link here explains in detail the difference between Synchronous Invocation and Asynchronous Invocation.

  • Synchronous Invocation:

    • The caller waits for the function to process and return a response.

    • Commonly used in request-response scenarios, such as web APIs where immediate feedback is required.

    • If the function fails, the caller receives the error response.

    • Examples: API Gateway integration, AWS SDK calls

  • Asynchronous Invocation:

    • The caller does not wait for the function to complete.

    • AWS Lambda queues the event and processes it, returning a success response immediately.

    • Useful for tasks that can be processed in the background.

    • In the event of Failure of function Dead

    • Examples: S3 events, SNS notifications, CloudWatch Logs

    • Handling failed asynchronous invocations strategies;

      • Retries:

        • AWS Lambda automatically retries failed asynchronous invocations twice, for a total of three attempts. Each attempt will have a longer wait interval than the previous one, giving the function a bit more time to process the request successfully. If all of the retry attempts are unsuccessful, AWS Lambda will give up and discard the request.
      • Dead Letter Queues (DLQs):

        • However to prevent the loss of the failed request. Configure a DLQ to capture failed events that cannot be processed after all retry attempts. These events can be sent to Amazon SQS or Amazon SNS for further inspection and debugging.
      • Error Handling Configuration:

        • Customize error handling behavior by configuring the maximum retry attempts and the event age limit. This helps in controlling how long an event should be retried before being discarded .
      • Destination Configuration:

        • Define separate destinations for successful and failed invocations. This allows for the redirection of failed events to specified resources such as another Lambda function, an SQS queue, or an SNS topic.
      • Monitoring and Troubleshooting:

        • Utilize AWS X-Ray for tracing and troubleshooting Lambda invocations. This can provide detailed insights into the invocation path and help diagnose issues .
      • Manual Retries:

        • For critical errors, manually re-invoke the function with the failed event data. This can be done after debugging the cause of failure.

By combining these strategies, you can effectively manage and mitigate issues with asynchronous Lambda invocations, ensuring robust error handling and reliability in your serverless applications

  • Event Source Mapping (Polling-Based Invocation):

    • AWS Lambda polls the event source for records and invokes the function synchronously to process them.

    • Commonly used with stream-based and queue-based services.

    • Ensures that records are processed at least once.

    • Examples: DynamoDB Streams, Kinesis Data Streams, SQS

Security is a critical focus for AWS, and Lambda functions have unique security features. By default, a Lambda function can't communicate with other services, and no one can invoke the function unless it's enabled. Lambda functions can be used for various purposes, including powering web applications through APIs and compute.

Various use cases and applications of AWS Lambda.

Lambda is used in various scenarios, including internal micro-services, mobile applications, IoT devices, data processing, chatbots, and automation. Data processing is a significant use case, with organizations processing vast amounts of data, such as stock trades and sensor data, using Lambda. Chatbots, both internal and external, are another popular application, with Amazon using Lambda for an internal tool and Alexa skills. Lambda is also used for IT automation, with customers first dipping their toes in serverless computing for tasks like API analysis and reacting to cloud watch alarms

Is AWS Lambda Suitable for Compliance-Driven Workloads, Such as Healthcare and Financial Applications?

AWS Lambda is suitable for compliance-driven workloads, including healthcare and financial applications, due to several key features:

  1. HIPAA Compliance:

    • AWS Lambda is HIPAA-eligible, meaning it meets the security and privacy requirements outlined by HIPAA for handling protected health information (PHI). This enables healthcare organizations to build and deploy applications that comply with HIPAA regulations.
  2. GxP Compliance:

    • For life sciences and healthcare sectors, AWS provides GxP (Good Practice) compliance solutions that help establish environments adhering to regulatory standards, ensuring data integrity and security.
  3. Automated Compliance Management:

    • AWS offers tools and frameworks that automatically build and maintain compliance postures. This includes keeping track of resources and their compliance status, which is critical for healthcare and financial applications.
  4. Security and Data Protection:

    • AWS implements extensive security controls and supports various compliance certifications and attestations, making it suitable for handling sensitive financial data and ensuring compliance with regulations such as PCI-DSS for payment processing.
  5. Comprehensive Compliance Support:

    • AWS provides detailed compliance documentation and support, ensuring that workloads deployed on AWS Lambda can meet stringent regulatory requirements across different industries.

What is the pricing Model for AWS Lambda?

You are charged based on the number of requests for your functions and the duration it takes for your code to execute.

Lambda counts a request each time it starts executing in response to an event notification trigger, such as from Amazon Simple Notification Service (SNS) or Amazon EventBridge, or an invoke call, such as from Amazon API Gateway, or via the AWS SDK, including test invokes from the AWS Console.

Duration is calculated from the time your code begins executing until it returns or otherwise terminates, rounded up to the nearest 1 ms*. The price depends on the amount of memory you allocate to your function. In the AWS Lambda resource model, you choose the amount of memory you want for your function, and are allocated proportional CPU power and other resources. An increase in memory size triggers an equivalent increase in CPU available to your function.

Step Functions

AWS Step Functions is a fully managed service that makes it easier to coordinate the components of distributed applications and microservices using visual workflows. Building applications from individual components that each perform a discrete function helps you scale more easily and change applications more quickly.

Step Function vs AWS Lambda

Step Functions is a serverless orchestration service that lets you easily coordinate multiple Lambda functions into flexible workflows that are easy to debug and change. Step Functions will keep your Lambda functions free of additional logic by triggering and tracking each step of your application for you while AWS Lambda is a serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers.

Is Step Function a paid service?

AWS Step Functions, you pay only for what you use. Step Functions has two types of workflows: Standard Workflows and Express Workflows.

With Step Function Standard Workflows, you are charged based on the number of state transitions required to execute your application. Step Functions counts a state transition each time a step of your workflow is executed. You are charged for the total number of state transitions across all your state machines, including retries.

With Step Functions Express Workflows, you pay only for what you use. You are charged based on the number of requests for your workflow and its duration. Step Functions Express Workflows counts a request each time it starts executing a workflow, and you are charged for the total number of requests across all your workflows. This includes tests from the console.

Find more resources here.

Kudos to the Besa team for curating yet another insightful and impactful session!💪 #Besa #Serverless #Lambda #Step-Functions #AWS #Technology #Innovation #ContinuousLearning