Resolve application service spent 1 second











up vote
0
down vote

favorite












We use abp in a really product for user. And there is api, it's so easy, but the response time for it is about 1 second. We think it shouldn't be, then we investigate it, found the execution time for the application service method is about 100 ms, and resolve the application service spent about 1 second.



We use IocManager.RegisterAssemblyByConvention(thisAssembly) for register.



Following screenshot is from the log file for investigation:
enter image description here



My questions are:




  1. why the resolver spent so much time?

  2. What's the correct way to fix this issue.










share|improve this question






















  • Inject only the services you need.
    – aaron
    Nov 20 at 12:53










  • @aaron, yes,before asked, I have already removed all unnecessary services, but it's a core application service, it uses much services for business.
    – Lakin Lu
    Nov 21 at 2:42










  • A core service should not use many business services. If you inject many services, then obviously it takes a longer time to resolve all of them.
    – aaron
    Nov 21 at 5:02










  • 1) Your application service can use many domain service's and also each domain service can use another services and everyone must be resolved, that's why it takes so much time. 2) Try to implement lazy loading and resolve only needed services not all of them. This may help you. You can resolve your services only before usage, so resolving you appservice will speed up.
    – Fidan
    Nov 29 at 11:25












  • Yes, thanks! We have changed the resolve to per request. its so fast now. before it spent about 1 second, now it is 100 ms. And as your suggestion, we are going to improve it further more to use lazy loading.
    – Lakin Lu
    Dec 6 at 9:58















up vote
0
down vote

favorite












We use abp in a really product for user. And there is api, it's so easy, but the response time for it is about 1 second. We think it shouldn't be, then we investigate it, found the execution time for the application service method is about 100 ms, and resolve the application service spent about 1 second.



We use IocManager.RegisterAssemblyByConvention(thisAssembly) for register.



Following screenshot is from the log file for investigation:
enter image description here



My questions are:




  1. why the resolver spent so much time?

  2. What's the correct way to fix this issue.










share|improve this question






















  • Inject only the services you need.
    – aaron
    Nov 20 at 12:53










  • @aaron, yes,before asked, I have already removed all unnecessary services, but it's a core application service, it uses much services for business.
    – Lakin Lu
    Nov 21 at 2:42










  • A core service should not use many business services. If you inject many services, then obviously it takes a longer time to resolve all of them.
    – aaron
    Nov 21 at 5:02










  • 1) Your application service can use many domain service's and also each domain service can use another services and everyone must be resolved, that's why it takes so much time. 2) Try to implement lazy loading and resolve only needed services not all of them. This may help you. You can resolve your services only before usage, so resolving you appservice will speed up.
    – Fidan
    Nov 29 at 11:25












  • Yes, thanks! We have changed the resolve to per request. its so fast now. before it spent about 1 second, now it is 100 ms. And as your suggestion, we are going to improve it further more to use lazy loading.
    – Lakin Lu
    Dec 6 at 9:58













up vote
0
down vote

favorite









up vote
0
down vote

favorite











We use abp in a really product for user. And there is api, it's so easy, but the response time for it is about 1 second. We think it shouldn't be, then we investigate it, found the execution time for the application service method is about 100 ms, and resolve the application service spent about 1 second.



We use IocManager.RegisterAssemblyByConvention(thisAssembly) for register.



Following screenshot is from the log file for investigation:
enter image description here



My questions are:




  1. why the resolver spent so much time?

  2. What's the correct way to fix this issue.










share|improve this question













We use abp in a really product for user. And there is api, it's so easy, but the response time for it is about 1 second. We think it shouldn't be, then we investigate it, found the execution time for the application service method is about 100 ms, and resolve the application service spent about 1 second.



We use IocManager.RegisterAssemblyByConvention(thisAssembly) for register.



Following screenshot is from the log file for investigation:
enter image description here



My questions are:




  1. why the resolver spent so much time?

  2. What's the correct way to fix this issue.







aspnetboilerplate






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 at 10:34









Lakin Lu

2751310




2751310












  • Inject only the services you need.
    – aaron
    Nov 20 at 12:53










  • @aaron, yes,before asked, I have already removed all unnecessary services, but it's a core application service, it uses much services for business.
    – Lakin Lu
    Nov 21 at 2:42










  • A core service should not use many business services. If you inject many services, then obviously it takes a longer time to resolve all of them.
    – aaron
    Nov 21 at 5:02










  • 1) Your application service can use many domain service's and also each domain service can use another services and everyone must be resolved, that's why it takes so much time. 2) Try to implement lazy loading and resolve only needed services not all of them. This may help you. You can resolve your services only before usage, so resolving you appservice will speed up.
    – Fidan
    Nov 29 at 11:25












  • Yes, thanks! We have changed the resolve to per request. its so fast now. before it spent about 1 second, now it is 100 ms. And as your suggestion, we are going to improve it further more to use lazy loading.
    – Lakin Lu
    Dec 6 at 9:58


















  • Inject only the services you need.
    – aaron
    Nov 20 at 12:53










  • @aaron, yes,before asked, I have already removed all unnecessary services, but it's a core application service, it uses much services for business.
    – Lakin Lu
    Nov 21 at 2:42










  • A core service should not use many business services. If you inject many services, then obviously it takes a longer time to resolve all of them.
    – aaron
    Nov 21 at 5:02










  • 1) Your application service can use many domain service's and also each domain service can use another services and everyone must be resolved, that's why it takes so much time. 2) Try to implement lazy loading and resolve only needed services not all of them. This may help you. You can resolve your services only before usage, so resolving you appservice will speed up.
    – Fidan
    Nov 29 at 11:25












  • Yes, thanks! We have changed the resolve to per request. its so fast now. before it spent about 1 second, now it is 100 ms. And as your suggestion, we are going to improve it further more to use lazy loading.
    – Lakin Lu
    Dec 6 at 9:58
















Inject only the services you need.
– aaron
Nov 20 at 12:53




Inject only the services you need.
– aaron
Nov 20 at 12:53












@aaron, yes,before asked, I have already removed all unnecessary services, but it's a core application service, it uses much services for business.
– Lakin Lu
Nov 21 at 2:42




@aaron, yes,before asked, I have already removed all unnecessary services, but it's a core application service, it uses much services for business.
– Lakin Lu
Nov 21 at 2:42












A core service should not use many business services. If you inject many services, then obviously it takes a longer time to resolve all of them.
– aaron
Nov 21 at 5:02




A core service should not use many business services. If you inject many services, then obviously it takes a longer time to resolve all of them.
– aaron
Nov 21 at 5:02












1) Your application service can use many domain service's and also each domain service can use another services and everyone must be resolved, that's why it takes so much time. 2) Try to implement lazy loading and resolve only needed services not all of them. This may help you. You can resolve your services only before usage, so resolving you appservice will speed up.
– Fidan
Nov 29 at 11:25






1) Your application service can use many domain service's and also each domain service can use another services and everyone must be resolved, that's why it takes so much time. 2) Try to implement lazy loading and resolve only needed services not all of them. This may help you. You can resolve your services only before usage, so resolving you appservice will speed up.
– Fidan
Nov 29 at 11:25














Yes, thanks! We have changed the resolve to per request. its so fast now. before it spent about 1 second, now it is 100 ms. And as your suggestion, we are going to improve it further more to use lazy loading.
– Lakin Lu
Dec 6 at 9:58




Yes, thanks! We have changed the resolve to per request. its so fast now. before it spent about 1 second, now it is 100 ms. And as your suggestion, we are going to improve it further more to use lazy loading.
– Lakin Lu
Dec 6 at 9:58












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Before, we use default DependencyLifeStyle as Transient, and we make some changes to set DependencyLifeStyle to per request. And the resolve is so fast now.



The code changes as below:



public override void PreInitialize()
{
IocManager.IocContainer.Kernel.ComponentRegistered += Kernel_ComponentRegistered;
}
private void Kernel_ComponentRegistered(string key, IHandler handler)
{
foreach (var interceptor in interceptors)
{
if (interceptor.Key.IsAssignableFrom(handler.ComponentModel.Implementation))
{
handler.ComponentModel.Interceptors.Add(new InterceptorReference(interceptor.Value));
}
}
if (handler.ComponentModel.Implementation.Assembly.FullName.Contains(".Domain"))
{
if (handler.ComponentModel.LifestyleType == LifestyleType.Transient)
{
IocManager.IocContainer.Register(
Component
.For(handler.ComponentModel.Implementation)
.ImplementedBy(handler.ComponentModel.Implementation)
.LifestyleCustom<MsScopedLifestyleManager>()
.IsDefault()
.Named($"{key}-1")
);
}
}
}





share|improve this answer





















  • Mark your answer as accepted.
    – aaron
    Dec 6 at 13:30











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391088%2fresolve-application-service-spent-1-second%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













Before, we use default DependencyLifeStyle as Transient, and we make some changes to set DependencyLifeStyle to per request. And the resolve is so fast now.



The code changes as below:



