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
91
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
Fault-tolerant workflow orchestration in PHP @ PHPCon Poland 2024
sgrodzicki
0
79
PHP w Google Cloud @ PHPCon Poland 2022
sgrodzicki
0
13
Elasticsearch + Symfony @ SymfonyLive Online Polish Edition 2021
sgrodzicki
0
140
Elasticsearch + Symfony @ WDI 2021
sgrodzicki
0
47
Combining Logs, Metrics, and Traces for Unified Observability @ Infoshare 2020
sgrodzicki
0
470
Building Distributed Systems in Distributed Teams @ Infoshare 2020
sgrodzicki
0
56
Building Distributed Systems in Distributed Teams @ 4Developers 2020
sgrodzicki
0
60
Building Distributed Systems in Distributed Teams @ DevOpsDay Warsaw 2019
sgrodzicki
0
42
Infrastructure as Code @ DevOpsDay Warsaw 2019
sgrodzicki
0
58
Other Decks in Technology
See All in Technology
「クラウドコスト絶対削減」を支える技術—FinOpsを超えた徹底的なクラウドコスト削減の実践論
delta_tech
4
190
AWS CDK 入門ガイド これだけは知っておきたいヒント集
anank
5
600
伴走から自律へ: 形式知へと導くSREイネーブリングによる プロダクトチームの信頼性オーナーシップ向上 / SRE NEXT 2025
visional_engineering_and_design
3
230
推し書籍📚 / Books and a QA Engineer
ak1210
0
120
american aa airlines®️ USA Contact Numbers: Complete 2025 Support Guide
aaguide
0
500
アクセスピークを制するオートスケール再設計: 障害を乗り越えKEDAで実現したリソース管理の最適化
myamashii
1
330
【LT会登壇資料】TROCCO新コネクタ「スマレジ」を活用した直営店データの分析
kazari0425
1
170
大量配信システムにおけるSLOの実践:「見えない」信頼性をSLOで可視化
plaidtech
PRO
0
290
ソフトウェアQAがハードウェアの人になったの
mineo_matsuya
3
110
freeeのアクセシビリティの現在地 / freee's Current Position on Accessibility
ymrl
2
280
助けて! XからWaylandに移行しないと新しいGNOMEが使えなくなっちゃう 2025-07-12
nobutomurata
2
140
TLSから見るSREの未来
atpons
2
240
Featured
See All Featured
Docker and Python
trallard
45
3.5k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
Speed Design
sergeychernyshev
32
1k
Side Projects
sachag
455
42k
Scaling GitHub
holman
460
140k
Documentation Writing (for coders)
carmenintech
72
4.9k
Code Reviewing Like a Champion
maltzj
524
40k
Rails Girls Zürich Keynote
gr2m
95
14k
Faster Mobile Websites
deanohume
307
31k
Agile that works and the tools we love
rasmusluckow
329
21k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
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!