Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Application Slowness -- Urgent Help Needed #2188


User avatar
0
maharatha created

Hi -

I have been struggling with performance issue with my code. I am using New Relic to find out what's the issue but it hasn't helped much.

Below is a brief description of my issue :

I have written a method called : GetVendorUnits(SearchInputDto input) which is being exposed as a Web Api. When I monitor in Audit Log or using New Relic I am observing it's executing within 1100 mili seconds, but the response I get back from the server is taking 12 - 15 seconds and sometime more.

[attachment=0:oa152h8v]Relic.png[/attachment:oa152h8v]

Could you please point me to the right direction to troubleshoot the issue on where the time is being spent and what to look for ?

Few questions :

  1. Why is the constructor being called so many times ?
  2. Where are the areas I should look into ?

I am having no clue how to figure this out.

Note :

  1. If you look at the time spent in constructor is minimal but the code that's getting executed withing each constructor access is causing the delay.

  2. I am directly calling the GetVendor web service and no other processing is being done.

I am literally stuck and unable to move forward.

Any help will be highly appreciated.

Thanks, Partha


7 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share your application service code as well ?

    In the mean time, you can comment out your app service method lines and try to find out which part causes this slowness. You can first try to return an empty response and see how long does it take to execute.

  • User Avatar
    0
    maharatha created

    We figured out the culprit to be Dependency Injection.

    We were injecting services at the constructor level which was adding to the slowness.

    Is there any reason why Dependency Injection would add such slowness to the application ?

    We are planning to Inject dependency wherever it's required rather than injecting at the constructor.

    Do you have a better suggestion on how to use the DI ?

  • User Avatar
    0
    JeffMH created

    I have to say I am curious on this one as well.

    My first thought is you have some weird dependency graph. I think Castle will fail if you have a circular dependency but it will also give you some other potential configuration problems:

    <a class="postlink" href="https://github.com/castleproject/Windsor/blob/master/docs/debugger-views.md">https://github.com/castleproject/Windso ... r-views.md</a>

    I loaded up the IocManager in my debugger and there are some potential issues. You could check to see if anything you are dependent on is on of the debug views. If one is in there, you could just comment that one out and see if it gets better.

    I am sure you may have already moved on. It may be worth the AspNetZero guys to look over the lists that are generated by Castle. There are 7 Potentially misconfigured, 38 potential lifestyle mismatches, and 20 potentially duplicate dependencies. Not that any of these may be wrong, they are just potential problems.

    I may spend some time running a couple perf tests if I can, won't be anytime soon, but this has me really curious.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    @maharatha, actually DI shouldn't create such a slowness unless you are doing something in the construcor of your classes. If you decide do resolve dependencies manuallay, you need to relese them manually as well. For this specific case you can do this, but generally it's suggested to use DI via constructor or property injection.

    @JeffMH, we will also try to do same tests for our environment.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    It seems like our implementation here <a class="postlink" href="https://github.com/volosoft/castle-windsor-ms-adapter">https://github.com/volosoft/castle-windsor-ms-adapter</a> has a bug and it causes some problems.

    We will release it in a short time so you can try it in your projects and see if it fixes the problem.

    thanks.

  • User Avatar
    0
    JeffMH created

    Kudos finding an issue here. I am sure that was not a trivial thing to track down.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Actually it was an important problem but it should be fixed right now. It seems to be working as expected in our tests.

    Thanks.