Application Performance Improvement

Read Complete Release Notes

What's New?

In the previous versions of the SummitAI application, SQL Server was used for Session Management in the customer production environment (On-Premise). Since, the Application was heavily using Session and large amount of data was getting stored and retrieved from the Session, the SQL Server was becoming a bottleneck. This was causing Application performance issues.

Recommendations

Following recommendations are provided to improve the overall Application performance:

  • Move Session Management to Redis Server
  • Use SQL Server in memory tables for managing Sessions

Both the approaches significantly improve the Application performance. Based on the environment, cost and customer, SummitAI team can further advise on the approach to be adopted.

Using Redis Server

Prerequisites for Redis Server

Redis is installed on Linux. Ubuntu LTS 18.04 version is the recommended version. The Linux machine can be a physical or a virtual machine. Alternatively, if docker is available on server operating system, Redis can be installed inside docker as well.

You can also install Keydb. Keydb is high performance fork of Redis. Keydb is 100% compatible with Redis. You can switch between Redis or Keydb without altering the code.

Hardware Requirements for Redis Server Installation for Production Systems

Item

Description

Minimum Requirement

Recommended

RAM Per node

RAM size must be part of the capacity planning

16GB

>=30GB

Cores per node

Redis server is based on a multi-tenant architecture and can run multiple processes on the same core without significant performance degradation

4 cores

 >=8 Cores

Nodes per cluster

At least 3 nodes are required to support a reliable, highly available deployment that handles process failure, node failure, and network split events in a consistent manner.

3 nodes

>= 3 nodes (Must be an odd number of nodes)

Ephemeral Storage

Used for storing replication files (RDB format) and cluster log files.

60GB

120GB

Network

Using multiple NICs per node where each NIC is >100Kbps, but RS can also run over a single 1Gbps interface network used for processing application requests, inter-cluster communication, and storage access.

1G

>=10G

Software Requirements Redis Server Installation

Redis Version

Linux

2.8.x

Ubuntu LTS 18.04 version

Redis Installation on VM or Physical Machine

  1. Update your local apt package cache and install Redis by typing in:
    1. sudo apt update
    2. sudo apt install redis-server
  2. This will download and install Redis and its dependencies. Redis configuration can be managed using redis.conf file. Default password for Redis is empty. Open the redis conf by issuing the following command
    1. sudo nano /etc/redis/redis.conf

To start the Redis Server automatically, it has to register with system. Update the Redis conf with following:

           supervised system 

To check the if Redis service is running fine, issue the following command: 

           sudo systemctl status redis

By default, Redis service runs on 6379 port. You can change this port by editing the redis.conf file. More about Redis configuration can be found in the following links:

                https://redis.io/topics/config

                https://raw.githubusercontent.com/antirez/redis/5.0/redis.conf

Redis Installation in Docker

Make sure that the docker is installed on the server grade operating system. Run the following command:

        docker pull redis

It will pull the latest version of Redis. To install specific version, issue the following command:

        docker pull redis:{specific version}

Run the container using following command:

        docker run -p 6379:6379 -d redis

The Docker port of 6379 is mapped with 6379 of local machine. Make sure that 6379 port is open for other machines. Port 6379 of Redis machine should be accessible from the Application Server.

Configuring SummitAI Application for Using Redis for Session Management

Redis connection string and web.config changes

  • Remove existing session provider from web.config. E.g. remove state server or SQLserver
  • Add the following settings in under <system.webserver> section:
       <modules>
       <remove name="Session" />
       <add name="Session" type="Microsoft.AspNet.SessionState.SessionStateModuleAsync, Microsoft.AspNet.SessionState.SessionStateModule, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="integratedMode" />
       <modules>
  • Add the Redis provider by adding following settings:

 Refer to sample web.config For Redis

       <sessionState mode="Custom" customProvider="MySessionStateStore">

  <providers>

    <!-- Either use 'connectionString' OR 'settingsClassName' and 'settingsMethodName' OR use 'host','port','accessKey','ssl','connectionTimeoutInMilliseconds' and 'operationTimeoutInMilliseconds'. -->

    <!-- 'throwOnError','retryTimeoutInMilliseconds','databaseId' and 'applicationName' can be used with both options. -->

    <!--

      <add name="MySessionStateStore"

        host = "127.0.0.1" [String]

        port = "" [number]

        accessKey = "" [String]

        ssl = "false" [true|false]

        throwOnError = "true" [true|false]

        retryTimeoutInMilliseconds = "5000" [number]

        databaseId = "0" [number]

        applicationName = "" [String]

        connectionTimeoutInMilliseconds = "5000" [number]

        operationTimeoutInMilliseconds = "1000" [number]

        connectionString = "<Valid StackExchange.Redis connection string>" [String]

        settingsClassName = "<Assembly qualified class name that contains settings method specified below. Which basically return 'connectionString' value>" [String]

        settingsMethodName = "<Settings method should be defined in settingsClass. It should be public, static, does not take any parameters and should have a return type of 'String', which is basically 'connectionString' value.>" [String]

        loggingClassName = "<Assembly qualified class name that contains logging method specified below>" [String]

        loggingMethodName = "<Logging method should be defined in loggingClass. It should be public, static, does not take any parameters and should have a return type of System.IO.TextWriter.>" [String]

        redisSerializerType = "<Assembly qualified class name that implements Microsoft.Web.Redis.ISerializer>" [String]

      />

    -->

    <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider"

         host=""

         accessKey=""

         ssl="true" />

  </providers>

</sessionState>

Redis Clients

Redis Cli

This is a free command line tool and comes with Redis installation. No separate installation is required for this.

Redis Commander

This is a free and open source browser-based GUI tool.

Installation using npm   

Run the following command for installation:

     npm install -g redis-commander

Launch the Redis commander from command prompt using the following command:

      redis-commander    

Open the browser and browse the following URL: http://127.0.0.1:8081

Add the Redis Server using Add Server menu. Enter the Redis Server details for connecting it.

Please refer the following link for more details: Redis-commander installation 

Redis Insights    

This is paid browser-based GUI client. Free version has many limitations. Download the application from the following link: Download Redis Insights                                     

After installation, launch the Redis insights from the start menu. Open the browser and enter the following URL: http://localhost:8001/

You can add Redis connection from the UI.



Using SQL Server in Memory Tables

Prerequisites for SQL Server in Memory Tables

Memory tables are supported from SQL Server 2016 and above.

Configuring SummitAI Application for Using SQL Server in Memory Table

Generate the in-memory database in SQL server. Refer to Script for generating in memory session database.

Add the following settings to use SQL server in memory tables as session provider. Refer to sample web.config  For SQL server in memory

                    <sessionState mode="Custom"  customProvider="AzureSessionProvider" allowCustomSqlDatabase="true" sqlConnectionString="Server=tcp:serverIP;Database=AspState;User ID=userId;Password=password;">        

                           <providers>          

                           <add useInMemoryTable="true" retryInterval="100"  maxRetryNumber="5" name="AzureSessionProvider" type="Azure.Utilities.SqlSessionStateStore, Azure.Utilities" writeExceptionsToEventLog="false" />        

                           </providers>

     

                     </sessionState>

Sample Web.Config

For Redis

Sample Redis - Web.config

For SQL server in memory

Sample SQL Server In memory - Web.config

Script for generating in memory session database

aspstate_sql2016_with_retry.sql