current position:Home>AWS serverless design lambda

AWS serverless design lambda

2022-04-29 07:57:15zoobuzas

AWS serverless Design -Lambda

1. There is a limit to the number of simultaneous executions

Lambda The principle is actually the increasing container technology . Every request is to open a container .

Concurrent execution =( Calls per second )x( Average execution time ( second ))
for example , One Lambda The average time of the function is 10 second , Send out every second 100 Two events will be executed at the same time 1000 individual Lambda function , That's the limit .

The wonder is , In fact, the restrictions in each region of the world are not the same , Like the United States, it seems 2000 Limit .

Ordinary areas AWS Lambda In the same area of the same account, it is limited to 1,000. When the limit is reached , Further function calls are restricted ( throttle ). Note that the same account , It's not the same function .

There are several ways to avoid limitations .

One of them is “ Try processing again ”. For synchronization , When restrictions occur ,Lambda Function will return 429 error . If this error occurs , The caller of the function will perform the retry process . In the case of asynchronous processing , It will take the longest 6 Automatically retry every hour .

Besides , stay AWS Lambda Under the circumstances , Apply to relax the ceiling ,
( however , It's hard to accept ).
 Insert picture description here

Monitoring and error analysis are very complex

Multiple functions work together in serverless applications . therefore , It's actually more difficult to monitor than normal applications .

Lambda It can also be used for Java and Python multilingual . however Lambda Most of the runtime provided is hidden inside , When problems occur, it is difficult to analyze and isolate them for inspection .
 Insert picture description here

Of course use AWS CloudWatch You can see enough error messages in the log . General investigation is also enough. In fact , Compared with others, it's already very good . such as splunk,Nmap these

Execution time limit

For those with limited execution time AWS Lambda, The execution time is 15 Within minutes . If there is one execution, it will exceed 15 Minutes , You need to divide and parallelize processes .

And need to consider Lambda Restrictions on server free services other than .
for example ,API Gateway + Lambda. under these circumstances , You should also consider API Gateway restrictions . stay API Gateway Under the circumstances , The norm is that it will be at most 29 Timeout in seconds . therefore , The value will be in 29 Seconds from Lambda The function returns , The process will then execute asynchronously . If the process is difficult to divide and parallelize , You need to use Amazon EC2 Implementation requires 15 A process of minutes or more .

AWS Lambda Not to be used alone

Not to be used alone AWS Lambda perform Lambda function . To carry out Lambda function , You need to set a trigger to trigger the process to start in another service resource .
perform Lambda There are two main types of triggers . The first is the type of function that is called synchronously with the trigger . This applies to API Gateway And manual execution . The second is to detect the occurrence of events and execute functions asynchronously . This includes from Amazon S3、CloudWatch Log、CloudWatch Events Such as running .
oudWatch Log、CloudWatch Events Such as running .

copyright notice
author[zoobuzas],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204290550503662.html

Random recommended