57

Appserver & DBServer Database Server App Server Throw more RAM and CPU

Embed Size (px)

Citation preview

Best Practices for Scaling Web AppsChander Dhall

DEV-B318

EM OFC WIN DBI

CDP TWC DEV AZR

Following this session at 18:30

in Hall 5Meet with Microsoft Product ExpertsSnacks and Beverages Served

Ask The Experts Key and floorplan

Cloud and Datacenter Platform

Data Platform and Business Intelligence

Developer Platform and Tools

Enterprise Mobility

Office 365

Windows

Microsoft Azure

Trustworthy Computing

AgendaWhy is it important to scale? Creating a scalable solution (in incremental steps)While (Not Fixed) {Propose an ArchitectureIdentify Failures and BottlenecksIdentify DowntimeApply a better solution

}

Why?

Amazon claim – Just an extra 1/10th of a second on their response times will cost them 1% in sales.Google – ½ a second increase in latency caused traffic to drop by a fifth.

Why is Scalability Important

The website was working great UNTIL we launched

Instagram was down the day they launched it

ConceptsScalability - Number of users / sessions / transactions / operations the entire system can handle

Performance – Optimal utilization of resources

Responsiveness – Time taken per operation

Availability – Probability of the application being available at any given point in time

Downtime Impact - The impact of a downtime of a server/service/resource - number of users, type of impact etc

Section 1: CAP

Chander Dhall

Brewer’s CAP Theorem

Consistency (or more appropriately Atomic)AvailabilityPartition Tolerance

“No set of failures less than total network failure is allowed to cause the system to respond incorrectly” – Gilbert & Lynch

Fallacies of Distributed Computing

Network is reliable. Latency is zero. Bandwidth is infinite. Network is secure. Topology doesn’t change. There is one administrator.

Fallacies of Distributed ComputingTransport cost is zero. Network is homogenous.

Section 2: Failed ArchitectureChander Dhall

Getting StartedAppserver & DBServer

Database ServerApp Server

Next Gen – Vertical Scaling

Appserver & DBServer

Database Server

App Server

Throw more RAM and CPU

Vertical Partitioning (Services)

App Server

Db Server

Horizontal ScalingLoad Balancer

DB Server

Unfortunate Solution

Load Balancer

S ServicesS S S S

Web Web Web

Database

Section 3: Less Scalable SolutionChander Dhall

Sticky Sessions

Load Balancer

User 1

Central Session Store

Load Balancer

Session Store

APP

SERVER

Clustered Session Management

Load Balancer

Load Balanced App Server Cluster

Load Balancer

Users

Load Balancer

Vertical Partitioning (Hardware)Load Balancer Load Balancer

DB Server SAN

Horizontal Scaling (DB)

Load Balancer Load Balancer

DB Server SAN

Horizontal Scaling (DB)

Load Balancer Load Balancer

DB Server SANDB Server DB Server

DB Replica

Vertical / Horizontal Partitioning (DB)

Load Balancer Load Balancer

DB Server SANDB Server DB Server

DB Cluster

Vertical / Horizontal Partitioning (DB)

App Cluster

Db Cluster 1 Db Cluster 2Twitter Table

Facebook Table

Users Table

Products Table

Vertical Partitioning

Vertical / Horizontal Partitioning (DB)

App Cluster

Db Cluster 1 Db Cluster 2Twitter Table

Facebook Table

Twitter Table

Facebook Table

Horizontal Partitioning

0-1 Million Users 1-2 Million Users

Step 7 – Vertical / Horizontal Partitioning (DB)

Load Balancer

DB

DB ClusterDB DB DB DB DB

DB Cluster

Hash Map

SAN

Separating Sets

Load Balancer Load Balancer

DB DB DB

DB Cluster

Hash Map

DB DB DB

DB Cluster

Load Balancer Load Balancer

DB DB DB

DB Cluster

Hash Map

DB DB DB

DB Cluster

Set 1-10 Million Users Set 11-20 Million Users

Global Redirector

Global Look up Hash

Map

Caching

Add caches within App ServerObject CacheSession CacheAPI cachePage cache

SoftwareMemcachedRedis Azure Cache (App Fabric)

HTTP AcceleratorA good HTTP Accelerator / Reverse proxy performs the following –

Redirect static content requests to a lighter HTTP server (lighttpd)Cache content based on rules Use Async Non blocking IO Maintain a limited pool of Keep-alive connections to the App ServerIntelligent load balancing

More Important StuffCDNsIP AnycastingAsync Nonblocking IO (for all Network Servers)If possible - Async Nonblocking IO for diskIncorporate multi-layer caching strategy where required

L1 cache – in-process with App ServerL2 cache – across network boundaryL3 cache – on disk

Grid computing

Demo

Section 4: Finalizing using Polyglot PersistenceChander Dhall

NoSql Vs Relational

0 2000 4000 6000 8000 10000 12000 14000 160000

2000

4000

6000

8000

10000

12000

14000

Key Value

Mem-cached

Relational Data-bases

Doc-umen

t Databases

Depth of Functionality Sca

labili

ty a

nd P

erf

orm

ance

FinalizingLoad Balancer

DB

DB

DB

DB Cluster

Hash

Map

DB

DB

DB

DB ClusterMaste

r

Slave Slave

SANDocument/Graph No Sql

Master

Slave Slave

Search Db

Caching Offline

processing/Queuing

Load Balancer

4. Using No-Sql in the right way

