简体   繁体   中英

Synchronous Node.js APIs and AWS Lambda

As I understand it, AWS Lambda executes an instance of a function whenever some event (eg an incoming HTTP request) occurs - and that function is running in a process/execution environment that is just handling that one event in isolation.

If this is the case, I'm wondering what benefit, if any, Node.js asynchronous APIs provide in such an environment? I understand why they're essential in a normal Node.js setting where the one process can be handling simultaneously the activity of large numbers of concurrent user requests, but am I right that this isn't the case in an executing AWS Lambda function?

If so, wouldn't it be reasonable to have synchronous alternatives to the standard Node.js APIs that are used for, eg accessing other AWS resources such as S3 storage etc?

I don't think so. In fact if you could use a synchronous request for whatever involving network (http requests and so on), you would block your application until you receive response since javascript is single threaded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM