Skip to content
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

Performance Issue at loading time #58

Open
manwithsteelnerves opened this issue Jul 20, 2020 · 2 comments
Open

Performance Issue at loading time #58

manwithsteelnerves opened this issue Jul 20, 2020 · 2 comments

Comments

@manwithsteelnerves
Copy link

There is a significant delay(3-4secs) when loading the schema.
Is there any chance to cache the ajv instance so that addKeywords will be called once? AddKeywords seems to happen for every rest end point.

Please suggest.

Screenshot 2020-07-21 at 12 28 38 AM

@wparad
Copy link
Contributor

wparad commented Jul 20, 2020

Would you be able to also paste your code example of how you are using https://github.com/PayU/api-schema-builder could go a long way.

@manwithsteelnerves
Copy link
Author

manwithsteelnerves commented Jul 20, 2020

We are using as a dependency with in openapi-validator-middleware.
To give a quick overview, openapi-validator takes the schema path and internally uses this module for processing the schema.

I tried caching ajv instances for a quick test as and the performance got increased by 2x!!!
But i'm not sure if its fine to cache the below instances. Please correct me.

if(!ajv) {
        ajvOptions = Object.assign({}, defaultAjvOptions, options.ajvConfigParams);
        ajv = new Ajv(ajvOptions);
    
        ajvUtils.addCustomKeyword(ajv, options.formats, options.keywords);    
    }

Screenshot 2020-07-21 at 1 03 55 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants