Scaling LAMP doesn't have to suck

Download Scaling LAMP doesn't have to suck

Post on 08-May-2015

324 views

Category:

Technology

4 download

Embed Size (px)

DESCRIPTION

Scale PHP Effortlessly Learn the 80/20 of owning your LAMP stack and get back to coding! I spent a year sleeping next to my laptop, rolling over to restart Apache, as I scaled Twitpic to 50m users. Save your sanity and learn from my mistakes.

TRANSCRIPT

<ul><li>1.scaling LAMP doesnt have to suck! @stevencorona (800 million api calls/day) </li></ul> <p>2. lets learn how to scale php ! ...in 40 minutes 3. LAMP LINUX APACHE MYSQL PHP 4. a better LAMP LINUX +TUNING NGINX PHP-FPM PERCONA NSQ REDIS 5. nginx loadbalancer nginx php-fpm MySQL Master nginx php-fpm nginx php-fpm nsq MySQL Slavecache MySQL Slave 6. tuning linux linux is mostly saneuse latest kerneldistro doesnt matter(i like ubuntu) 7. top 3 settings open_lesnetwork/sysctl tuningi/o scheduler! most settings you ndonline are outdated 8. open les default is 1024on linux, each socket = open le! /etc/security/limits.conf! soft nofile 65535! hard nofile 65535 9. sysctl tuning! thousands of settingsnewer kernels autotune network! /etc/sysctl.conf! net.core.somaxconn=65536! net.ipv4.ip_local_port_range=2000 62000! 10. i/o scheduler linux has swappable schedulerdefault is cfq! $ echo deadline &gt; ! /sys/block/sda/queue/scheduler ! +50% IOPS on MySQL 11. nginx open-source HTTP serverswap out apacheeasy + sane congnginx.org 12. nginx most popular webserver of top 1000 sites! 15,000 requests/secondwith 20% CPU and100MB RAM 13. nginx 14. nginx load balancerhttp cachefastcgi proxyweb server 15. php php-fpm is kingstandard with php5.3 16. php-fpm use static worker pool4x number of CPU cores! pm=static! pm.max_children=128 17. php php 5.5 is much faster than 5.4 and 5.3! USE IT! 18. php ! php 5.5 includes Zend Opcache(no more APC)! 10-20% faster than APC in real world 19. php horizontal scalingwatch out for sessions! 20. php + mysql mysql persistent connections are GOOD to use.! despite what the internet says 21. percona ! open source mysql fork! patches from twitter and googlepercona.com 22. percona drop-in replacement! faster at scale, more reliable 23. percona new transactions per minute (more is better) 24. percona only use innodbdisable query cacheenable thread poolthread_handling=pool-of-threads! 25. percona stop wasting timeuse SSDs ! 26. redis in the old days, we used memcache! redis is better ! redis.io 27. redis data persisted to diskhot cache500,000 GET/second 28. redis cong is great out of box! avoid stalls on EC2use HVM instances 29. redis lots of php libraries! use pecl-redisc extensionpecl install redis 30. nsq message queue server in golang by bit.ly! we use it to process 800 million events/day! https://github.com/bitly/nsq 31. nsq nsqphp is best php librarypub/sub modeldo work asyncapi callsdefer long-running work! https://github.com/davegardnerisme/nsqphp 32. nsq 33. nsq DONT USE MYSQLAS A WORK QUEUE! 34. dont scale code ! your code is fast enough! scale infrastructure 35. thanks! check out my book SCALING PHP http://scalingphpbook.com </p>