Asp.net websites from thousands to millions of users
-
Upload
alok-pandey -
Category
Technology
-
view
4.157 -
download
7
description
Transcript of Asp.net websites from thousands to millions of users
![Page 1: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/1.jpg)
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
![Page 2: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/2.jpg)
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
![Page 3: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/3.jpg)
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.
![Page 4: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/4.jpg)
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.
![Page 5: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/5.jpg)
Scaling Problems
Scaling:
Specialization,
Optimization, and
Distribution.
![Page 6: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/6.jpg)
Optimizing the Code
Use profiling tools to analyze your application
Find out where the application is spending the most time
![Page 7: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/7.jpg)
Load Balancing & Affinity
![Page 8: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/8.jpg)
Minimizing Payload & Caching
![Page 9: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/9.jpg)
Scaling Databases
Large-scale Web applications, partition databases into
Readers and
Writers
![Page 10: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/10.jpg)
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.
![Page 11: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/11.jpg)
Facts
http://www.rootusers.com/performance-difference-between-iis-7-5-and-iis-8/
![Page 12: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/12.jpg)
Which one to use
![Page 13: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/13.jpg)
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
![Page 14: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/14.jpg)
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
![Page 15: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/15.jpg)
ProcessModel Optimization
Servers are too powerful.
Change default process model setting in machine.config to make best use of CPU power.
![Page 16: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/16.jpg)
Pipeline Optimization
![Page 17: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/17.jpg)
System.net optimization
Default is 2 per IP
![Page 18: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/18.jpg)
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.
![Page 19: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/19.jpg)
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.
![Page 20: Asp.net websites from thousands to millions of users](https://reader035.fdocuments.in/reader035/viewer/2022062701/553aa58b4a795937168b45af/html5/thumbnails/20.jpg)
Thank You
www.aspnetcommunity.org
AspNetCommunity
ASP.NET,C#/VB.NET Developer/Programmer
Facebook Group Twitter
@AspNetCommunityASP.NET Community