public override void PreInitialize()
{
IocManager.IocContainer.Kernel.ComponentRegistered += Kernel_ComponentRegistered;
}
private void Kernel_ComponentRegistered(string key, IHandler handler)
{
foreach (var interceptor in interceptors)
{
if (interceptor.Key.IsAssignableFrom(handler.ComponentModel.Implementation))
{
handler.ComponentModel.Interceptors.Add(new InterceptorReference(interceptor.Value));
}
}
if (handler.ComponentModel.Implementation.Assembly.FullName.Contains(".Domain"))
{
if (handler.ComponentModel.LifestyleType == LifestyleType.Transient)
{
IocManager.IocContainer.Register(
Component
.For(handler.ComponentModel.Implementation)
.ImplementedBy(handler.ComponentModel.Implementation)
.LifestyleCustom<MsScopedLifestyleManager>()
.IsDefault()
.Named($"{key}-1")
);
}
}
}





share|improve this answer





















  • Mark your answer as accepted.
    – aaron
    Dec 6 at 13:30















up vote
0
down vote













Before, we use default DependencyLifeStyle as Transient, and we make some changes to set DependencyLifeStyle to per request. And the resolve is so fast now.



The code changes as below:



public override void PreInitialize()
{
IocManager.IocContainer.Kernel.ComponentRegistered += Kernel_ComponentRegistered;
}
private void Kernel_ComponentRegistered(string key, IHandler handler)
{
foreach (var interceptor in interceptors)
{
if (interceptor.Key.IsAssignableFrom(handler.ComponentModel.Implementation))
{
handler.ComponentModel.Interceptors.Add(new InterceptorReference(interceptor.Value));
}
}
if (handler.ComponentModel.Implementation.Assembly.FullName.Contains(".Domain"))
{
if (handler.ComponentModel.LifestyleType == LifestyleType.Transient)
{
IocManager.IocContainer.Register(
Component
.For(handler.ComponentModel.Implementation)
.ImplementedBy(handler.ComponentModel.Implementation)
.LifestyleCustom<MsScopedLifestyleManager>()
.IsDefault()
.Named($"{key}-1")
);
}
}
}





share|improve this answer





















  • Mark your answer as accepted.
    – aaron
    Dec 6 at 13:30













up vote
0
down vote










up vote
0
down vote









Before, we use default DependencyLifeStyle as Transient, and we make some changes to set DependencyLifeStyle to per request. And the resolve is so fast now.



The code changes as below:



public override void PreInitialize()
{
IocManager.IocContainer.Kernel.ComponentRegistered += Kernel_ComponentRegistered;
}
private void Kernel_ComponentRegistered(string key, IHandler handler)
{
foreach (var interceptor in interceptors)
{
if (interceptor.Key.IsAssignableFrom(handler.ComponentModel.Implementation))
{
handler.ComponentModel.Interceptors.Add(new InterceptorReference(interceptor.Value));
}
}
if (handler.ComponentModel.Implementation.Assembly.FullName.Contains(".Domain"))
{
if (handler.ComponentModel.LifestyleType == LifestyleType.Transient)
{
IocManager.IocContainer.Register(
Component
.For(handler.ComponentModel.Implementation)
.ImplementedBy(handler.ComponentModel.Implementation)
.LifestyleCustom<MsScopedLifestyleManager>()
.IsDefault()
.Named($"{key}-1")
);
}
}
}





share|improve this answer












Before, we use default DependencyLifeStyle as Transient, and we make some changes to set DependencyLifeStyle to per request. And the resolve is so fast now.



The code changes as below:



public override void PreInitialize()
{
IocManager.IocContainer.Kernel.ComponentRegistered += Kernel_ComponentRegistered;
}
private void Kernel_ComponentRegistered(string key, IHandler handler)
{
foreach (var interceptor in interceptors)
{
if (interceptor.Key.IsAssignableFrom(handler.ComponentModel.Implementation))
{
handler.ComponentModel.Interceptors.Add(new InterceptorReference(interceptor.Value));
}
}
if (handler.ComponentModel.Implementation.Assembly.FullName.Contains(".Domain"))
{
if (handler.ComponentModel.LifestyleType == LifestyleType.Transient)
{
IocManager.IocContainer.Register(
Component
.For(handler.ComponentModel.Implementation)
.ImplementedBy(handler.ComponentModel.Implementation)
.LifestyleCustom<MsScopedLifestyleManager>()
.IsDefault()
.Named($"{key}-1")
);
}
}
}






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 6 at 10:52









Lakin Lu

2751310




2751310












  • Mark your answer as accepted.
    – aaron
    Dec 6 at 13:30


















  • Mark your answer as accepted.
    – aaron
    Dec 6 at 13:30
















Mark your answer as accepted.
– aaron
Dec 6 at 13:30




Mark your answer as accepted.
– aaron
Dec 6 at 13:30


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391088%2fresolve-application-service-spent-1-second%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Tonle Sap (See)

I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

Guatemaltekische Davis-Cup-Mannschaft