SlideShare a Scribd company logo
Mahmud Hasan
Lead Software Engineer
                Jaxara
 For any website performance depends on the
  following factors:
1. Server configuration.

2. Server side implementation.

3. Client side implementation.

4. Database implementation.

5. Hardware configuration.

6. Network configuration.
 In this session we will discuss on blue highlighted
  items below:
1. Server configuration.

2. Server side implementation.

3. Client side implementation.

4. Database implementation.

5. Hardware configuration.

6. Network configuration.
We know:
 For asp.net websites we use IIS as webserver.

 We hold all of our website specific configurations in
  web.config file.

 But do we know about 2 more config files that hold
 different configurations of our application? Those
 are machine.config and web.config inside
 “C:WindowsMicrosoft.NETFrameworkv2.0.5072
 7CONFIG” folder.
   Web.config in your website’s root directory
    holds configuration of your website. On the
    other hand web.config and machine.config in
    “C:WindowsMicrosoft.NETFrameworkv2.0.
    50727CONFIG” folder holds global
    configuration of your webserver and it is
    global for all the websites of your server.
   Now a days most of the sites have dependencies on
    external services and resources. You can adjust the
    settings of few server variables to scale your site
    for better accessibility and performance.
   Process Model
    In machine.config file you will find the following
    block under system.web:

       <processModel autoConfig="true"/>


    This will set all the process model parameters
    value to its default. Though the default process
    model configuration is not defined in
    machine.config or root web.config, you can see
    the default values set by an application here:
<processModel
   enable="true"
   timeout="Infinite"
   idleTimeout="Infinite"
   shutdownTimeout="00:00:05"
   requestLimit="Infinite"
   requestQueueLimit="5000"
   restartQueueLimit="10"
   memoryLimit="60"
   webGarden="false"
   cpuMask="0xffffffff"
   userName="machine"
   password="AutoGenerate"
   logLevel="Errors"
   clientConnectedCheck="00:00:05"
   comAuthenticationLevel="Connect"
   comImpersonationLevel="Impersonate"
   responseDeadlockInterval="00:03:00"
   responseRestartDeadlockInterval="00:03:00"
   autoConfig="true"
   maxWorkerThreads="20"
   maxIoThreads="20"
   minWorkerThreads="1"
   minIoThreads="1"
   serverErrorMessageFile=""
   pingFrequency="Infinite"
   pingTimeout="Infinite"
   asyncOption="20"
   maxAppDomains="2000" />
   We will see how we can improve asp.net application’s
    performance by modifying few of the processModel
    parameters.

   Before that, another very important configuration element
    that has contribution is httpRuntime under system.web.
    Again, you will not see the default value of this element in
    either machine.config or root web.config. Here is the default
    settings:
<httpRuntime
     executionTimeout="110"
     maxRequestLength="4096“
     requestLengthDiskThreshold="256“
     useFullyQualifiedRedirectUrl="false"
     minFreeThreads="8"
     minLocalRequestFreeThreads="4"
     appRequestQueueLimit="5000"
     enableKernelOutputCache="true"
     enableVersionHeader="true"
     requireRootedSaveAsPath="true"
     enable="true"
     shutdownTimeout="90"
     delayNotificationTimeout="5"
     waitChangeNotification="0"
     maxWaitChangeNotification="0"
     requestPriority="Normal"
     enableHeaderChecking="true"
     sendCacheControlHeader="true"
     apartmentThreading="false"/>
   Now let’s see how some of the server level
    parameter values can help us to gain
    performance boost for our applications.
   This parameter defines the number of threads asp.net can process at a time. The
    default value of this parameter is 20. It means, if your web server is a single CPU
    machine, 20 worker threads will be usable by asp.net in parallel. For a dual core
    machine it will be 40.

   The formula is : maxWorkerThreads * # of CPU.

   Don’t confuse one important factor here. Say, you have a dual core machine. That
    does not mean, your webserver can serve 40 simultaneous request based on the
    default settings. It actually depends on another parameter of httpRuntime. that is
    minFreeThreads. I will talk on this soon.

   If your application is less CPU intensive, rather more dependant on database
    server and external services for data and processing, you may increase the value
    of maxWorkerThreads significantly. The allowed range of this parameter is 5 to
    100. Try to assess which value should be optimum for you. I would set it to 100
    for my application. Note that, I knew my application was hosted to a dedicated
    server and no other applications were served from that server.
   This is a parameter of processModel element. It defines the
    maximum number of I/O threads to use for the process. Like
    maxWorkerThreads, the value of this parameter is also
    multiplied by the number of CPU. So,
   the folrmula is: maxIoThreads * # of CPU.

   Default value of this parameter is 20. The range of value it
    allows is 5 to 100. It is better to have this aligned with
    maxWorkerThreads. I would set it to 100 for my application.
   minFreeThreads is a parameter of httpRuntime. It determines how many
    worker threads must be available to start a remote or local request. The
    default value of this parameter is 8. That means if the value of
    maxWorkerThreads is set to 100 in a dual core machine, and if
    minFreeThreads is set to default 8, asp.net will be able to serve total 192
    requests simultaneously.

   The formula is: (maxWorkerThreads*number of CPUs)-minFreeThreads

   You should be careful in setting the value of this parameter. Because, if
    you increase the value of maxWorkerThreads to 100 and sets a very low
    value for minFreeThreads, it will hamper your application. Because for
    every request you application may need some free threads for
    processing background or parallel tasks. That is why, you always should
    ensure a good number of free threads in your application. MSDN
    suggests to set it to 88 * # of CPU. But as my application was hosted to a
    dedicated server, I would set to 50 * # of CPU. You can think of setting
    it to an even lower value if your application runs in a dedicated server
    and does not handle too many asynchronous processing.
   This is a parameter of httpRuntime. It specifies the minimum
    number of free threads that ASP.NET keeps available to allow
    execution of new local requests. The specified number of
    threads is reserved for requests that are coming from the
    local host, in case some requests issue child requests to the
    local host during processing. This helps to prevent a possible
    deadlock with recursive reentry into the Web server. The
    default value of this parameter is 4.

   MSDN suggests to set this value to 76 * # of CPU. But
    according to the ratio of default minLocalRequestFreeThreads
    and maxWorkerThreads, I would set it to 10 * # of CPU.
   minWorkerThreads indicates the minimum number of threads
    that should be kept warm. This is a parameter of
    processModel. The default value of this parameter is 1.

   Threads that are controlled by this setting can be created at a
    much faster rate than worker threads that are created from
    the CLR's default "thread-tuning" capabilities. The suggested
    value for this parameter is : maxWorkerThreads/2. So, if you
    set maxWorkerThreads to 100 should set minWorkerThreads
    to 50. Note that, you should not confuse minWorkerThreads
    with minFreeThreads.
   This is a configuration parameter of
    httpRuntime. The default value is 110
    seconds. Based on your preference, you may
    like to alter the value of this parameter.
   MaxConnection is a parameter defined under
    System.Net.ConnectionManagement. It defines, how
    many external http connections can be made from a
    client. Here the client is asp.net. The suggested value of
    this parameter according to msdn is 12 * # of CPU. But
    you can make it even bigger number based on your
    scenario. If your application has dependencies on many
    external services for data and it is less CPU intensive
    you may set it to as maximum as 100.

      <system.net>
        <connectionManagement>
               <add address="*" maxconnection="100" />
        </connectionManagement>
      </system.net>
   So we have talked about different configurations you may set
    to tune your application for processModel, httpRuntime and
    system.net. These values have dependency on each other. So,
    you must do it very carefully to get the best output.
   An HttpModule is an assembly that implements IHttpModule
    interface and intercepts all Http requests. By default asp.net loads
    quite a few HttpModules. Whenever a http request is sent to the
    server all of the HttpModules take place in in the request pipeline
    and intercepts each and every request.

   The default HttpModules are configured at web.config file inside

    C:WindowsMicrosoft.NETFrameworkv2.0.50727CONFIG directory.
<httpModules>
    <add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/>
    <add name="Session" type="System.Web.SessionState.SessionStateModule">
    <add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule"/>
    <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"/>
    <add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule"/>
    <add name="RoleManager" type="System.Web.Security.RoleManagerModule"/>
    <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule"/>
    <add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule"/>
    <add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule"/>
    <add name="Profile" type="System.Web.Profile.ProfileModule"/>
    <add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version
      =2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    <add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3
      .0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</httpModules>
   It is obvious that you do not need all of the HttpModules in your application.
    So, there is no point to keep the un-used HttpModules in your request
    pipeline and allow them to execute some unnecessary code. For example if
    you do not use WindowsAuthentication, you can safely remove this module
    from your configuration. But removing default HttpModules from the global
    web.config file inside frameworkconfig directory is never wise as it will
    impace all the websites installed in the server. So you should do this in the
    web.config of your own application. You can do this in the following way:

<httpModules>
  <remove name="UrlAuthorization" />
  <remove name="WindowsAuthentication" />
  <remove name="PassportAuthentication" />
  <remove name="AnonymousIdentification" />
  <remove name="FileAuthorization" />
