• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Building Scalable .NET Web Applications
 

Building Scalable .NET Web Applications

on

  • 12,175 views

 

Statistics

Views

Total Views
12,175
Views on SlideShare
9,767
Embed Views
2,408

Actions

Likes
4
Downloads
178
Comments
0

9 Embeds 2,408

http://www.buunguyen.net 2285
http://buunguyen.net 77
http://www.slideshare.net 25
http://sotayblog.com 6
http://cs-nqa.kms.com.vn 4
http://webcache.googleusercontent.com 4
http://www.techgig.com 4
http://hrm.kms-technology.com 2
http://translate.googleusercontent.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Building Scalable .NET Web Applications Building Scalable .NET Web Applications Presentation Transcript

    • Building Scalable .NET Web Applications
      Buu Nguyen, MVP (ASP.NET)
      www.buunguyen.net/blog
      buunguyen@kms-technology.com
      Microsoft Confidential
      1
    • Agenda
      Scalability
      Scaling Web Client Tier
      Scaling Web & Application Server Tiers
      Scaling Database Tier
    • Scalability
    • Scalability
      A system is scalable when it can accommodate more loads and larger data set by increasing hardware power
      Scalability implies performance but not the other way around
    • Vertical Scaling vs. Horizontal Scaling
      http://www.ourofficebox.co.uk/Images/scalability2%20750.png
      http://www.gigaspaces.com/files/pics/online_gaming_scalability_diagram_website.jpg
    • Don't Underestimate Vertical Scaling
      StackOverflow.com
      1M page views per day
      500K questions and millions of posts
      817th largest site
      Hardware
      2 web servers (1 Xeon 4-core processor, 8GB RAM)
      1 database server (2 Xeon 4-core processors, 48GB RAM)
      Software
      IIS 7.5 on Windows Server 2008 R2
      HAProxy (inside Linux VM)
      SQL Server 2008 Enterprise
      ASP.NET MVC and .NET 3.5
      Source: http://www.microsoft.com/casestudies/Case_Study_Detail.aspx?casestudyid=4000006676
      Microsoft Confidential
      6
    • Scaling Web Client Tier
    • Client Resource Management
      Minify and Gzip JavaScript, CSS
      MS Ajax Minifier, YUI Compressor, Google Closure Compiler
      Combine JavaScript and CSS
      MS Script Loader
      CSS on top
      JavaScript at bottom
      Add Expires headers for all resources
    • Combres
      Currently 2.0, Apache license
      http://combres.codeplex.com/
      Key Features
      Combine, compress, minify, cache (server & client) JavaScript and CSS resources
      Automatic change detection
      Extensible architecture
      User Guide
      http://www.codeproject.com/KB/aspnet/combres2.aspx
      Microsoft Confidential
      9
    • JavaScript & Ajax Optimization
      Reverse-Ajax (Comet) instead of polling
      Use dedicated Comet server
      Examples: StreamHub, Meteor
      http://cometdaily.com/maturity.html
      Yield to timer by chunking processing
      Avoid outer-scope lookup
      Split initial payload (i.e. before onload)
      Employ non-blocking JS loading techniques
      MS Ajax Library Script Loader, YUI Script Loader
    • Scaling Web and Application Server Tiers
    • Load Balancing
      The act of properly distribute workload across machines/resources in a cluster
      Approaches
      DNS’ “A” records
      Poor man’s hand-coded redirection
      Software, e.g. HAProxy, NLB, LVS
      Hardware, e.g. F5
      Considerations
      Session state
      View state
    • Domain Sharding
      Partition resources across different hosts
      By type, e.g. static/dynamic, JS/CSS etc.
      By functionality, e.g. forum module
      Benefits
      Balance loads
      Parallel downloads
      Avoid redundant cookies
      Isolated optimization
    • Content Delivery Network (CDN)
      Services
      Microsoft, Google, Akamai etc.
      Static resources only
      Benefits
      As domain sharding
      Redundancy and availability
      Smart DNS routing
      High chance of browser cache hit
    • Distributed Cache
      Enable persistent cache for a server cluster
      Fast (in-memory)
      Distributed – ignorant by clients
      Solutions
      AppFabric Cache (Velocity)
      Support POCO, XML, binary
      ASP.NET integration
      Extensible cache provider
      Others: memcached
    • Concurrency
      It’s a waste of cores if you don’t have enough threads
      Solutions
      Parallel Task Library (PTL)
      PLINQ
      F#
    • Others
      Compensation over distributed transactions
      Asynchronous over synchronous services
      Related: asynchronous controller in MVC 2.0
    • Side Notes on Entity Framework
      Singleton ObjectContext doesn’t fit web apps
      Not thread-safe
      Consume RAM
      Might fit rich client
      One OC per request is the common strategy for web apps
      Use compiled query to reuse generated EF command tree
    • Scaling Database Tier
    • Indexes
      Clustered vs. non-clustered indexes
      Guidelines
      Indexing columns in WHERE and SELECT
      Indexing columns with highly unique values
      Cluster-indexing primary keys
      Avoid over-indexing
    • Replication
      Publisher-subscribers configuration
      i.e. master-slave in MySQL
      Write to subscribers won’t propagate back
      Common options
      Transactional (near real-time)
      Snapshot (time interval)
      Suitable for read-intensive applications
    • …Replication
      Peer-2-peer configuration
      i.e. master-master in MySQL
      Issues
      Identity conflicts
      No “true” copy at any point of time
      High network latency
    • Partitioning
      Vertical Partitioning (Clustering)
      Horizontal Partitioning (Sharding)
      Distribute tables into multiple DBs, each representing a cluster of related tables, e.g.
      Customer DB, product DB, forum DB etc.
      Application layer aggregates data
      Distribute table rows into logical groups, e.g.
      US customers, European customers
      Application layer picks shards & aggregates data
    • NoSQL
      Partitioning makes relational databases not so relational any more
      Complexity in DB design & application layer
      NoSQL, “not-only-relational”, is about DBs built with scalability in mind
      Sacrifice integrity & ACID to a certain extent
      Apache Cassandra
      Auto load balancing
      Identical nodes
      Elastic capacity
      Flexible schema
      Others: MongoDB, Voldermort, Tokyo Cabinet