TechWriterDev
  • Cloud
    • AWS
      • 00_Doubts
      • CloudPractitioner
        • Cloud Computing
        • AWS Global Infrastructure
        • Introduction to AWS EC2
        • Elastic load balancer(ELB)
        • 04_Messaging_Queuing
        • Aditional Computing Service
        • Accessing AWS resources
        • AWS Networking
        • Storage
        • Amazon Database Solutions
        • Monitoring Tools
        • AWS Security
        • Distributed Denial Of Service Attacks
      • DeveloperAssociate
        • References
        • AWS DVA-C02 Services Index
        • Services
          • 00_IAM
            • Identity and Access Management (IAM)
            • Account Protection Mechanisms
            • Access Mechanism of AWS Resources
            • Security Tools
            • Responsibility Model
            • Advanced Concepts
          • 01_EC2
            • Elastic Compute Cloud (EC2)
            • EC2 Volume Types
            • Amazon Machine Image (AMI)
            • AWS charges for IPv4 address
          • 02_SecurityGroups
            • Security Groups
          • 03_Elastic_LoadBalancing
            • Terminology
            • Elastic load balancer
            • Features
            • Basics
          • 04_AutoScaling
            • Auto Scaling
          • 05_RDS
            • Relational Database Service (RDS)
            • Aurora
            • Security
            • RDS Proxy
          • 06_ElastiCache
            • Cache
            • Cache Offerings
          • 07_Route53
            • Basics of DNS
            • Route 53
          • 08_VPC
            • Virtual Private Cloud (VPC)
          • 09_S3
            • Simple Storage Service (S3)
            • S3 Features
            • S3 Encryption
            • S3 Features
            • S3 Bucket Policy and IAM Policy
          • 10_ECS
            • Elastic Container Service (ECS)
            • Elastic Container Registry (ECR)
            • AWS Copilot
          • 11_EKS
            • Elastic Kubernetes Service (EKS)
          • 12_SDK_CLI_Tips
            • Access AWS Resources
          • 13_CloudFront
            • Cloud Front
          • 14_Messaging
            • Simple Queue Service (SQS)
            • Simple Notification Service (SNS)
            • Fan Out Pattern
            • Kinesis
            • Compare and Contrast
          • 15_ElasticBeanStalk
            • Elastic Beanstalk
          • 16_CloudFormation
            • CloudFormation
            • Dynamic References
          • 17_Monitoring
            • AWS Monitoring
            • AWS CloudWatch
            • CloudWatch Alarms
            • Synthetics Canary
            • Amazon EventBridge (formerly CloudWatch Events)
            • X-Ray
            • OpenTelemetry
            • CloudTrail
          • 18_Lambda
            • Lambda
            • Lambda Integrations
            • Configuring Lambda
            • Lambda Layers
          • 19_API_Gateway
            • API Gateway
            • API Gateway Integrations
          • 20_DynamoDB
            • DynamoDB
            • Operations
            • Indexes
            • DynamoDB Accelerator (DAX)
            • DynamoDB Streams
            • Transactions
            • Integrations
          • 21_CICD
            • CICD
            • CodeCommit
            • CodePipeline
            • CodeBuild
            • CodeDeploy
            • CodeArtifact
            • CloudGuru
          • 22_SAM
            • Serverless Application Model (SAM)
          • 23_CDK
            • Cloud Development Kit (CDK)
          • 24_StepFunctions
            • Step Functions
            • Types of step function
          • 25_AppSync
            • AppSync
          • 26_Amplify
            • Amplify
          • 27_STS
            • Security Token Service (STS)
          • 28_DirectoryService
            • Active Directory
          • 29_KMS
            • Encryption
            • KMS API
            • Features
            • Cloud Hardware Security Module (HSM)
          • 30_SSM_Store
            • SSM Parameter Store
          • 31_SecretsManager
            • Secrets Manager
          • 32_Cognito
            • Cognito
      • Questions
        • AWS_Region
        • EC2
        • IAM
  • Database
    • MongoDb
      • Mongo db Basics
      • Mongo DB Atlas
      • Document
      • Import-Export based on Data Format
      • Mongo Shell Commands
      • Query Operators
      • Indexes
      • Upsert
      • MongoDB Aggregation Framework
      • Aggregation Framework Operators
    • PostgreSQL
      • POSTGRE SQL DataTypes
      • About table
      • Constraints
  • Technologies
    • RabbitMQ
      • RabbitMQ Concepts
      • Introduction to Exchanges
      • Introduction to Queues
    • Terraform
      • 00_Introduction
      • Configuration blocks
      • Commands
      • Variables
      • Terraform Cloud
      • Modules
  • Languages
    • Java
      • Logging
        • Getting Started
      • 00_Core
        • 00_Basics
          • Java Vs C++
          • Object oriented principles
          • Steps to compile a java program
          • JVM Internals
          • Understanding Java Development Kit
          • What is JIT Compiler?
          • Java data types
          • 07_identifiers_type_conversion
          • 08_references_and_packages
          • Steps for attaching scanner
        • Concurrency
          • 00_Threads
            • Threads
          • 01_ExecutorFramework
            • Executor Framework
            • Asynchronous Computation
      • 01_Backend
        • 01_HttpAndWebServerBasics
          • HTTP
          • Content Type
          • Web Server
        • 02_J2EE_Basics
          • J2EE_Basics
          • Why HttpServlet classs is declared as abstract class BUT with 100 % concrete functionality ?
        • 03_TomCatAndSession
          • What is a Session?
          • WebContainer
        • 04_PageNavigation
          • Cookies Additional Information
          • Page Navigation Techniques
        • 05_AboutServlet
          • CGI v/s Servlet
          • Executor Framework
          • Servlet Life cycle
          • SERVLET CONFIG
          • Servlet Context
          • Servlet Listener (web application listener)
        • 08_SpringBoot
          • Spring Boot
          • Some common annotations used in spring eco system
        • 09_SpringDataJPA
          • Spring Data JPA
        • Java_Language_Changes
          • JDK enhancement tracking reference
        • 06_ORM_Hibernate
          • readmes
            • Hibernate
            • Advantages of Hibernate
            • Hibernate Caching
            • Hibernate API
            • Hibernate Query API
            • Hibernate Annotations and JPQL
            • Entity and Value Type
        • 07_SpringFramework
          • bean_validation
            • Bean Validation
          • core
            • readme
              • Spring
              • Spring Framework Modules
              • Spring MVC Request flow
              • Dependency Injection
              • Spring Beans
              • 06_Spring_Framework_Annotations
      • 03_Tools
        • Maven
          • Maven
  • SoftwareEngineering
    • DesignPatterns
      • Notes
        • Basics
        • OOP
        • SOLID Principles
        • 03_Creational
          • Abstract Factory (aka Kit)
          • Builder
          • Factory Method (aka Virtual constructor)
          • Prototype
          • Singleton
        • 04_Structural
          • Adapter (aka Wrapper)
          • Bridge (aka Handle | Body)
          • Composite
          • Decorator (aka Wrapper)
          • Facade
          • Flyweight
          • Proxy (aka Surrogate)
        • 05_Behavioral
          • Chain of Responsibility
          • Command (aka Action | Transaction)
          • Iterator (aka Cursor)
          • Observer (aka Publish-Subscribe | Dependents)
          • Strategy (aka Policy)
    • Principles
      • REST
        • REST
  • Tools
    • Containers
      • Docker
        • Docker
        • Docker Image
        • Commands
        • Compose
        • Best Practices
      • Kubernetes
        • Kubernetes
    • VCS
      • Git
        • Quick reference of useful Git commands