</httpModules>

   Be confirm that your application does not need a module before you
    remove it.
   Since asp.net webform based application came first, perhaps viewstate is one
    of the most liked features in the community. You have a server control in
    your page and after post back you have its value preserved without doing
    anything. Really for web form developers it is an awesome feature. But while
    it is a nice feature, it can hamper your site performance too unless you use
    this efficiently.
   By default in all asp.net pages the viewstate is enabled. So, all the server
    controls you use in your webform will persist its viewstate. ViewSate always
    loads in your browser in encoded format. So, the bigger your ViewState is,
    the bigger your page size becomes. For a small and simple page this may be
    minor. But when you use a complex and large page where quite a few server
    controls are used, ViewState can increase your page size significantly. Look
    at image 1 to see the look of ViewState of a simple asp.net page where I had
    used just a GridView control and populated it with 60 rows and 3 columns.
    You can disable ViewState in your asp.net application in 3 levels. 1. application level 2.
     page level 3. control level. You should always remember the precedence of this settings.
     Your common sense may tempt you to think you can disable ViewState in application
     level and even in page level then, you will enable it in control level. But it will not work in
     this way. In asp.net ViewState settings work the other way. Application level setting gets
     the highest priority, then the page level setting and finally the control level setting.

    So the suggested way is:

1.   If you need ViewState even in a single location of your application, keep it enabled at application level.
2.   The pages where you do not need ViewState at all, disable it in page level.
3.   The pages where you need ViewState, enable it in page level and then disable it in all the server
     controls where you actually do not need it. The controls that loads on every get or post request and
     you do not need its value to be persisted between http requests are most likely the controls where you
     do not need view state. For example: A GridView control may not need a view state.


    Application Level Setting > Page Level Setting > Control Level Setting
Disable ViewState in Application Level inside web.config

 <system.web>
    <pages enableViewState="false"></pages>
 </system.web>

Disable ViewState in Page Level in Page directive

<%@ Page .... EnableViewState="false" %>

Disable ViewState at control level

<asp:Label runat="server" ID="lblMsg" EnableViewState="false">H
 ere is your message!</asp:Label>
This is really a 100 level message to most asp.net developers.
Sometimes, we tend to store information in ViewState when the
information just needs to be persisted during a post back. But as I
have already described, we should always try to keep the ViewState
size as minimum as possible. So, storing large data in ViewState is
always prohibited.
When you develop your asp.net based web application, you may like to
turn on the trace to profile different matrixes of your application. This is
fine. But when you deploy the site to production, you must turn off the
Asp.Net Trace.
You can turn on the trace through web.config:

<trace enabled="true" pageOutput="true"/>

This will load the trace data at the bottom of your browser window.
When you go to production make sure that you make both “enabled”
and “pageOutput” to false. If you just make pageOutput to false still
tracing runs in the background and performance will be affected.
   Turn Debug off.
   Deploy with release build.
   Use of Page.IsPostBack
   String Operations
   SSL is Not Cached, so Minimize SSL Use
   Minimize HTTP Requests
    ◦ Use Sprite Images
    ◦ Use Image Maps
   Use CDN
   Cache your static contents
   Cache your dynamic contents where appropriate.
   gZip components
   Put Stylesheets at the Top
   Put Scripts at the Bottom
   Make JavaScript and CSS External
   Minify JavaScript and CSS
   Flush the Buffer Early
   Split Components Across Domains
   Reduce Cookie Size
   Use Cookie-free Domains for static
    Components
   Use PNG over GIF
   Don't re-size Images in HTML
   Make favicon.ico Small and Cacheable
   Create proper indexing
   De-fragment your indexes
   Write better query
    ◦   Avoid using cursor
    ◦   Temporary Table/ Table variable
    ◦   Avoid Using Dynamic SQL
    ◦   Avoid “like” when you perform any complex query
        on large data
    ◦   Never do “select * from table”
    ◦   Comment out your print statements
    ◦   Use Indexed view
    ◦   Prefer subquery over function if re-usability is not
        vital.
    ◦   Use “UNION” over “OR”
Thanks

More Related Content

What's hot

Sherlock Homepage - A detective story about running large web services - WebN...
Sherlock Homepage - A detective story about running large web services - WebN...Sherlock Homepage - A detective story about running large web services - WebN...
Sherlock Homepage - A detective story about running large web services - WebN...
Maarten Balliauw
 
How To Configure Amazon EC2 Load Balancer
How To Configure Amazon EC2 Load BalancerHow To Configure Amazon EC2 Load Balancer
How To Configure Amazon EC2 Load Balancer
VCP Muthukrishna
 
How To Configure Amazon EC2 Security Groups
How To Configure Amazon EC2 Security GroupsHow To Configure Amazon EC2 Security Groups
How To Configure Amazon EC2 Security Groups
VCP Muthukrishna
 
How To Install and Configure Open SSH Server on Ubuntu
How To Install and Configure Open SSH Server on UbuntuHow To Install and Configure Open SSH Server on Ubuntu
How To Install and Configure Open SSH Server on Ubuntu
VCP Muthukrishna
 
How To Connect Amazon AWS EC2 with Key Pair – Linux
How To Connect Amazon AWS EC2 with Key Pair – LinuxHow To Connect Amazon AWS EC2 with Key Pair – Linux
How To Connect Amazon AWS EC2 with Key Pair – Linux
VCP Muthukrishna
 
Pandora FMS: Apache server monitoring
Pandora FMS: Apache server monitoring Pandora FMS: Apache server monitoring
Pandora FMS: Apache server monitoring
Pandora FMS
 
How To Configure FirewallD on RHEL 7 or CentOS 7
How To Configure FirewallD on RHEL 7 or CentOS 7How To Configure FirewallD on RHEL 7 or CentOS 7
How To Configure FirewallD on RHEL 7 or CentOS 7
VCP Muthukrishna
 
Windows PowerShell Basics - How To List PSDrive Info
Windows PowerShell Basics - How To List PSDrive InfoWindows PowerShell Basics - How To List PSDrive Info
Windows PowerShell Basics - How To List PSDrive Info
VCP Muthukrishna
 
How To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Check IE Enhanced Security Is Enabled Windows PowerShellHow To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Check IE Enhanced Security Is Enabled Windows PowerShell
VCP Muthukrishna
 
How To Install and Configure Apache SSL on CentOS 7
How To Install and Configure Apache SSL on CentOS 7How To Install and Configure Apache SSL on CentOS 7
How To Install and Configure Apache SSL on CentOS 7
VCP Muthukrishna
 
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
VCP Muthukrishna
 
Scaling up task processing with Celery
Scaling up task processing with CeleryScaling up task processing with Celery
Scaling up task processing with Celery
Nicolas Grasset
 
Shell Script Disk Usage Report and E-Mail Current Threshold Status
Shell Script  Disk Usage Report and E-Mail Current Threshold StatusShell Script  Disk Usage Report and E-Mail Current Threshold Status
Shell Script Disk Usage Report and E-Mail Current Threshold Status
VCP Muthukrishna
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
Mohammad Reza Kamalifard
 
How to installation and configure apache2
How to installation and configure apache2How to installation and configure apache2
How to installation and configure apache2
VCP Muthukrishna
 
Install and Configure RSyslog – CentOS 7 / RHEL 7
Install and Configure RSyslog – CentOS 7 / RHEL 7Install and Configure RSyslog – CentOS 7 / RHEL 7
Install and Configure RSyslog – CentOS 7 / RHEL 7
VCP Muthukrishna
 
Ajax basics
Ajax basicsAjax basics
How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7
VCP Muthukrishna
 
How To Configure Apache VirtualHost on RHEL 7 on AWS
How To Configure Apache VirtualHost on RHEL 7 on AWSHow To Configure Apache VirtualHost on RHEL 7 on AWS
How To Configure Apache VirtualHost on RHEL 7 on AWS
VCP Muthukrishna
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
Engine Yard
 

What's hot (20)

Sherlock Homepage - A detective story about running large web services - WebN...
Sherlock Homepage - A detective story about running large web services - WebN...Sherlock Homepage - A detective story about running large web services - WebN...
Sherlock Homepage - A detective story about running large web services - WebN...
 
How To Configure Amazon EC2 Load Balancer
How To Configure Amazon EC2 Load BalancerHow To Configure Amazon EC2 Load Balancer
How To Configure Amazon EC2 Load Balancer
 
How To Configure Amazon EC2 Security Groups
How To Configure Amazon EC2 Security GroupsHow To Configure Amazon EC2 Security Groups
How To Configure Amazon EC2 Security Groups
 
How To Install and Configure Open SSH Server on Ubuntu
How To Install and Configure Open SSH Server on UbuntuHow To Install and Configure Open SSH Server on Ubuntu
How To Install and Configure Open SSH Server on Ubuntu
 
How To Connect Amazon AWS EC2 with Key Pair – Linux
How To Connect Amazon AWS EC2 with Key Pair – LinuxHow To Connect Amazon AWS EC2 with Key Pair – Linux
How To Connect Amazon AWS EC2 with Key Pair – Linux
 
Pandora FMS: Apache server monitoring
Pandora FMS: Apache server monitoring Pandora FMS: Apache server monitoring
Pandora FMS: Apache server monitoring
 
How To Configure FirewallD on RHEL 7 or CentOS 7
How To Configure FirewallD on RHEL 7 or CentOS 7How To Configure FirewallD on RHEL 7 or CentOS 7
How To Configure FirewallD on RHEL 7 or CentOS 7
 
Windows PowerShell Basics - How To List PSDrive Info
Windows PowerShell Basics - How To List PSDrive InfoWindows PowerShell Basics - How To List PSDrive Info
Windows PowerShell Basics - How To List PSDrive Info
 
