Upload
marina-peregud
View
22
Download
0
Tags:
Embed Size (px)
Citation preview
Спикер:
Тема презентации:
Антон Бойко, Microsoft Azure MVP
Разделяй и властвуй — набор практик
для построения масштабируемого приложения в облаке
Who am I?
Developer• .NET – 10+ years• Node.JS and JavaScript – 3+ years
Cloud engineer• Microsoft Azure – 4+ years• Amazon Web Services – 3+ years
Community leader• Microsoft Azure MVP – 2+ years• Ukrainian Microsoft Azure Community Founder
Consultant• 30+ cloud based projects (from 5 to 5M users) including startups, migration, etc.• 20+ cloud based trainings, workshops, webinars, etc.
Agenda
• Scalability? It is and it isn`t.• Ways of scaling.• Divide and conquer. Divide what and conquer who?• Go into more details with scalability patterns.
Scalability
Scalability is…
• Scalability is the ability of a system, network, or process to handle a growing amount of work in a capable manner or its ability to be enlarged to accommodate that growth.
Scalability story #1 – Gnutella
• When a user wants to do a search, a client sends a request to each actively connected node. In version 0.4 of the protocol, the number of actively connected nodes for a client was quite small (around 5), therefore each node forwarded the request to all its actively connected nodes, and they in turn forwarded the request, and so on, until the packet reached a predetermined number of hops from the sender.
Scalability story #2 – Domain Name System
.
.com.dataart .blog
.ua .in.testing
.teamspark.azureday
.gwab
Scalability is not…
• Performance tuning
Tuning Scaling
Ways of scaling
Vertical scaling
1 CPU4 GB RAM
4 CPU16 GB RAM
X4
Vertical scaling
Pros• Simple and straightforward• Better resources’ utilization
Cons• Usually requires shutdown
(downtime) to scale
Horizontal scaling
1 CPU4 GB RAM
1 CPU4 GB RAM
1 CPU4 GB RAM
1 CPU4 GB RAM
1 CPU4 GB RAM
X4
Horizontal scaling
Pros• Scale without downtime• Improved availability out of the
box
Cons• Your app needs to support
horizontal scaling• Can induce inefficient resources’
utilization
There is no silver bullet
Divide and conquer
Divide application
• Split your app into independent modules which can perform some small and dedicated tasks. For example:• Client• API• Application• Data access
• Do not try to do all tasks at once, you need to eat your elephant piece by piece.• It’s much easier and more transparent to work within simple module
scope than the system scope itself.
Conquer workload
• If you know your enemies and yourself, you will not be imperiled in a hundred battles - Sun Tzu, The Art of War.• Determine whom you are fighting against.• Know your strengths and know your weaknesses.
Anyway… Always use your head!
Divide and conquer story #1 – web site content analyzer
Downloader queue Downloader
Content storage
Analyzer queue
Results storage
Analyzer
APIClient App
1..N
1..N
1..N
Divide and conquer story #2 – Map Reduce
Sheldon: I made tea. Leonard: I don’t want tea. Sheldon: I didn’t make tea for you. This is my tea. Leonard: Then why are you telling me? Sheldon: It’s a conversation starter. Leonard: That’s a lousy conversation starter. Sheldon: Oh, is it? We’re conversing. Checkmate.
HDFS Map Reduce Result
Raw data(line from txt file)
Key and raw data array Key-value pairs
“I made tea.” =>“tea” : “I made tea.”
“tea” : [“…”, “…”, “…”] =>“tea” : “3”
“tea” : “3”“you” : “1”
Scalability patterns
Static content hosting
Web Site
Web SiteWeb Site
Static content hosting CDN
Static content hosting
Pros• Simple and straightforward way
to decrease web server load• Very easy to implement• Bring static content closer to end
users
Cons• Need to wait for TTL to expire on
caching node or need to update caching node explicitly• Can supply content from
different IP address• Can be harder to deploy new
version because of system inconsistency
Worker
Queue-based load leveling
Web Site
Worker
Queue-based load leveling
Web Site
Queue
Worker
Queue-based load leveling
Pros• Easy way to scale independent
atomic tasks
Cons• Can take some time to rearrange
system communication mechanism• Queue is a one-way
communication channel• Queue can increase response
latency
Command and query responsibility segregation
CRUD
Command and query responsibility segregation
Write
Read
Sync
Command and query responsibility segregation
Pros• Provides an ability to manage
writes and reads load separately• Reads can be easily scaled
horizontally
Cons• Can take a lot of time to migrate
from regular CRUD based code• Can easily become
unmanageable and cumbersome
Sharding
CharleyJudithJake
Sharding
Charley Judith Jake
CharleyJudithJake
Sharding
Pros• Can scale data storage almost to
infinity• Can easily manage data load for
different shards
Cons• Impossible to use native queries
to query data among several shards (unless your engine is able to do that)• Cross-shard queries can require
a lot of additional coding• Will introduce additional
redundancy
And again… Always use your head!