Powered by GitBook
On this page
  • Environment Variables
  • Logging & Monitoring
  • Lambda Function Configuration
  • Lambda concurrency executions
  • Concurrency Issues
  • Lambda Function dependencies
  • References
  1. Cloud
  2. AWS
  3. DeveloperAssociate
  4. Services
  5. 18_Lambda

Configuring Lambda

Environment Variables

  • Key-Value pairs in string form, available to lamdba code.

  • Lambda also adds its own system environment variables.

  • Can be used to store secret values (encrypted using KMS).

  • Secrets can also be encrypted using Lambda secret service or CMK (Customer Master Key).

Logging & Monitoring

  • If Lambda has execution role with an IAM policy that has write permission to CloudWatch, then all logs will be avaiable to CloudWatch Logs.

  • Metrics are also displayed in AWS CloudWatch Metrics.

  • Metrics such as success-rate, error count, throttles, async delivery failures, invocation count etc.

  • Lambda Tracing can be enabled using X-Ray tracing (Active Tracing).

    • Once X-Ray tracing is enabled, Lambda will have X-Ray daemon running.

    • Once enabled, X-Ray SDK can be used.

    • Following environment variables should be configured in Lambda to communicate with X-Ray.

      Variable Name
      Description

      _X_AMZN_TRACE_ID

      Contains tracing header

      AWS_XRAY_CONTENT_MISSING

      By default, LOG_ERROR

      AWS_XRAY_DAEMON_ADDRESS

      X-Ray Daemon IP_ADDRESS:PORT

Lambda Function Configuration

  • RAM can be increased from 128 MB to 10 GB, in 1 MB increments.

  • The more RAM you add, the more VCPU credits get added.

  • After 1792 MB, you get more than one vCPU, so to benefit from it use multi threading.

  • So, for CPU bound processing in lambda, make sure to increase the RAM, as there is no explicit setting to select number of vCPUS.

  • Lambda by default will timeout by 3 seconds, but this can be increased upto 15 minutes.

Lambda concurrency executions

  • Concurrency limit of upto 1000 concurrent executions.

  • Reserved concurrency can be set to limit the concurrency at function level.

  • It fucntion is invoked above the given concurrency limit, then it will trigger a Throttle.

    • For synchronous invocation, on encountering this limit lambda will throw 429 ThrottleError.

    • For asynchronous invocation, this will retry automatically and event will go to DLQ.

  • Higher than 1000 concurrent executions can be achieved by connecting with AWS support team.

Concurrency Issues

  • Limit issue

    • Concurrency Limit applies to all the functions in an account.

  • Asynchronous Invocations

    • If functions doesnt have enough concurrency available to process all the events, additional requests are throttled.

    • For throttling errors, Lambda returns the event to the queue and attempt to run the function again for upto 6 hours.

    • The retry interval increases the exponentially from 1 second after first attempt to upto maximum of 5 minutes.

  • Cold Start & Provisioned Concurrency

    • On first invocation of a lambda function, code is loaded and all code outside the lambda handler has to be run i.e., all the initialization code.

    • If initialization is large, then the process takes time. As a result, the first request served by new instances has higher latency than the rest.

    • To solve this cold start problem, one can use Provisioned Concurrency.

      • This allocates concurrency even before the function is invoked i.e, maintain a warm pool of execution context.

      • So, cold start never happens and all invocations have lower latency.

      • Application auto scaling can manage the concurrency (schedule or target utilization).

      • Will incur additional charges for this setup.

Lambda Function dependencies

  • External dependencies should be packages along with code and zip it together.

  • Once zip is created, upload it to Lambda, if less than 50 MB, else upload to S3 first and refer it from there.

  • AWS SDK comes by default with every lamdba function.

References

PreviousLambda IntegrationsNextLambda Layers

Last updated 4 months ago

At 1792 MB, a function has equivalent of one full .

vCPU
Provisioned and Reserved Concurrency