Search This Blog

Monday, April 11, 2016

3 simple steps to improve the overall performance in a middle-tier application server scenario

UPDATED
The contents of this article were merged into the new document at 
Security - How to reduce the number of permission requests and improve overall performance.
=============

Preamble

Here I will be talking about the configuration described in the eXpressApp Framework > Concepts > Security System > New Security System > Middle Tier Security - WCF Service article, assuming that the application server (YourSolutionName.ApplicationServer) is used with a desktop client app (YourSolutionName.Win). I am not talking about the web client, because I anticipate that in this configuration the Client-Side Security (2-Tier Architecture) with the integrated mode (SecuredObjectSpaceProvider) is a more typical choice as long as the database is located on the same web server where the ASP.NET app is deployed.




1. Server or DataView data access mode for ListView

While this is not specific to the 'application server' scenario, it is still worth mentioning these options explicitly when you need to work with large lists in grids in an XAF app. You can learn more on how to select an appropriate mode for your particular case from the online XAF documentation: eXpressApp Framework > Concepts > UI Construction > Views > List View Data Access Modes.


2. Tuning the data transport channel between the server and client apps

By default, XAF Solution Wizard creates a project template  where communication between apps is enabled via WCF with WSHttpBinding created in the WcfDataServerHelper class. You are supposed to modify the binding settings according to your business requirements as described in the WCF documentation (well, you can even opt for the deprecated .NET Remoting instead of WCF here!). MSDN's Choosing a Transport article may come in handy.

To save your time and since we are talking about performance, let me quote the Windows Communication Foundation | Performance Tuning WCF Services, Part 2 article in MSDN:

"The Net.Tcp binding is the best performing binding type for two-way communications between different servers. One drawback is that it is not interoperable with non-WCF clients."


In order to use this NetTcpBinding type, do the following:
2.1. In the YourSolutionName.Win and YourSolutionName.ApplicationServer projects, define the following method in the Program classes:

public static System.ServiceModel.Channels.Binding CreateDefaultBinding() {
    NetTcpBinding binding = new NetTcpBinding();    
    binding.MaxReceivedMessageSize = Int32.MaxValue;
    binding.MaxBufferPoolSize = Int32.MaxValue;
    binding.ReceiveTimeout = TimeSpan.FromHours(24);
    binding.ReaderQuotas.MaxArrayLength = Int32.MaxValue;
    binding.ReaderQuotas.MaxBytesPerRead = Int32.MaxValue;
    binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
    binding.ReaderQuotas.MaxDepth = Int32.MaxValue;
    binding.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue;
    binding.Security.Mode = SecurityMode.None;
    return binding;
}

2.2. Replace the default WcfDataServerHelper.CreateDefaultBinding() calls with the Program.CreateDefaultBinding() ones.


3. Security permission caching


Here I will be referring to the new functionality released in the latest XAF 15.2 (it was also pulled down to v15.1.7+ for early testing). Refer to the new eXpressApp Framework > Concepts > Security System > New Security System > Security Permissions Caching documentation article and my previous blog post to learn more on how to enable and configure this caching according to your business needs. 


To use this new API for our performance tuning in v15.2.9, let's do the following:
3.1. In the YourSolutionName.Win project, add a reference to the DevExpress.ExpressApp.Security.Xpo assembly.
3.2. Add the following line into the very beginning of the Main method of the Program class:

DevExpress.ExpressApp.Security.SecurityAdapterHelper.Enable(DevExpress.ExpressApp.Security.Adapters.ReloadPermissionStrategy.CacheOnFirstAccess);


Your feedback is needed!

I am looking forward to hearing from you in comments once you have had an opportunity to implement and test these suggestions in your existing XAF apps. If you use additional techniques, feel free to share them in comments as well. Should you experience any issues with your XAF projects in this particular configuration, please contact us via the Support Center (https://www.devexpress.com/Support/Center/Question/Create) and attach your test samples, db backups, SQL and other performance profiler traces so we can assist you further.

See Also

3 comments:

  1. you are planning to implement "DataView + Server" mode?

    ReplyDelete
    Replies
    1. Do you mean async server mode (https://documentation.devexpress.com/#CoreLibraries/clsDevExpressXpoXPInstantFeedbackSourcetopic)? If so, thanks for your feedback - our team will take your input into account for the future.

      Delete
    2. If you are referring to a different feature, please describe your use-cases and feature effects in detail.

      Delete