How To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Check IE Enhanced Security Is Enabled Windows PowerShellHow To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Check IE Enhanced Security Is Enabled Windows PowerShell
 
How To Install and Configure Apache SSL on CentOS 7
How To Install and Configure Apache SSL on CentOS 7How To Install and Configure Apache SSL on CentOS 7
How To Install and Configure Apache SSL on CentOS 7
 
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
 
Scaling up task processing with Celery
Scaling up task processing with CeleryScaling up task processing with Celery
Scaling up task processing with Celery
 
Shell Script Disk Usage Report and E-Mail Current Threshold Status
Shell Script  Disk Usage Report and E-Mail Current Threshold StatusShell Script  Disk Usage Report and E-Mail Current Threshold Status
Shell Script Disk Usage Report and E-Mail Current Threshold Status
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
 
How to installation and configure apache2
How to installation and configure apache2How to installation and configure apache2
How to installation and configure apache2
 
Install and Configure RSyslog – CentOS 7 / RHEL 7
Install and Configure RSyslog – CentOS 7 / RHEL 7Install and Configure RSyslog – CentOS 7 / RHEL 7
Install and Configure RSyslog – CentOS 7 / RHEL 7
 
Ajax basics
Ajax basicsAjax basics
Ajax basics
 
How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7
 
How To Configure Apache VirtualHost on RHEL 7 on AWS
How To Configure Apache VirtualHost on RHEL 7 on AWSHow To Configure Apache VirtualHost on RHEL 7 on AWS
How To Configure Apache VirtualHost on RHEL 7 on AWS
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
 

Similar to Performance tips for web

cPanel - Apache Global Configuration
cPanel - Apache Global ConfigurationcPanel - Apache Global Configuration
cPanel - Apache Global Configuration
skuver
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
oazabir
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmenMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
VannaSchrader3
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docxMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
alfredacavx97
 
Jmeter interviewquestions
Jmeter interviewquestionsJmeter interviewquestions
Jmeter interviewquestions
girichinna27
 
PeopleSoft Integration broker Performance Tunning
PeopleSoft Integration broker Performance TunningPeopleSoft Integration broker Performance Tunning
PeopleSoft Integration broker Performance Tunning
InSync Conference
 
PowerPoint Presentation
PowerPoint PresentationPowerPoint Presentation
PowerPoint Presentation
webhostingguy
 
Chapter 8 part2
Chapter 8   part2Chapter 8   part2
Chapter 8 part2
application developer
 
Sherlock Homepage - A detective story about running large web services - NDC ...
Sherlock Homepage - A detective story about running large web services - NDC ...Sherlock Homepage - A detective story about running large web services - NDC ...
Sherlock Homepage - A detective story about running large web services - NDC ...
Maarten Balliauw
 
Sherlock Homepage (Maarten Balliauw)
Sherlock Homepage (Maarten Balliauw)Sherlock Homepage (Maarten Balliauw)
Sherlock Homepage (Maarten Balliauw)
Visug
 
Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...
Maarten Balliauw
 
Using Apache as an Application Server
Using Apache as an Application ServerUsing Apache as an Application Server
Using Apache as an Application Server
Phil Windley
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing
Techglyphs
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questions
Akhil Mittal
 
Salt conf 2014 - Using SaltStack in high availability environments
Salt conf 2014 - Using SaltStack in high availability environmentsSalt conf 2014 - Using SaltStack in high availability environments
Salt conf 2014 - Using SaltStack in high availability environments
Benjamin Cane
 
MySQL Performance Tuning 101
MySQL Performance Tuning 101MySQL Performance Tuning 101
MySQL Performance Tuning 101
Mirko Ortensi
 
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability EnvironmentsSaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltStack
 
Kioptrix 2014 5
Kioptrix 2014 5Kioptrix 2014 5
Kioptrix 2014 5
Jayesh Patel
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
Sam Keen
 
Service Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and KubernetesService Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and Kubernetes
Sreenivas Makam
 

Similar to Performance tips for web (20)

cPanel - Apache Global Configuration
cPanel - Apache Global ConfigurationcPanel - Apache Global Configuration
cPanel - Apache Global Configuration
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmenMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docxMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
 
Jmeter interviewquestions
Jmeter interviewquestionsJmeter interviewquestions
Jmeter interviewquestions
 
PeopleSoft Integration broker Performance Tunning
PeopleSoft Integration broker Performance TunningPeopleSoft Integration broker Performance Tunning
PeopleSoft Integration broker Performance Tunning
 
PowerPoint Presentation
PowerPoint PresentationPowerPoint Presentation
PowerPoint Presentation
 
Chapter 8 part2
Chapter 8   part2Chapter 8   part2
Chapter 8 part2
 
