Skip to content

Add lazy compiling of validators #114

@sashee

Description

@sashee

The library does as much as possible during init, which is great when it's deployed on a server that handles a lot of calls, but it's terrible for a serverless environment. I noticed 6-10 seconds of cold start times even for a small number of paths running on AWS Lambda, which is either makes the first request painfully slow or makes me increase the resources available to the function which makes it more expensive.

After a bit of investigation I found that most of the time is spent initializing the validators. I noticed that they are all pre-compiled (for example here). My hunch is that if these schemas are compiled lazily then the response time for the first request could be distributed in subsequent requests, making the library work better with serverless.

I'm wondering if you are open to a PR that add a new parameter (or reuse the "quick" argument) that makes the validator to not precompile the schemas on init.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions