asp.net websites from thousands to millions of users

Post on 24-Apr-2015

4.159 Views

Category:

Technology

7 Downloads

Preview:

Click to see full reader

DESCRIPTION

Asp.net websites from thousands to millions of users

TRANSCRIPT

Alok Kumar Pandey

Active Contributor - AspNetCommunity

Director, Strategic Product Development at Braindigit IT Solution

.NETLearning

ASP.NET Websites From Thousands to Millions of Users

facebook.com/alokgo

Facebook Twitter

@alokpandey01

Scaling Strategies for ASP.NET Applications

The Performance Equation

Scaling Problems

Optimizing the Code

Load Balancing & Affinity

Minimizing Payload & Caching

Scaling Databases

The Endless Scaling Effort

A Fact

.NET 3.0/4.0/4.5 was released, woohoo!

WCF!

Lambda Expressions!!

LINQ to SQL!!!, PLINQ ….

Upgraded to .NET 3.0/4.0/4.5...

Major deployment over the weekend.

Monday 9 AM, peak traffic.

No response from site.

The Performance Equation

The Original Performance Equation

The Web Version of the Performance Equation

• R => Response time.• Payload => Total bytes sent to the browser• Bandwidth => Rate of transfer to and from the browser. • AppTurns => The number of resource files a given page needs. • RTT => The time it takes to round-trip• Concurrent Requests => Number of simultaneous requests • Cs => Compute time on the server. • Cc => Compute time on the client.

Scaling Problems

Scaling:

Specialization,

Optimization, and

Distribution.

Optimizing the Code

Use profiling tools to analyze your application

Find out where the application is spending the most time

Load Balancing & Affinity

Minimizing Payload & Caching

Scaling Databases

Large-scale Web applications, partition databases into

Readers and

Writers

The Endless Scaling Effort

As application continues to grow, efforts to scale it are going to continue to grow as well.

Use testing to be sure spending effort where it's needed.

Test work to be sure that actually made an improvement, not just a change.

Facts

http://www.rootusers.com/performance-difference-between-iis-7-5-and-iis-8/

Which one to use

Speed of Common Operationsadd to end

remove from end

insert at middle

remove from middle

Random Access

In-order Access

Search for specific element

Notes

Array O(n) O(n) O(n) O(n) O(1) O(1) O(n)Most efficient use of memory; use in cases where data size is fixed.

List<T>best case O(1); worst case O(n)

O(1) O(n) O(n) O(1) O(1) O(n)Implementation is optimized for speed. In many cases, List will be the best choice.

Collection<T>best case O(1); worst case O(n)

O(1) O(n) O(n) O(1) O(1) O(n)List is a better choice, unless publicly exposed as API.

LinkedList<T> O(1) O(1) O(1) O(1) O(n) O(1) O(n)Many operations are fast, but watch out for cache coherency.

Stack<T>best case O(1); worst case O(n)

O(1) N/A N/A N/A N/A N/AShouldn't be selected for performance reasons, but algorithmic ones.

Queue<T>best case O(1); worst case O(n)

O(1) N/A N/A N/A N/A N/AShouldn't be selected for performance reasons, but algorithmic ones.

Dictionary<K,T>best case O(1); worst case O(n)

O(1)best case O(1); worst case O(n)

O(1) O(1)* O(1)* O(1)

Although in-order access time is constant time, it is usually slower than other structures due to the over-head of looking up the key.

http://www.dotnetcurry.com/ShowArticle.aspx?ID=190

Run this on desktops

for (int i = 0; i < 500; i ++){ for (int j = 0; j < 500; j ++) { var client = new WebClient(); client.DownloadStringAsync(new Uri("http://www.mydomain.com/page.aspx"); } Thread.Sleep(500);}

Prevent App Level DOS attack

ProcessModel Optimization

Servers are too powerful.

Change default process model setting in machine.config to make best use of CPU power.

Pipeline Optimization

System.net optimization

Default is 2 per IP

Content Delivery Network (CDN)

Content from CDN nodes get served faster with lower latency than coming from real servers.

CDN Nodes have better caching and compression algorithms.

CDN nodes can offload server and network from delivering static files. Thus better throughput for dynamic content.

Moral of the Story

ASP.NET out of the box, does not scale for millions of hits.

Must make the hacks at code, database and configuration level to get it to scale.

That’s reality for any technology, not only ASP.NET specific.

Thank You

www.aspnetcommunity.org

AspNetCommunity

ASP.NET,C#/VB.NET Developer/Programmer

LinkedIn

Facebook Group Twitter

@AspNetCommunityASP.NET Community

Facebook

top related