Sherlock Homepage - A detective story about running large web services - NDC ...
Sherlock Homepage - A detective story about running large web services - NDC ...Sherlock Homepage - A detective story about running large web services - NDC ...
Sherlock Homepage - A detective story about running large web services - NDC ...
 
Sherlock Homepage (Maarten Balliauw)
Sherlock Homepage (Maarten Balliauw)Sherlock Homepage (Maarten Balliauw)
Sherlock Homepage (Maarten Balliauw)
 
Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...Sherlock Homepage - A detective story about running large web services (VISUG...
Sherlock Homepage - A detective story about running large web services (VISUG...
 
Using Apache as an Application Server
Using Apache as an Application ServerUsing Apache as an Application Server
Using Apache as an Application Server
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questions
 
Salt conf 2014 - Using SaltStack in high availability environments
Salt conf 2014 - Using SaltStack in high availability environmentsSalt conf 2014 - Using SaltStack in high availability environments
Salt conf 2014 - Using SaltStack in high availability environments
 
MySQL Performance Tuning 101
MySQL Performance Tuning 101MySQL Performance Tuning 101
MySQL Performance Tuning 101
 
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability EnvironmentsSaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
 
Kioptrix 2014 5
Kioptrix 2014 5Kioptrix 2014 5
Kioptrix 2014 5
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
Service Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and KubernetesService Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and Kubernetes
 

Recently uploaded

Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
Things to Consider When Choosing a Website Developer for your Website | FODUU
Things to Consider When Choosing a Website Developer for your Website | FODUUThings to Consider When Choosing a Website Developer for your Website | FODUU
Things to Consider When Choosing a Website Developer for your Website | FODUU
FODUU
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdfAI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
Techgropse Pvt.Ltd.
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 

Recently uploaded (20)

Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
Things to Consider When Choosing a Website Developer for your Website | FODUU
Things to Consider When Choosing a Website Developer for your Website | FODUUThings to Consider When Choosing a Website Developer for your Website | FODUU
Things to Consider When Choosing a Website Developer for your Website | FODUU
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdfAI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 

Performance tips for web

  • 1. Mahmud Hasan Lead Software Engineer Jaxara
  • 2.  For any website performance depends on the following factors: 1. Server configuration. 2. Server side implementation. 3. Client side implementation. 4. Database implementation. 5. Hardware configuration. 6. Network configuration.
  • 3.  In this session we will discuss on blue highlighted items below: 1. Server configuration. 2. Server side implementation. 3. Client side implementation. 4. Database implementation. 5. Hardware configuration. 6. Network configuration.
  • 4. We know:  For asp.net websites we use IIS as webserver.  We hold all of our website specific configurations in web.config file. But do we know about 2 more config files that hold different configurations of our application? Those are machine.config and web.config inside “C:WindowsMicrosoft.NETFrameworkv2.0.5072 7CONFIG” folder.
  • 5. Web.config in your website’s root directory holds configuration of your website. On the other hand web.config and machine.config in “C:WindowsMicrosoft.NETFrameworkv2.0. 50727CONFIG” folder holds global configuration of your webserver and it is global for all the websites of your server.
  • 6. Now a days most of the sites have dependencies on external services and resources. You can adjust the settings of few server variables to scale your site for better accessibility and performance.
  • 7. Process Model In machine.config file you will find the following block under system.web: <processModel autoConfig="true"/> This will set all the process model parameters value to its default. Though the default process model configuration is not defined in machine.config or root web.config, you can see the default values set by an application here:
  • 8. <processModel enable="true" timeout="Infinite" idleTimeout="Infinite" shutdownTimeout="00:00:05" requestLimit="Infinite" requestQueueLimit="5000" restartQueueLimit="10" memoryLimit="60" webGarden="false" cpuMask="0xffffffff" userName="machine" password="AutoGenerate" logLevel="Errors" clientConnectedCheck="00:00:05" comAuthenticationLevel="Connect" comImpersonationLevel="Impersonate" responseDeadlockInterval="00:03:00" responseRestartDeadlockInterval="00:03:00" autoConfig="true" maxWorkerThreads="20" maxIoThreads="20" minWorkerThreads="1" minIoThreads="1" serverErrorMessageFile="" pingFrequency="Infinite" pingTimeout="Infinite" asyncOption="20" maxAppDomains="2000" />
  • 9. We will see how we can improve asp.net application’s performance by modifying few of the processModel parameters.  Before that, another very important configuration element that has contribution is httpRuntime under system.web. Again, you will not see the default value of this element in either machine.config or root web.config. Here is the default settings:
  • 10. <httpRuntime executionTimeout="110" maxRequestLength="4096“ requestLengthDiskThreshold="256“ useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="5000" enableKernelOutputCache="true" enableVersionHeader="true" requireRootedSaveAsPath="true" enable="true" shutdownTimeout="90" delayNotificationTimeout="5" waitChangeNotification="0" maxWaitChangeNotification="0" requestPriority="Normal" enableHeaderChecking="true" sendCacheControlHeader="true" apartmentThreading="false"/>
  • 11. Now let’s see how some of the server level parameter values can help us to gain performance boost for our applications.
  • 12. This parameter defines the number of threads asp.net can process at a time. The default value of this parameter is 20. It means, if your web server is a single CPU machine, 20 worker threads will be usable by asp.net in parallel. For a dual core machine it will be 40.  The formula is : maxWorkerThreads * # of CPU.  Don’t confuse one important factor here. Say, you have a dual core machine. That does not mean, your webserver can serve 40 simultaneous request based on the default settings. It actually depends on another parameter of httpRuntime. that is minFreeThreads. I will talk on this soon.  If your application is less CPU intensive, rather more dependant on database server and external services for data and processing, you may increase the value of maxWorkerThreads significantly. The allowed range of this parameter is 5 to 100. Try to assess which value should be optimum for you. I would set it to 100 for my application. Note that, I knew my application was hosted to a dedicated server and no other applications were served from that server.
  • 13. This is a parameter of processModel element. It defines the maximum number of I/O threads to use for the process. Like maxWorkerThreads, the value of this parameter is also multiplied by the number of CPU. So,  the folrmula is: maxIoThreads * # of CPU.  Default value of this parameter is 20. The range of value it allows is 5 to 100. It is better to have this aligned with maxWorkerThreads. I would set it to 100 for my application.
  • 14. minFreeThreads is a parameter of httpRuntime. It determines how many worker threads must be available to start a remote or local request. The default value of this parameter is 8. That means if the value of maxWorkerThreads is set to 100 in a dual core machine, and if minFreeThreads is set to default 8, asp.net will be able to serve total 192 requests simultaneously.  The formula is: (maxWorkerThreads*number of CPUs)-minFreeThreads  You should be careful in setting the value of this parameter. Because, if you increase the value of maxWorkerThreads to 100 and sets a very low value for minFreeThreads, it will hamper your application. Because for every request you application may need some free threads for processing background or parallel tasks. That is why, you always should ensure a good number of free threads in your application. MSDN suggests to set it to 88 * # of CPU. But as my application was hosted to a dedicated server, I would set to 50 * # of CPU. You can think of setting it to an even lower value if your application runs in a dedicated server and does not handle too many asynchronous processing.
  • 15. This is a parameter of httpRuntime. It specifies the minimum number of free threads that ASP.NET keeps available to allow execution of new local requests. The specified number of threads is reserved for requests that are coming from the local host, in case some requests issue child requests to the local host during processing. This helps to prevent a possible deadlock with recursive reentry into the Web server. The default value of this parameter is 4.  MSDN suggests to set this value to 76 * # of CPU. But according to the ratio of default minLocalRequestFreeThreads and maxWorkerThreads, I would set it to 10 * # of CPU.
  • 16. minWorkerThreads indicates the minimum number of threads that should be kept warm. This is a parameter of processModel. The default value of this parameter is 1.  Threads that are controlled by this setting can be created at a much faster rate than worker threads that are created from the CLR's default "thread-tuning" capabilities. The suggested value for this parameter is : maxWorkerThreads/2. So, if you set maxWorkerThreads to 100 should set minWorkerThreads to 50. Note that, you should not confuse minWorkerThreads with minFreeThreads.
  • 17. This is a configuration parameter of httpRuntime. The default value is 110 seconds. Based on your preference, you may like to alter the value of this parameter.
  • 18. MaxConnection is a parameter defined under System.Net.ConnectionManagement. It defines, how many external http connections can be made from a client. Here the client is asp.net. The suggested value of this parameter according to msdn is 12 * # of CPU. But you can make it even bigger number based on your scenario. If your application has dependencies on many external services for data and it is less CPU intensive you may set it to as maximum as 100. <system.net> <connectionManagement> <add address="*" maxconnection="100" /> </connectionManagement> </system.net>
  • 19. So we have talked about different configurations you may set to tune your application for processModel, httpRuntime and system.net. These values have dependency on each other. So, you must do it very carefully to get the best output.
  • 20. An HttpModule is an assembly that implements IHttpModule interface and intercepts all Http requests. By default asp.net loads quite a few HttpModules. Whenever a http request is sent to the server all of the HttpModules take place in in the request pipeline and intercepts each and every request.  The default HttpModules are configured at web.config file inside C:WindowsMicrosoft.NETFrameworkv2.0.50727CONFIG directory.
  • 21. <httpModules> <add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/> <add name="Session" type="System.Web.SessionState.SessionStateModule"> <add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule"/> <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"/> <add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule"/> <add name="RoleManager" type="System.Web.Security.RoleManagerModule"/> <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule"/> <add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule"/> <add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule"/> <add name="Profile" type="System.Web.Profile.ProfileModule"/> <add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version =2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> <add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3 .0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </httpModules>
  • 22. It is obvious that you do not need all of the HttpModules in your application. So, there is no point to keep the un-used HttpModules in your request pipeline and allow them to execute some unnecessary code. For example if you do not use WindowsAuthentication, you can safely remove this module from your configuration. But removing default HttpModules from the global web.config file inside frameworkconfig directory is never wise as it will impace all the websites installed in the server. So you should do this in the web.config of your own application. You can do this in the following way: <httpModules> <remove name="UrlAuthorization" /> <remove name="WindowsAuthentication" /> <remove name="PassportAuthentication" /> <remove name="AnonymousIdentification" /> <remove name="FileAuthorization" /> </httpModules>  Be confirm that your application does not need a module before you remove it.
  • 23. Since asp.net webform based application came first, perhaps viewstate is one of the most liked features in the community. You have a server control in your page and after post back you have its value preserved without doing anything. Really for web form developers it is an awesome feature. But while it is a nice feature, it can hamper your site performance too unless you use this efficiently.  By default in all asp.net pages the viewstate is enabled. So, all the server controls you use in your webform will persist its viewstate. ViewSate always loads in your browser in encoded format. So, the bigger your ViewState is, the bigger your page size becomes. For a small and simple page this may be minor. But when you use a complex and large page where quite a few server controls are used, ViewState can increase your page size significantly. Look at image 1 to see the look of ViewState of a simple asp.net page where I had used just a GridView control and populated it with 60 rows and 3 columns.
  • 24.
  • 25. You can disable ViewState in your asp.net application in 3 levels. 1. application level 2. page level 3. control level. You should always remember the precedence of this settings. Your common sense may tempt you to think you can disable ViewState in application level and even in page level then, you will enable it in control level. But it will not work in this way. In asp.net ViewState settings work the other way. Application level setting gets the highest priority, then the page level setting and finally the control level setting.  So the suggested way is: 1. If you need ViewState even in a single location of your application, keep it enabled at application level. 2. The pages where you do not need ViewState at all, disable it in page level. 3. The pages where you need ViewState, enable it in page level and then disable it in all the server controls where you actually do not need it. The controls that loads on every get or post request and you do not need its value to be persisted between http requests are most likely the controls where you do not need view state. For example: A GridView control may not need a view state.  Application Level Setting > Page Level Setting > Control Level Setting
  • 26. Disable ViewState in Application Level inside web.config <system.web> <pages enableViewState="false"></pages> </system.web> Disable ViewState in Page Level in Page directive <%@ Page .... EnableViewState="false" %> Disable ViewState at control level <asp:Label runat="server" ID="lblMsg" EnableViewState="false">H ere is your message!</asp:Label>
  • 27. This is really a 100 level message to most asp.net developers. Sometimes, we tend to store information in ViewState when the information just needs to be persisted during a post back. But as I have already described, we should always try to keep the ViewState size as minimum as possible. So, storing large data in ViewState is always prohibited.
  • 28. When you develop your asp.net based web application, you may like to turn on the trace to profile different matrixes of your application. This is fine. But when you deploy the site to production, you must turn off the Asp.Net Trace. You can turn on the trace through web.config: <trace enabled="true" pageOutput="true"/> This will load the trace data at the bottom of your browser window. When you go to production make sure that you make both “enabled” and “pageOutput” to false. If you just make pageOutput to false still tracing runs in the background and performance will be affected.
  • 29. Turn Debug off.  Deploy with release build.
  • 30. Use of Page.IsPostBack  String Operations
  • 31. SSL is Not Cached, so Minimize SSL Use
  • 32. Minimize HTTP Requests ◦ Use Sprite Images ◦ Use Image Maps  Use CDN  Cache your static contents  Cache your dynamic contents where appropriate.
  • 33. gZip components
  • 34. Put Stylesheets at the Top  Put Scripts at the Bottom  Make JavaScript and CSS External  Minify JavaScript and CSS  Flush the Buffer Early  Split Components Across Domains  Reduce Cookie Size  Use Cookie-free Domains for static Components
  • 35. Use PNG over GIF  Don't re-size Images in HTML  Make favicon.ico Small and Cacheable
  • 36. Create proper indexing  De-fragment your indexes
  • 37. Write better query ◦ Avoid using cursor ◦ Temporary Table/ Table variable ◦ Avoid Using Dynamic SQL ◦ Avoid “like” when you perform any complex query on large data ◦ Never do “select * from table” ◦ Comment out your print statements ◦ Use Indexed view ◦ Prefer subquery over function if re-usability is not vital. ◦ Use “UNION” over “OR”