Tuesday, March 14, 2017
XAF app performance: Reducing the number of simultaneous database connections
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:
DB_NAME(dbid) as DBName,
COUNT(dbid) as NumberOfConnections,
loginame as LoginName
dbid > 0
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 users. Starting 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
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