+ All Categories
Home > Technology > PHP and MySQL Architectures

PHP and MySQL Architectures

Date post: 15-Jan-2015
Category:
Upload: seguy-damien
View: 7,093 times
Download: 1 times
Share this document with a friend
Description:
Web applications requires robust PHP and MySQL architectures. This may be for high availability, for sheer performances, or even both. Yet, there is always the nagging question of doing so in an economically viable way. Architecture is not black magic : coming right from the mission goal, it will take most of the load and still look nice in the accounting tables. During this session, we'll study a number of architectures solutions available to modern PHP architects, and discuss about their impact on availability, performances, PHP programmation, MySQL organization and econometrics.
Popular Tags:
24
PHP/MySQL Architectures November 7th, 2007, Washington DC, USA
Transcript
Page 1: PHP and MySQL Architectures

PHP/MySQL Architectures November 7th, 2007,

Washington DC, USA

Page 2: PHP and MySQL Architectures

Who is speaking?Damien Seguy

Expert services for Nexen Services

Statistics provider (and ISP killer)

Phather of thousands of elePHPants

[email protected]

Page 3: PHP and MySQL Architectures

ArchitectureUp to two servers is quite obvious

Organize PHP/MySQL application to go beyond 2 servers

How one can add more servers then?

Keep going up in scale and size

Page 4: PHP and MySQL Architectures

What is your problem?

Too much to process?

Too much traffic?

Too much data?

Too much reads?

Too much writes?

Page 5: PHP and MySQL Architectures

Architecture criteriaPerformances

Fast to answer

High availability (HA)

Always accessible, even slowly

Evolutivity

Going up, going down

Marginal cost of adding one server

Page 6: PHP and MySQL Architectures

Two opposing strategies

Scale outScale up

Page 7: PHP and MySQL Architectures

Scale up'Mine is bigger' Syndrom

Really expensive

To buy

To keep up

Less impact on PHP code

Actually solve problems

Temporarily

No way to go back, or just a little

Page 8: PHP and MySQL Architectures

Scale outThe Farming syndrom

Cheap to reasonnable

Easier to evolve one piece a time

Significant impact on PHP code

The virtualization buzz

Automate your installations

puppet, Phing, Pear channels,

Page 9: PHP and MySQL Architectures

Web servers farms

Balancer :Proxy, load

Page 10: PHP and MySQL Architectures

Web servers farmsLots of work for PHP

Dispatching, personnalization, tracking

Solutions

Export static to a CDN

Akamaï, Amazon S3, Youtube,

Caches, caches, caches

HTML, data, SQL, PHP,

Use the 'Share nothing' strategy

Page 11: PHP and MySQL Architectures

Web servers farmsDon't tie yourselves to servers

When you need to share : sessions

Session via NFS

Session in a filer

Session in the database

Zend platform

Sessions in memcache

Page 12: PHP and MySQL Architectures

Database problems

Read Writing Catch

Replication Yes No Lag

Partitions No Yes Application

Cluster Yes Yes Management

Page 13: PHP and MySQL Architectures

Replication

Writing

Reading

Page 14: PHP and MySQL Architectures

ReplicationIdeal for backup or reports

Works great to spread the load geographically

Excellent for web applications

Lots of read, less writes

Easy to set up and on budget

Page 15: PHP and MySQL Architectures

Replication : the writesInitial

Idle

Read

Write

Master Slave1 Slave2

Page 16: PHP and MySQL Architectures

ReplicationLimited by writing

Master is idle

Slaves are overworked

Master is SPOF

Master fails, world crumble

Persistant problem of lag

Will slaves ever catch up?

The chore of resynching.

Page 17: PHP and MySQL Architectures

Replication strategiesSynchrone replication from Google

Ensure queries are also on the slaves

Send writing to master, reading to slaves

Share tables on different servers

Avoid round trip for fast info

What kind of lag can you accept?

Page 18: PHP and MySQL Architectures

PartitionsSlice your data on several servers

MySQL 5.1 has partitions

Start early by splitting your tables

Then put those tables on two servers.

Allow extra storage capacity

Raise the writing performances

Reduce size of each tables

Easy on budget

Page 19: PHP and MySQL Architectures

PartitionsMake every group command a chore

No GROUP BY, no UNIQUE

The key is the partition strategy

Bills : by dates

Users : by accounts, by group?

Need yellow pages to know where is what

Huge impact on the PHP application

Need for consistent admin scripts

Page 20: PHP and MySQL Architectures

Partitions + replication : shardMaster-master replication

Writing goes to both servers

Easy to set up and configure

High availability

No waste of ressources

Handles reads and insert

BUT subtle delete and update

Page 21: PHP and MySQL Architectures

Cluster

ManagementSQL

Storage

Page 22: PHP and MySQL Architectures

ClusterUseless below four machines

Individual performances start lower

Then, they don't change much

NDB is not InnoDB nor MyISAM

Still difficult to configure

This is the way to go

Page 24: PHP and MySQL Architectures

Elements graphiques


Recommended