-
Notifications
You must be signed in to change notification settings - Fork 803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
question: AWS Lambda get pretty slow when using decorators #1587
Comments
I don't provide support about how to use AWS. If the issue still persists, you may open a new Q&A in the discussions tab and maybe someone from the community may be able to help. |
@NoNameProvided we're actually running into this as well with Cloudflare Workers, and I think it's a good problem to think about that is more specific to the way the library works inside of "serverless functions" (not specifically AWS). Basically I believe this library is performing a lot of work on startup to build the schemas for validation based on the class decorators. Normally that's fine in a long-running server application, but it seriously harms performance in a serverless function that starts up once in an isolated memory space, initializes all the schema stuff, does a little bit of work and then shuts down. The only way around this that I could see would be to provide a way to take the class definitions and "precompute" the schemas as part of the build process (webpack etc.). If the library had some generalized support for that kind of thing it would be pretty useful I think. |
Hi @ajwootto! Thanks for the reply. Since this is nonactionable feedback ("it slow but no metrics") I cannot act on it. As a result please open a feature idea discussion where you
After this, the community can iterate on the idea, discuss the next steps and when we know what we should do we can open a feature or fix the issue.
I suspect something else is at play here, it should be not noticeable to build the metadata even if you have significant amount of decorated classes.
This is actually planned. |
@NoNameProvided I am willing to have a crack at implementing this next week if you give me some advice on how you think it can be done We are also using aws lambda and performance is paramount for us. I agree #1775 is much more important so please focus on that and release what you have today ASAP so that snyk and re-evaluate and remove the vulnerability warning Please and thanks! |
First, we need to understand what is slow in If I would take a look at it, I would start by running my test cases with the NodeJS debugger attached and analyze the results of a few runs with profiling. The resulting flame graph will tell you when the most time is spent. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm using
class-validator
in my newly created AWS lambda.When using the property decorators provided, like
@IsString()
, the lambda gets painfully slow when invoking locally (~150ms without decorators, ~4000ms with decorators).I'm not even validating the incoming object, just the fact the decorators are present slow down the lambda (as you may see):
lambda handler (
handler.ts
)RequestUser.ts
As you can see, no hard work is done here what could cause an increase of ~4000ms, and no validation of the
event.body
object itself.If I get rid of the decorators, runtime decreases, as mentioned, to about ~150ms.
Anyone has a guess what could cause this?
Thanks!
The text was updated successfully, but these errors were encountered: