Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Scaling LAMP
Search
Sebastian Grodzicki
April 20, 2015
Technology
1
77
Scaling LAMP
Scaling LAMP doesn't have to suck
Sebastian Grodzicki
April 20, 2015
Tweet
Share
More Decks by Sebastian Grodzicki
See All by Sebastian Grodzicki
Elasticsearch + Symfony @ SymfonyLive Online Polish Edition 2021
sgrodzicki
0
100
Elasticsearch + Symfony @ WDI 2021
sgrodzicki
0
18
Combining Logs, Metrics, and Traces for Unified Observability @ Infoshare 2020
sgrodzicki
0
390
Building Distributed Systems in Distributed Teams @ Infoshare 2020
sgrodzicki
0
44
Building Distributed Systems in Distributed Teams @ 4Developers 2020
sgrodzicki
0
38
Building Distributed Systems in Distributed Teams @ DevOpsDay Warsaw 2019
sgrodzicki
0
33
Infrastructure as Code @ DevOpsDay Warsaw 2019
sgrodzicki
0
42
Serverless PHP @ PHPCon Poland 2019
sgrodzicki
0
240
Profiling PHP @ HackYeah 2019
sgrodzicki
0
48
Other Decks in Technology
See All in Technology
拓展QA日常工作的邊界
line_developers_tw
PRO
0
650
Money-saving tips for the frugal serverless developer
theburningmonk
1
410
[2024년 5월 세미나] 생성형 AI와 함께하는 데이터 분석가 커리어
datarian
0
1.3k
データベース04: SQL (1/3) 単純質問 & 集約演算
trycycle
0
180
5分で分かる(かもしれない) Vector engine for OpenSearch Serverless
tsukuboshi
1
430
データベース05: SQL(2/3) 結合質問
trycycle
0
110
TailwindCSSでUIライブラリを作る際のハマりどころ
shuta13
0
230
SWC Transformerから見るTypeScript関数記述ベストプラクティス
fujiyamaorange
1
180
Kaggleで学ぶ系列データのための深層学習モデリング
yu4u
7
1.7k
TDD - Test Driven Drupal
opdavies
0
3k
生成AIと産業向けソフトウェアの自動生成 〜 ハノーバーメッセ2024より〜
kioto
2
440
日本が誇るイタリアのダンスミュージック!? ユーロビートって何??
minorun365
PRO
2
230
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
14
8.4k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
20
1.8k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
Practical Orchestrator
shlominoach
183
9.8k
BBQ
matthewcrist
80
8.8k
The Invisible Customer
myddelton
114
12k
Web Components: a chance to create the future
zenorocha
306
41k
Gamification - CAS2011
davidbonilla
77
4.6k
Into the Great Unknown - MozCon
thekraken
15
1.1k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
67
14k
Debugging Ruby Performance
tmm1
70
11k
Stop Working from a Prison Cell
hatefulcrawdad
266
19k
Transcript
Scaling LAMP doesn't have to suck
Sebastian Grodzicki CTO @ GoldenLine ~100 req/s ~4.7M UU
#DevOps
LAMP • Linux • Apache • MySQL • PHP
Scaling LAMP • shared hosting • VPS • dedicated server
Scaling LAMP • split LAMP into LM + LAP •
use virtual machines or Docker • forget 127.0.0.1 (AKA localhost) • forget about local storage
A better LAMP • Linux (tuned) • Apache Nginx •
MySQL Percona Server • PHP PHP-FPM • Redis • Resque
Linux (tuned) • Linux is mostly sane • use latest
kernel • distribution doesn’t matter • (I like Debian)
Tune Linux • open_files • network/sysctl • i/o scheduler
Linux: open_files • default: 1024 (ulimit -n) • soft nofile
999999 • hard nofile 999999
Linux: sysctl • net.ipv4.ip_local_port_range = 1024 65535 • net.ipv4.tcp_tw_recycle =
1 • net.ipv4.tcp_tw_reuse = 1 • net.core.somaxconn = 999999 (default: 128)
Linux: i/o scheduler • $ cat /sys/block/sda/queue/scheduler noop deadline [cfq]
• $ echo deadline > /sys/block/sda/queue/scheduler • $ cat /sys/block/sda/queue/scheduler noop [deadline] cfq
Nginx • open-source HTTP server • swap out Apache •
easy + sane config
Nginx 21k req/s @ 10% CPU & 160 MB RAM
Nginx • load balancer • reverse proxy • content caching
• streaming media • web server
Percona Server • open source MySQL fork • patches from
Twitter and Google • drop-in MySQL replacement • faster at scale, more reliable
MySQL vs Percona new transactions per minute
Percona Server • only use InnoDB (XtraDB) • disable query
cache • enable thread pool
PHP-FPM • standard with PHP 5.3+ • daemonization & process
management • used by Rasmus Lerdord (author of PHP)
PHP-FPM • pm = static • pm.max_children = {{ CPU
cores * 4 }} • pm.max_children = 32 # 8c/16t • pm.max_children = 64 # 16c/32t • pm.max_children = 80 # 20c/40t
PHP-FPM • 5.6 is faster than 5.5 • 5.5 is
faster than 5.4 • 5.4 is faster than 5.3 • 5.6 is much faster than 5.3
PHP-FPM • 5.6: OPcache • 5.5: OPcache • 5.4: APC
• 5.3: APC
Redis • key-value cache & store • >= Memcached •
optional persistence & hot cache • clients for almost every language • use phpredis (the C extension)
Resque • open source library • made by GitHub •
ported to PHP (php-reque) • uses Redis
Load Balancer A Load Balancer B App 1 App 2
App 3 App N DB 1 DB 2 DB N Redis 1 Redis 2 Redis N DNS
Questions?
Thank you!