简体   繁体   中英

NancyFX slow performance

I have AngularJs frontend web app which communicate with backend web API written in NancyFx. I have performance problem with Nancy, every time when I call my API service Nancy first scans every method in my module and then enters right method.
For example:
In my Nancy module I have Get,Post,Put and Delete.When I call get method on API, Nancy scans Get,Post,Put,Delete and then enters to Get method. So every time when I call service it need at least 2 seconds to enter the right method.

As far as I understand Nancy by default scans module to recognize right routes, but in my cases this takes too long. My module class is not to large I have about 150 lines of code in module.
Is this default Nancy behavior and can it be overridden in Boostrap, or how to increase performance?

There's not a lot to go on here without seeing your code, but what you have described doesn't make sense.

Nancy does a scan up front on the first request to build a cache of all routes and implementations. Then finds the corresponding matching route and invokes the implementation.

Any request after that only does the latter part.

There could be a number of things that could cause invocation to be slow, such as putting logic inside the constructor that exists outside of the route implementation. Dependencies which are slow to resolve. Database access. etc.

But without seeing any code at all I doubt anyone can pin-point your performance issues.

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