简体   繁体   English

如何使用NodeJS改善AWS Lambda函数的性能?

[英]How can I improve the performance of an AWS Lambda Function with NodeJS?

I am currently have a working NodeJS application that generates templated PDFs hosted on AWS Lambda. 我目前有一个工作正常的NodeJS应用程序,该应用程序生成托管在AWS Lambda上的模板化PDF。 It takes in handlebars template(s), generates a pdf with the templates and the data, writes the PDF to an S3 bucket an returns the file name. 它接收车把模板,并使用模板和数据生成pdf,将PDF写入S3存储桶并返回文件名。 If the file has already exists on S3, it returns the file name of the existing file. 如果文件在S3上已经存在,则返回现有文件的文件名。

When the file exists, it takes around 3 seconds to complete. 该文件存在时,大约需要3秒钟才能完成。 If it needs to generate the file, it takes between 15-25 seconds to complete. 如果需要生成文件,则需要15到25秒才能完成。

I have it configured to have a maximum 128MB of memory and timeout at 25 seconds, but I would really prefer to drop that to 15 seconds if possible. 我将其配置为在25秒时具有最大128MB的内存和超时,但是我真的更愿意将其降至15秒(如果可能)。 Due to the complexity and length of some of the PDFs that will be generated, I currently have to leave the timeout that long. 由于将要生成的某些PDF的复杂性和长度,我目前不得不将超时时间留得那么长。

Excluding the NodeJS libs that I am using, is there a way that I can speed up Lambda execution and/or Lambda's latency when reading/writing to S3? 除了我正在使用的NodeJS库之外,是否有一种方法可以在读取/写入S3时加快Lambda执行和/或Lambda的延迟?

One of the easiest ways to get increased performance from your Lambda function is to increase the memory allocated to it. 从Lambda函数获得更高性能的最简单方法之一就是增加分配给它的内存。 Increasing the memory also increases the amount of CPU allocated to your function and you should see the performance increase correspondingly. 增加内存也会增加分配给您的功能的CPU数量,您应该会看到性能相应的提高。

Aside from that, it's down to normal performance tuning techniques you would use with any application. 除此之外,它取决于您在任何应用程序中使用的常规性能调整技术。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何提高Node.js Lambda性能 - How to improve nodejs lambda performance 如何通过 AWS lambda nodejs function 索引存储在 S3 中的 XML 文件? - How can I index a XML file stored in S3 through AWS lambda nodejs function? aws-lambda-nodejs:如何使用回调函数返回我在aws-console中打印的值? - aws-lambda-nodejs: How can I use callback function to return a value which I printed in aws-console? 如何使用依赖项创建AWS nodejs lambda函数 - How to create AWS nodejs lambda function with dependency 如何处理 nodejs 中的 AWS lambda 函数错误 - How to handle the AWS lambda function error in nodejs 如何使用 AWS Lambda (nodeJS) 查询 AWS 外部的 MySQL 数据库? - How can I query a MySQL database that is outside AWS, using AWS Lambda (nodeJS)? 在nodejs中,我可以有每个子文件夹都托管一个AWS Lambda函数的子文件夹吗? - In nodejs, can I have sub-folders that each sub-folder host a AWS lambda function? 如何提高MongoDB批量性能? - How can I improve MongoDB bulk performance? 如何为AWS Lambda函数建立公共API路由? - How Can I Make A Public API Route For An AWS Lambda Function? lambda 函数中的 AWS NodeJS lambda 调用 - AWS NodeJS lambda call within a lambda function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM