PHP and MySQL Architectures
-
Upload
seguy-damien -
Category
Technology
-
view
7.098 -
download
1
description
Transcript of PHP and MySQL Architectures
![Page 1: PHP and MySQL Architectures](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/1.jpg)
PHP/MySQL Architectures November 7th, 2007,
Washington DC, USA
![Page 2: PHP and MySQL Architectures](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/2.jpg)
Who is speaking?Damien Seguy
Expert services for Nexen Services
Statistics provider (and ISP killer)
Phather of thousands of elePHPants
![Page 3: PHP and MySQL Architectures](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/3.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/4.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/5.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/6.jpg)
Two opposing strategies
Scale outScale up
![Page 7: PHP and MySQL Architectures](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/7.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/8.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/9.jpg)
Web servers farms
Balancer :Proxy, load
![Page 10: PHP and MySQL Architectures](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/10.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/11.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/12.jpg)
Database problems
Read Writing Catch
Replication Yes No Lag
Partitions No Yes Application
Cluster Yes Yes Management
![Page 13: PHP and MySQL Architectures](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/13.jpg)
Replication
Writing
Reading
![Page 14: PHP and MySQL Architectures](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/14.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/15.jpg)
Replication : the writesInitial
Idle
Read
Write
Master Slave1 Slave2
![Page 16: PHP and MySQL Architectures](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/16.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/17.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/18.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/19.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/20.jpg)
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](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/21.jpg)
Cluster
ManagementSQL
Storage
![Page 22: PHP and MySQL Architectures](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/22.jpg)
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 23: PHP and MySQL Architectures](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/23.jpg)
Questions?http://www.nexen.net/conferences.php
![Page 24: PHP and MySQL Architectures](https://reader034.fdocuments.in/reader034/viewer/2022052410/54b793894a795953368b473a/html5/thumbnails/24.jpg)
Elements graphiques