Code best practices and performance optimization. Alf Nilsson Lead System Developer & EMVP



Similar documents
Performance Tuning and Optimizing SQL Databases 2016

Composite C1 Load Balancing - Setup Guide

TRACE PERFORMANCE TESTING APPROACH. Overview. Approach. Flow. Attributes

MS 10978A Introduction to Azure for Developers

How to Setup SQL Server Replication

Performance Testing Microsoft Dynamics NAV

Sitecore Health. Christopher Wojciech. netzkern AG. Sitecore User Group Conference 2015

McAfee Enterprise Mobility Management Performance and Scalability Guide

Assignment # 1 (Cloud Computing Security)

MDM Multidomain Edition (Version 9.6.0) For Microsoft SQL Server Performance Tuning

The HTTP Plug-in. Table of contents

Tier Architectures. Kathleen Durant CS 3200

Performance White Paper

Effective Java Programming. measurement as the basis

SQL Anywhere 12 New Features Summary

Table of Contents Cicero, Inc. All rights protected and reserved.

MCTS Guide to Microsoft Windows 7. Chapter 10 Performance Tuning

Logi Ad Hoc Reporting Configuration for Load Balancing (Sticky Sessions)

EPiServer Operator's Guide

Course 10978A Introduction to Azure for Developers

This three-day instructor-led course provides students with the tools to extend Microsoft Dynamics CRM 4.0.

Load Balancing and Clustering in EPiServer

VirtualCenter Database Performance for Microsoft SQL Server 2005 VirtualCenter 2.5

Hands-On Microsoft Windows Server 2008

Using vcenter Orchestrator AMQP Plug-in

System Requirements for Microsoft Dynamics NAV 2009

Getting Started with Telerik Data Access. Contents

Resource Aware Scheduler for Storm. Software Design Document. Date: 09/18/2015

Tuning WebSphere Application Server ND 7.0. Royal Cyber Inc.

Top 10 reasons your ecommerce site will fail during peak periods

10978A: Introduction to Azure for Developers

Magento & Zend Benchmarks Version 1.2, 1.3 (with & without Flat Catalogs)

Release Notes Scribe Adapter for Microsoft Dynamics

BlackBerry Enterprise Server for Microsoft Exchange Version: 5.0 Service Pack: 2. Feature and Technical Overview

One of the database administrators

Microsoft Dynamics NAV 2013 R2 Sizing Guidelines for On-Premises Single Tenant Deployments

Administering Jive Mobile Apps

Performance Testing of Java Enterprise Systems

Zed E-Commerce and WebCRM 7.5. Release Notes 11/29/2011

Analytics Configuration Reference

Estimate Performance and Capacity Requirements for Workflow in SharePoint Server 2010

Optional custom API wrapper. C/C++ program. M program

SQL Server 2012 Optimization, Performance Tuning and Troubleshooting

R i o L i n x s u p p o r r i o l i n x. c o m 1 / 3 0 /

Scaling Web Applications in a Cloud Environment. Emil Ong Caucho Technology 8621

Predefined Analyser Rules for MS SQL Server

SQL Server Performance Tuning and Optimization

Load Balancing and Clustering in EPiServer

Load Balancing and Clustering in EPiDesk

AppDev OnDemand Cloud Computing Learning Library

Introducing the Microsoft IIS deployment guide

Testing and optimizing Web Performance on the EPiServer platform Excellence in Web Performance

Load and Performance Load Testing. RadView Software October

CLOUD COMPUTING & WINDOWS AZURE

Toad for Oracle 8.6 SQL Tuning

McAfee Agent Handler

Red Hat Network Satellite Management and automation of your Red Hat Enterprise Linux environment

Upgrades and the Cloud

Red Hat Satellite Management and automation of your Red Hat Enterprise Linux environment

KonyOne Server Installer - Linux Release Notes

Enterprise Performance Tuning: Best Practices with SQL Server 2008 Analysis Services. By Ajay Goyal Consultant Scalability Experts, Inc.

MuleSoft Blueprint: Load Balancing Mule for Scalability and Availability

Performance TesTing expertise in case studies a Q & ing T es T

QLIKVIEW SERVER MEMORY MANAGEMENT AND CPU UTILIZATION

Metalogix Replicator for SharePoint

SAP HANA SPS 09 - What s New? Administration & Monitoring

Module 15: Monitoring

SCCM Plug-in User Guide. Version 2.21

Glassfish Architecture.

Crystal Reports Server 2008

CHAPTER 20 TESING WEB APPLICATIONS. Overview

Monitoreando Active Directory usando OpManager

Securely. Mobilize Any Business Application. Rapidly. The Challenge KEY BENEFITS

Microsoft SQL Server: MS Performance Tuning and Optimization Digital

OBSERVEIT DEPLOYMENT SIZING GUIDE

An Oracle White Paper September Advanced Java Diagnostics and Monitoring Without Performance Overhead

Best practices for operational excellence (SharePoint Server 2010)

Introduction to Azure for Developers

Desktop Activity Intelligence

sql server best practice

Microsoft SharePoint Server 2010

DB Audit Expert 3.1. Performance Auditing Add-on Version 1.1 for Microsoft SQL Server 2000 & 2005

Microsoft SharePoint Server 2010

System Requirements Table of contents

Skills for Employment Investment Project (SEIP)

Backup / migration of a Coffalyser.Net database

Mobile Performance Management Tools Prasanna Gawade, Infosys April 2014

Informatica Master Data Management Multi Domain Hub API: Performance and Scalability Diagnostics Checklist

About Me: Brent Ozar. Perfmon and Profiler 101

Response Time Analysis

Virtuozzo Virtualization SDK

Grant Management. System Requirements

TEST REPORT SUMMARY MAY 2010 Symantec Backup Exec 2010: Source deduplication advantages in database server, file server, and mail server scenarios

Server 2008 SQL. Administration in Action ROD COLLEDGE MANNING. Greenwich. (74 w. long.)

DMS Performance Tuning Guide for SQL Server

Transcription:

Code best practices and performance optimization Alf Nilsson Lead System Developer & EMVP

Me? Alf Nilsson Lead Systems Developer ECD - EMVP - MCP

Code best practices and performance optimization What to look at? Tools Distractions Scenarios SessionState Loading Content & EPiServer API Cache Race Condition Locks

Code best practices and performance optimization Tools

Tools DotTrace Monitor CPU & Memory usage Call number and time License cost Other options Visual Studio ANTS Performance Profiler

Tools SQL Server Profiler Monitor database requests and CPU usage Can use lots of resources in production environment

Code best practices and performance optimization Distractions

Distractions Scheduled Jobs Executes code Often complex and heavy Sometimes very frequently Configuration <configuration> <episerver> <applicationsettings enablescheduler= false /> </episerver> </configuration>

Distractions Frontend resources Creates requests to server Requests to Media can cause database traffic

Distractions Frontend resources Creates requests to server Requests to Media can cause database traffic Example of tools LINQPad www.linqpad.net Postman Chrome plugin Create a console application

Code best practices and performance optimization Scenarios

SessionState SessionState Server queues incoming requests to handle session information between requests Enabled by default in.net Practice at NetRelations to disable to increase speed Request 1 Request 2 Request 3 Server

SessionState SessionState MVC [SessionState(SessionStateBehavior.Disabled)] Request 1 WebForms <%@ Page EnableSessionState="false"... %> Request 2 Request 3 Server

? What about the sessions? Do you need them? Save session key into cookie (beware of regional laws) Store information on server Some VisitorGroups and Add-ons use SessionState

Cut to the code

EPiServer API Loading Content & EPiServer API GetChildren GetDescendents + Get GetDescendents + GetItems FindPagesWithCriteria

EPiServer API Loading Content - GetChildren + Easy - Need to iterate and recurse for each child - Very expensive if big page tree!

Cut to the code

EPiServer API Loading Content GetDescendents & Get + Optimized for tree structure - don t need to iterate and recurse - Returns ContentReference and needs to Get content - Expensive if big page tree

Cut to the code

EPiServer API Loading Content GetDescendents & GetItems + Faster than get each content + Use when having multiple ContentReferences - Expensive if big page tree

Cut to the code

EPiServer API Loading Content FindPagesWithCriteria + One database call to find pages + Stored Procedure netpropertysearchvaluemeta + Good in a big tree structure - Does only work with Pages - Does not cache!

Cut to the code

Caching Caching IObjectInstanceCache and ISynchronizedObjectInstanceCache wraps HttpRuntime.Cache ISynchronizedObjectInstanceCache synchronizes in a load balanced environment CacheEvictionPolicy to clear out cache when needed

Caching ISynchronizedObjectInstanceCache var cache = ServiceLocator.Current.GetInstance<ISynchronizedObjectInstanceCache>(); cache.insert(key, value, cacheevictionpolicy); cache.remove(cachekey,value, cacheevictionpolicy); Server 1 Server 2 cachekey cachekey

Caching CacheEvictionPolicy - cachekeys new CacheEvictionPolicy(new string[] { cachekey }); Make cached object dependant on previously cached keys being updated or removed Won t cache if depending key is not already cached cache.insert( cachekey2,x, cache.insert( cachekey1, cache.remove( cachekey1 ); new CacheEvictionPolicy(new x, CacheEvictionPolicy.Empty); [] { cachekey1 })); Server No cachekey1! cachekey1 cachekey2

Caching CacheEvictionPolicy - masterkeys new CacheEvictionPolicy( null, // for files null, // for cachekeys new string[] { masterkey }); Same as cachekeys, but does not require key to already be cached

Cut to the code

Race Condition Locks Race Condition Locks Important when using resources that takes long time and can't handle usages by multiple threads, such as reading or writing files on disk! Locking Mini Locking

Race Condition Locks Race Condition Locks - Simple lock Prevents exceptions and that the system locks because of multiple threads using the same resource Queues threads that want to use locked functionality

Cut to the code

Scenarios Mini Locking If only using a simple lock, threads are locking up even if they don't need to Mini locks are more granular and only queues up threads based on keys

Cut to the code

Code best practices and performance optimization Questions? Judge of a man by his questions rather than by his answers. Voltaire

Code best practices and performance optimization Thanks and have a good Ascend! Alf Nilsson a @alfnilsson @ alf.nilsson@netrelations.com a github.com/alfnilsson http://talk.alfnilsson.se