NoSql Paradigm - Atomic Aggregates

AccountIdAccount No.

CheckingIdMin bal

SavingsIdInterest rate

Account{“Type”: “Checking”, “Id”: “chk123”,“Min Bal”:”10000”,}

Account{“Type”: “Savings”, “Id”: “sav123”,“Interest Rate”:”5%”,}

No sql paradigm – Index tableEmployee Id

Details

1234 Email: [email protected]; State: CA; Dept: IT

8235 Email: [email protected]; State: TX; Dept: Sales

2234 Email: [email protected]; State: AL; Dept: IT

1671 Email: [email protected]; State: WA; Dept: SalesStat

eEmployee Id

CA 1234, 1235, 1236, 1244

TX 8000, 8100, 8235, 8266

AL 2212, 2221, 2234, 2256

Dept Employee Id

IT 1234, 1235, 1236, 1244

Sales 8000, 8100, 8235, 8266

Acc 2212, 2221, 2234, 2256

No sql paradigm – Tree Index

Country - USA

State - CA

City - LA

Properties

Facilities

{“property”: [{ “facilityName”: abc”, “facilityId”:”111”},{“facilityName”:”xyz” , “facilityId”:”222”}]}

No sql paradigm – Composite Key

Dept= IT:* orDept= Sales:Online:*

IT: Software: 1123

EmpName: John; Address: Los Angeles IT: Software: 2323

EmpName: Kevin; Address: Dallas, TX IT: Hardware: 6767

EmpName: Matt; Address: San FranciscoSales: Online:

832EmpName: Katie: Address: Austin, Tx

Sales : Online: 423

EmpName: Karen: Address: Irvine, CASales : Store : 556

EmpName: Richard; Address: San Diego

ITEmployees

SalesEmployees

EMPLOYEES

No sql paradigm - Grouping

U123: O111 Product Ids: [“Surface”, “xbox”]

U124:O123 Product Ids: [“Win 8”, “xbox”]

U124:O234 Product Ids: [“Win phone”, “surface”]

U124:O999 Product Ids: [“office”, “azure sub”]

U125:O789 Product Ids: [“msdn”, “office”]

U125:O945 Product Ids: [“surface”, “xbox”]

Colocation of a users’ data.

Inverted search & direct aggregation

EmpId, dept, city, …….

Dept-IT: [111, 123, 234….]Dept-Sales:[673, 343, 434….]

City: Dallas

City: LA

111: Dept-Sales, City: LA …222: Dept-IT, City: Dallas ….

No sql paradigm – Materialized paths

Electronics

TV Phones Computers Cameras

Samsung Apple LG

LCD LED

No sql paradigm – Materialized paths

TV

Samsung Apple LG

LCD LED

{ “entity”: “TV”, “category”:”Electronics”}

{ “entity”: “Samsung”, “category”:”Electronics, TV”}

{ “entity”: “Samsung”, “category”:”Electronics, TV, LCD”}

No sql paradigm – Nested sets

Electronics

TV Phones

Samsung Sony Cell Landline1 2 3 4 5 6 7 8 9 10 11 12 13 14

No sql paradigm – Nested sets

1 2 3 4 5 6 7 8 9 10 11 12 13 14

Sony Samsung

TV

LandlineCell

Phone

Electronics

Flattening nested documents

Name: Chander

Hadoop: Expert

Nodejs: Expert

Spanish: Novice

{“name”:”chander”,“skills”:”hadoop, nodejs, Spanish”, “level”:”expert, expert, novice”}

Skills:hadoop AND level:expert

Flattening nested documents

Name: Chander

Hadoop: Expert

Nodejs: Expert

Spanish: Novice

{“name”:”chander”,“skills_1”:”hadoop”,“skills_2”: “nodejs”,“skills_3”: “spanish”, “level_1”:”expert”,“level_2”: “expert”,“level_3”: “novice”}

References http://www.couchbase.com/why-nosql/nosql-databaseHighly scalable blog. http://redis.io/http://Cassandra.apache.orghttp://elasticsearch.orghttp://memcached.org/Building Scalable Architecture

CDP-B235 Architecting Globally Available and Scalable Solutions on Microsoft Azure: An End-to-End View

Related content

Labs (session codes and titles)

Microsoft Solutions Experience Location (MSE)

Find Me Later At. . . Ask the Experts, Hall 5 (6:30-8pm)

Resources

Learning

Microsoft Certification & Training Resources

www.microsoft.com/learning

Developer Network

http://developer.microsoft.com

TechNet

Resources for IT Professionals

http://microsoft.com/technet

Sessions on Demand

http://channel9.msdn.com/Events/TechEd

http://www.visualstudio.com

http://blogs.msdn.com/b/developer-tools/

http://msdn.microsoft.com/vstudio

DEV Track Resources

visualstudio

@visualstudio

visualstudio

EM OFC WIN DBI

CDP TWC DEV AZR

Following this session at 18:30

in Hall 5Meet with Microsoft Product ExpertsSnacks and Beverages Served

Ask The Experts Key and floorplan

Cloud and Datacenter Platform

Data Platform and Business Intelligence

Developer Platform and Tools

Enterprise Mobility

Office 365

Windows

Microsoft Azure

Trustworthy Computing

TechEd Mobile app for session evaluations is currently offline

SUBMIT YOUR TECHED EVALUATIONSFill out an evaluation via

CommNet Station/PC: Schedule Builder

LogIn: europe.msteched.com/catalog

We value your feedback!

© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.