Some performance optimization for app and ioc
See original GitHub issueHi ,hikalkan
When use Abp,Zero,Abp.zero in project ,when i release to server i found every ajax called app service ,response time is more than 120ms, most of them is more than 150ms.
So i write a blank method only return true ,no db search,no other operating,and also respone 120ms.
In source i found ,ApplicationServiceBase is inject TenantManager and UserManager.
In TenantManager
public TenantManager(
IRepository<Tenant> tenantRepository,
IRepository<TenantFeatureSetting> tenantFeatureRepository,
EditionManager editionManager,
IUnitOfWorkManager unitOfWorkManager,
RoleManager roleManager,
IUserEmailer userEmailer,
TenantDemoDataBuilder demoDataBuilder,
UserManager userManager,
INotificationSubscriptionManager notificationSubscriptionManager,
IAppNotifier appNotifier,
IYueZeroFeatureValueStore featureValueStore
IYueZeroDbMigrator yueZeroDbMigrator
)
: base(
tenantRepository,
tenantFeatureRepository,
editionManager,
featureValueStore)
{
_unitOfWorkManager = unitOfWorkManager;
_roleManager = roleManager;
_userEmailer = userEmailer;
_demoDataBuilder = demoDataBuilder;
_userManager = userManager;
_notificationSubscriptionManager = notificationSubscriptionManager;
_appNotifier = appNotifier;
_yueZeroDbMigrator = yueZeroDbMigrator;
}
Resolve TenantManager will use about 70ms,and the ref classes is only use in CreateWithAdminUserAsync Method,this method is only use in tenant reg but resolve this ref class will cause all appService resolve init use 50ms-70ms
//_roleManager = roleManager;
//_userEmailer = userEmailer;
//_demoDataBuilder = demoDataBuilder;
//_userManager = userManager;
//_notificationSubscriptionManager = notificationSubscriptionManager;
//_appNotifier = appNotifier;
//_yueZeroDbMigrator = yueZeroDbMigrator;
So i suggested TenantManager change to
public TenantManager(
IRepository<Tenant> tenantRepository,
IRepository<TenantFeatureSetting> tenantFeatureRepository,
EditionManager editionManager,
IUnitOfWorkManager unitOfWorkManager,
//RoleManager roleManager,
//IUserEmailer userEmailer,
//TenantDemoDataBuilder demoDataBuilder,
//UserManager userManager,
//INotificationSubscriptionManager notificationSubscriptionManager,
//IAppNotifier appNotifier,
IYueZeroFeatureValueStore featureValueStore
//IYueZeroDbMigrator yueZeroDbMigrator
)
: base(
tenantRepository,
tenantFeatureRepository,
editionManager,
featureValueStore)
{
_unitOfWorkManager = unitOfWorkManager;
//_roleManager = roleManager;
//_userEmailer = userEmailer;
//_demoDataBuilder = demoDataBuilder;
//_userManager = userManager;
//_notificationSubscriptionManager = notificationSubscriptionManager;
//_appNotifier = appNotifier;
//_yueZeroDbMigrator = yueZeroDbMigrator;
}
public async Task<Guid> CreateWithAdminUserAsync(string tenancyName, string name, string adminPassword, string adminEmailAddress, string connectionString, bool isActive, Guid? editionId, bool shouldChangePasswordOnNextLogin, bool sendActivationEmail)
{
Guid newTenantId;
Guid newAdminId;
if (_demoDataBuilder == null) _demoDataBuilder = Yue.Dependency.IocManager.Instance.Resolve<TenantDemoDataBuilder>();
if (_userManager == null) _userManager = Yue.Dependency.IocManager.Instance.Resolve<UserManager>();
if (_yueZeroDbMigrator == null) _yueZeroDbMigrator = Yue.Dependency.IocManager.Instance.Resolve<IYueZeroDbMigrator>();
if (_appNotifier == null) _appNotifier = Yue.Dependency.IocManager.Instance.Resolve<IAppNotifier>();
if (_notificationSubscriptionManager == null) _notificationSubscriptionManager = Yue.Dependency.IocManager.Instance.Resolve<NotificationSubscriptionManager>();
if (_roleManager == null) _roleManager = Yue.Dependency.IocManager.Instance.Resolve<RoleManager>();
if (_userEmailer == null) _userEmailer = Yue.Dependency.IocManager.Instance.Resolve<IUserEmailer>();
and change in ApplicationServiceBase
public abstract class IWorksApplicationService : ApplicationService
{
private TenantManager _TenantManager;
public TenantManager TenantManager
{
get
{
if (_TenantManager == null)
{
_TenantManager = Yue.Dependency.IocManager.Instance.Resolve<TenantManager>();
}
return _TenantManager;
}
}
private UserManager _UserManager;
public UserManager UserManager
{
get
{
if (_UserManager == null)
{
_UserManager = Yue.Dependency.IocManager.Instance.Resolve<UserManager>();
}
return _UserManager;
}
}
and now every ajax response time is less than 80ms.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Improving Your App's Performance
Performance improvement work is a cycle. Gather data about your app's current performance. Then. Minimizing resource use benefits your users and improves their ......
Read more >How to Avoid Common App Performance Optimization Pitfalls
Learn how to optimize your app's performance and avoid common challenges and pitfalls with these tips and best practices.
Read more >How to Optimize Mobile App Performance for Any Scenario
Optimize your app size and resources Another way to optimize your app performance is to reduce your app size and resources. App size...
Read more >MvvmCross: IoC and ServiceLocation performance
I consider the answer as: There are no any problems with performance when using MvvmCross in usual apps development, however, due to mentioned ......
Read more >Best practices for app optimization | App quality
Follow these best practices to optimize your app without sacrificing quality. Use Baseline Profiles.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had found the same problem. #1528
moved to https://github.com/aspnetboilerplate/module-zero/issues/288