!"#$%&#'()*#+(,-.$/#+*0#,-$1#-2
! " "
Scaling a Web Application (mostly PHP/MySQL and almost mostly harmless)
Duleepa “Dups” Wijayawardhana MySQL Community Team
Scaling a Web Application (mostly PHP/MySQL and almost mostly - - PowerPoint PPT Presentation
Scaling a Web Application (mostly PHP/MySQL and almost mostly harmless) Duleepa Dups Wijayawardhana MySQL Community Team " " ! !"#$%&#'()*#+(,-.$/#+*0#,-$1#-2 Who the hell am I? PHP/MySQL Developer since the
!"#$%&#'()*#+(,-.$/#+*0#,-$1#-2
! " "
Duleepa “Dups” Wijayawardhana MySQL Community Team
century :)
North America
2001-2007
PHP Expert MySQL Expert ME
problems?
tutorials didn’t seem fun?
server is even up right now and whether they even have a job after this finishes?
unprepared, system down.
methods to succeed.
alive, incl. technologies from LiveJournal.
to phone in on St. Patrick’s Day and you run the site on a $5/month hosted web service and some New York magazine picks it up as a story...
needing to withstand a hurricane.
coast of Louisiana
preparing to slashdot you)
Hurricane in real life?
Hurricane in real life?
your weak points
security nightmare
scaling plan is wrong
Response Times
success!
engineers.
systems, you are about to be in for a world of pain.
point at which a user clicks the browser to when they receive the page on their screen.
about the customer!
Do for each system with low, medium, high, super- high loads.
servers enough, medium, 4, high, 8, super-high 12.
application areas and the load scenarios you expect on each area.
data transfered, bandwidth.
application, you need to get it.
back and see if you had the System Load analysis correct.
you want to figure out what happens when things go completely out of bounds, can you scale each node?
how each part of your application is going to be affected by traffic and load, now plan for it.
the application.
point.
concurrent connections when you expect to have hundreds... that’s a whole lot of pain.
database to see what is being hit (more later)
application profilers
experience is a pain point: do not forget about javascript and performance.
performance for availability.
scaling.
numbers of servers, databases i.e. resources.
A profile of mysql.com in April 2008 with xDebug and kCacheGrind
Category:Load_testing_tools
http://www.pylot.org/
before doing server scaling.
completely at 300GB but may just be a bad query
Query Analyzer can help.
index.
first_name(1), potentially randomly in a latin1 charset, you would have 100 million/26 = 3.8 million rows to search through. Ineffective index.
solution?
CREATE TABLE `entries` ( `entry_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL DEFAULT '', ... KEY `title` (`title`(1)) );
mysql> explain select title from entries ignore index (title) where title like 'a%' order by title ASC limit 10\G id: 1 select_type: SIMPLE table: entries type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 18459 Extra: Using where; Using filesort
mysql> explain select title from entries where title like 'a%' order by title ASC limit 10\G id: 1 select_type: SIMPLE table: entries type: range possible_keys: title key: title key_len: 5 ref: NULL rows: 706 Extra: Using where; Using filesort
+-------------------------------------------------------------------- | A 'Simple' Protocol for Manual MySQL Slave Promotion to Master | A (round-about) story about Jeffry P. Bezos | ... | A better backup procedure +--------------------------------------------------------------------
10 rows in set (0.07 sec)
+----------------------------------------------------------------- | title +----------------------------------------------------------------- | A 'Simple' Protocol for Manual MySQL Slave Promotion to Master | A (round-about) story about Jeffry P. Bezos | ... | A better backup procedure +-----------------------------------------------------------------
10 rows in set (0.02 sec)
seconds, is that a problem?
allow you to use cheap web server farms instead: Wikipedia, MySQL.com.
might end up with a huge slow down in performance.
mysql_query_cache_sizing
index.php?title=WaffleFAQ
Fatal Error?
performance issues and identify pain points as you expand an application.
types (video distribution, images etc.) Can increase performance.
pushing most accessed content on faster disks.
writes than reads sometimes
performance depending on the job
pairs in RAM of clusters of servers.
Memcache and then query Memcache from the application.
applications.
writes) are good examples
memcached
have the ability to shard on some ID/unique data.
good redundancy with slaves
shards.
nodes to create a true cluster. Great for database
speed.
servers.
potentially a look at the future
for write heavy web apps.
row-level locking, transaction. In general: good for write heavy web apps.
understand how to use indexes.
two selects. (smugmug!)
Log.
denormalizing your data.
Data integrity can become compromised very fast.
environment.
can have dramatic impact on your performance.
indexes, but if it is too big then your system slows down as it starts to page and write to disk.
professional advice!
previous official release of MySQL.
faster Disk I/O depending on your situation and data served
from faster disks.
experts, ask your community, participate in the community!
Librarian!
http//tweetrhapsody.com
Confessionals
http//stpatsdrunkdial.com
Duleepa “Dups” Wijayawardhana dups@sun.com Slides will be made available