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:

My questions are:
- why the resolver spent so much time?
- What's the correct way to fix this issue.
aspnetboilerplate
add a comment |
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:

My questions are:
- why the resolver spent so much time?
- What's the correct way to fix this issue.
aspnetboilerplate
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
add a comment |
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:

My questions are:
- why the resolver spent so much time?
- What's the correct way to fix this issue.
aspnetboilerplate
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:

My questions are:
- why the resolver spent so much time?
- What's the correct way to fix this issue.
aspnetboilerplate
aspnetboilerplate
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
add a comment |
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
add a comment |
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")
);
}
}
}
Mark your answer as accepted.
– aaron
Dec 6 at 13:30
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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")
);
}
}
}
Mark your answer as accepted.
– aaron
Dec 6 at 13:30
add a comment |
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")
);
}
}
}
Mark your answer as accepted.
– aaron
Dec 6 at 13:30
add a comment |
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")
);
}
}
}
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")
);
}
}
}
answered Dec 6 at 10:52
Lakin Lu
2751310
2751310
Mark your answer as accepted.
– aaron
Dec 6 at 13:30
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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