35
Scalable web architecture LAMP (& AWS infrastructure) Aleksandr Tsertkov

Scalable Web Architecture

  • View
    12.663

  • Download
    2

Embed Size (px)

DESCRIPTION

Scalable Web Architecture: LAMP, AWS, S3, CloudFront, EC2, caching strategy, scaling database, hight availibility, fault tolerant, horizontal scalability

Citation preview

Page 1: Scalable Web Architecture

Scalable web architectureLAMP (& AWS infrastructure)

Aleksandr Tsertkov

Page 2: Scalable Web Architecture

LAMP

Page 3: Scalable Web Architecture

LAMP: Platform

L - Linux / Unix

A - Apache / lighthttpd / nginx

M- MySQL / PostgreSQL / SQLite

P - PHP / Python / Perl / Ruby

Page 4: Scalable Web Architecture

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

LAMP: Who use it

Let’s take top 10 Internet sites according to Alexa.

• Google

• Yahoo!

• YouTube

• Facebook

• Windows Live

• MSN

• Wikipedia

• Blogger

• Baidu

• Yahoo! Yapan

Who use LAMP? 5 of 10

Page 6: Scalable Web Architecture

System design (SD)

Page 7: Scalable Web Architecture

SD: Key points

• Scalability

• HA (High Availibility)– Backup & restore strategy!!!

• Fault-tolerant

• SA (Share Nothing)

Page 8: Scalable Web Architecture

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

SD: Horizontal scalability

Adding new nodes to a system for handling growing load and removing nodes when load decreases.

Page 10: Scalable Web Architecture

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

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

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

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

SD: Typical web architecture

• Load balancer

• Several web servers

• Database server(s)

• Shared file server (NAS) (if really needed)

Page 15: Scalable Web Architecture

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

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

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

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

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

SD: Caching strategy

Hierarchy of caches should be used for optimal performance and efficiency.

Local memory -> memcached -> local disk

Page 21: Scalable Web Architecture

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

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

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

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

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

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

SD: Complete picture

Page 28: Scalable Web Architecture

Amazon Web Services

Page 29: Scalable Web Architecture

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

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

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

AWS: S3 & CloudFront

• Out of the box CDN with CloudFront

• DFS (sort of) with S3

• Very reliable

Page 33: Scalable Web Architecture

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

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

Thank you!