Download - Scalable Web Architecture
![Page 1: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/1.jpg)
Scalable web architectureLAMP (& AWS infrastructure)
Aleksandr Tsertkov
![Page 2: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/2.jpg)
LAMP
![Page 3: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/3.jpg)
LAMP: Platform
L - Linux / Unix
A - Apache / lighthttpd / nginx
M- MySQL / PostgreSQL / SQLite
P - PHP / Python / Perl / Ruby
![Page 4: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/4.jpg)
LAMP: Why LAMP
– We know it!– Proved by very big guys (Facebook,
YouTube, LiveJournal, etc)– Plenty of shared experience on the web– Its flexible and extendable– Easy to find engineers– Easy to maintain– Its cheap
![Page 5: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/5.jpg)
LAMP: Who use it
Let’s take top 10 Internet sites according to Alexa.
• Yahoo!
• YouTube
• Windows Live
• MSN
• Wikipedia
• Blogger
• Baidu
• Yahoo! Yapan
Who use LAMP? 5 of 10
![Page 6: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/6.jpg)
System design (SD)
![Page 7: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/7.jpg)
SD: Key points
• Scalability
• HA (High Availibility)– Backup & restore strategy!!!
• Fault-tolerant
• SA (Share Nothing)
![Page 8: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/8.jpg)
SD: Load scalability
“ Load scalability: The ability for a distributed system to easily expand and contract its resource pool to accommodate heavier or lighter loads. ”
-Wikipedia
![Page 9: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/9.jpg)
SD: Horizontal scalability
Adding new nodes to a system for handling growing load and removing nodes when load decreases.
![Page 10: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/10.jpg)
SD: High Availibility
Complex: High availability is a system design protocol and associated implementation that ensures a certain absolute degree of operational continuity during a given measurement period.
Simple: maximum uptime, minimum downtime.
![Page 11: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/11.jpg)
SD: Fault Tolerant
System should be able to continue function normally even if some of its components fail.
No single point of failure.
![Page 12: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/12.jpg)
SD: Share Nothing
“ A shared nothing architecture (SN) is a distributed computing architecture in which each node is independent and self-sufficient, and there is no single point of contention across the system. “
- Wikipedia
![Page 13: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/13.jpg)
SD: Share Nothing
Can be achieved on different application layers separately:
• Database: data partitioning / sharding
• Cache: memcache client side partitioning
• Computing: job queues
![Page 14: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/14.jpg)
SD: Typical web architecture
• Load balancer
• Several web servers
• Database server(s)
• Shared file server (NAS) (if really needed)
![Page 15: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/15.jpg)
SD: Typical web architecture
Database server
Web server-1
Web server-2
Web server-n
Load balancer (LB)
File server
![Page 16: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/16.jpg)
SD: Typical web architecture
• Each of these components / layers can be scaled separately.
• Database is usually the toughest part to scale.
![Page 17: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/17.jpg)
SD: Scaling database
Master-Slave Replication variants:
1. Read/Write queries to Master, Read only from Slaves
2. Writes to Master, Reads only from Slaves
![Page 18: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/18.jpg)
SD: Scaling database
Master should be very powerful machine, but sooner or later you will hit the IO limit.
Data partitioning / sharding is used to distribute data across number of Masters spreading load between them (horizontal scaling).
![Page 19: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/19.jpg)
SD: Scaling database
Common data(master)
Slave-1
Slave-n
Partition-1(master)
Slave-1
Slave-n
Partition-n(master)
Slave-1
Slave-n
User-AUser-BUser-C
User-DUser-EUser-F
![Page 20: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/20.jpg)
SD: Caching strategy
Hierarchy of caches should be used for optimal performance and efficiency.
Local memory -> memcached -> local disk
![Page 21: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/21.jpg)
SD: Caching hierarchy
• App server local in memory cache for highly common items (speedup scripts bootstrapping)
• Distributed cache system (memcached) for caching database queries and general purpose cache
• App server file cache for big size items
![Page 22: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/22.jpg)
SD: High-CPU app servers
For High-CPU computing operations like audio/video processing dedicated application servers should be used.
Good control over them can be achieved using job queue.
Video: check YouTube Platform ;-)
![Page 23: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/23.jpg)
SD: Web servers optimization
• General web servers (apache)
• COMET web servers
• Static content web servers
• Content Delivery Network (CDN) should be used for static public content.
![Page 24: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/24.jpg)
SD: Static files strategy
• Network attached storage (NAS)– Distributed network file system (Lustre,
GlusterFS, MogileFS)– Not distributed (NFS)
• Fault-tolerance and data redundancy are required!
![Page 25: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/25.jpg)
SD: Static files strategy
• Distributed filesystem is complex but in a perfect world it should give us what we need: performance, redundancy, fault-tolerance.
• Static content web servers can run on DF nodes!
![Page 26: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/26.jpg)
SD: Load balancers
• Software or hardware load balancers
• Traffic distributed between several load balancers using round robin DNS
• HA solution for load balancers
![Page 27: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/27.jpg)
SD: Complete picture
![Page 28: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/28.jpg)
Amazon Web Services
![Page 29: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/29.jpg)
AWS: What is AWS?
• Amazon is not only about books • Amazon Web Services provide
infrastructure web services platform in the cloud.
![Page 30: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/30.jpg)
AWS: Why AWS?
• Because it has everything what we need:– EC2: Elastic Compute Cloud
• EBS: Elastic Block Store• CloudWatch: monitoring service with auto scaling• Elastic Load Balancing
– S3: Simple Storage Service– Cloud front (CDN)– SQS: Simple Queue Service
![Page 31: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/31.jpg)
AWS: EC2
• Easy to deploy (os images)• Easy to scale up and down on demand
(deals with peaks) with Auto Scaling• Out of the box monitoring with
CloudWatch• Out of the box load balancing with Elastic
Load Balancinghttp://aws.amazon.com/loadbalancing
![Page 32: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/32.jpg)
AWS: S3 & CloudFront
• Out of the box CDN with CloudFront
• DFS (sort of) with S3
• Very reliable
![Page 33: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/33.jpg)
AWS: Services on top of AWS
Some like AWS so much that they have created own cloud services on top of it
• RightScale www.rightscale.com
• GoGrid www.gogrid.com
![Page 34: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/34.jpg)
AWS: Panacea?
• AWS is indeed good to start with since its fast and cheap.
• In a long time term if everything goes as expected and profit increases it might be better to build own cloud infrastructure and migrate to it at some point.
![Page 35: Scalable Web Architecture](https://reader033.vdocument.in/reader033/viewer/2022061105/5441e375afaf9f56208b47c5/html5/thumbnails/35.jpg)
Thank you!