Quantcast
Channel: eXpandFramework RSS
Viewing all articles
Browse latest Browse all 861

XAF app performance: Reducing the number of simultaneous database connections

$
0
0


Multiple simultaneously opened connections consume your database server memory and thus, have negative impact on your application performance. To diagnose this situation, you can use the following SQL script:

SELECT 
    DB_NAME(dbid) as DBName, 
    COUNT(dbid) as NumberOfConnections,
    loginame as LoginName
FROM
    sys.sysprocesses
WHERE 
    dbid > 0
GROUP BY 
    dbid, loginame

Thankfully, there is a couple of tricks to optimize your existing apps in production (they are already applied out of the box in new projects).




Scenario 1: XPO-based web application with multiple concurrent users

Ensure that the code demonstrated in the Initialization of one XPO data layer per one global HttpApplication ticket is added to the Global.asax.cs file. This code creates a single IXpoDataStoreProvider and IDataStore  objects shared by all usersStarting with the 15.2.4 version, this code is automatically added by the Solution Wizard, but it may be missing in projects created with an earlier version of XAF.

Scenario 2: An XPO-based WinForms application in Instant Feedback mode

Ensure that the following code, which registers the XPObjectSpaceProvider or SecuredObjectSpaceProvider with enabled caching and connection pooling in the data store provider, is added to the WinApplication.cs file.Starting with the 16.2.5 version, this code is automatically added by the Solution Wizard, but it may be missing in projects created with an earlier version of XAF.

winApplication.CreateCustomObjectSpaceProvider += (sender, e) => {
    e.ObjectSpaceProviders.Add(new SecuredObjectSpaceProvider((ISelectDataSecurityProvider)winApplication.Security, 
        XPObjectSpaceProvider.GetDataStoreProvider(e.ConnectionString, e.Connection, true), false));
    e.ObjectSpaceProviders.Add(new NonPersistentObjectSpaceProvider(winApplication.TypesInfo, null));
};

See Also: How to measure and improve the application's performance

Viewing all articles
Browse latest Browse all 861

Trending Articles