[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

Lambda integration with ALB

  • HTTP(s)
  • Lambda function must be registered in a target group

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

 

 

ALB Multi-Header Values

If a client connect to ALB, we can config settings of ALB whether support Multi-Header Values.

For example, client send query parameters `?name=foo&name=bar` which will be converted to `name: [‘foo‘, ‘bar‘]`

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

When enable Multi-value headers: HTTP headers and query string parameters that are sent with multiple values are shown as arrays within the AWS Lambda event are response objects.

 

Ref: https://www.cnblogs.com/Answer1215/p/14844873.html

 

Lambda@Edge

You have deployed a CDN using CloudFront. You want to run a global AWS Lambda alongside with CDN.

Lambda@Edge allows you to

  • Build more responsive applications
  • You don‘t manage servers, Lambda is deplooyed globally
  • Customize the CDN contetn

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

 

 

Lambda - Asynchronous Invocations

How it works?

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

For example, s3 trigger Lambda, it will put events into a Queue, Lambda will read from Queue max 3 times if need retry, then you will see multi logs in CloudWatch. After 3 times retry, will send to DLQ.

Return StatusCode for Asyn is 202.

Enable DLQ for Lambda, you also need to attach IAM policy

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

 

Event Source Mapping

Lambda need to poll from the source. Lambda function is invoked synchronouly.

  • Kinesis Data Streams
  • SQS & SQS FIFO queue
  • DynamoDB Streams

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

  • By Default, if you function return an error, the entire batch is reprocessed until the function succeeds, or the items in the batch expire.

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

 

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

 

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

Destination

On Lambda invoke success or failure, you can send data to another AWS service, such as SQS or Kinesis.

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

For example, you upload an image to S3, and trigger Lambda processing, on sucess send message to a SQS; on failure, send message to another SQS

  • on success: you will see message in SQS right away
  • on failure: becasue S3 inovke Lambda is async, if on failure, Lambda will retry 3 times, so you will not be able to see the SQS message right away, but should be able to see it after 4 mins.

 

[AWS - DA] Lambda (ALB, Mult-values header, Edge, Async invocation, Event Source Mapping, Destination) PART 1

上一篇:【Android】Gradle下载不动,修改为阿里镜像


下一篇:Spring项目的类中获取ApplicationContext实例的方式