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
100
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Scaling LAMP
Scaling LAMP doesn't have to suck
Sebastian Grodzicki
April 20, 2015
More Decks by Sebastian Grodzicki
See All by Sebastian Grodzicki
Fault-tolerant workflow orchestration in PHP @ PHPCon Poland 2024
sgrodzicki
0
160
PHP w Google Cloud @ PHPCon Poland 2022
sgrodzicki
0
50
Elasticsearch + Symfony @ SymfonyLive Online Polish Edition 2021
sgrodzicki
0
190
Elasticsearch + Symfony @ WDI 2021
sgrodzicki
0
66
Combining Logs, Metrics, and Traces for Unified Observability @ Infoshare 2020
sgrodzicki
0
560
Building Distributed Systems in Distributed Teams @ Infoshare 2020
sgrodzicki
0
92
Building Distributed Systems in Distributed Teams @ 4Developers 2020
sgrodzicki
0
92
Building Distributed Systems in Distributed Teams @ DevOpsDay Warsaw 2019
sgrodzicki
0
71
Infrastructure as Code @ DevOpsDay Warsaw 2019
sgrodzicki
0
99
Other Decks in Technology
See All in Technology
第67回コンピュータビジョン勉強会CVPR2026読会前編
tsukamotokenji
0
160
【公開用】AI_Dev_Ex2026_AI_登壇資料
matsuritechnologies
PRO
1
430
「守りたい体験」を渡すだけで E2E を生成させられるようになった話
hinac0
2
980
なぜ、あなたのエージェントは言うことを聞かないのか
segavvy
1
170
Amplify Gen2でbackend.tsにCDKを定義する/しない事によるCDKの挙動の違いとユースケース
smt7174
1
470
SRENEXT_2026_Chairs__Talks_in_Tamachi.sre.pdf
srenext
1
120
”AIを使う” から ”AIに任せる” へ ─ 開発プロセスを再設計してAIを組織標準にするまで
cyberagentdevelopers
PRO
1
130
ダッシュボード"開発"について 〜使われるダッシュボードのつくりかた〜
kimichan
0
150
全員がリーダーである世界へ キリマンジャロ登頂とシェアド・リーダー
jinwatanabe
0
120
JAWS_ICEBERG_BASECAMP
iqbocchi
2
110
なぜ、あなたのAPIは使われないのか? AX時代の設計原則、ガードレール、運用体制
yokawasa
1
190
10年目を迎えた「ABEMA」がどのように AI 活用を推進して、AI 駆動開発にシフトしているのか / How ABEMA, entering its 10th year, is promoting the use of AI and shifting toward AI-driven development
miyukki
0
360
Featured
See All Featured
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
550
Accessibility Awareness
sabderemane
1
160
Become a Pro
speakerdeck
PRO
31
6k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
550
Color Theory Basics | Prateek | Gurzu
gurzu
0
390
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
450
Design in an AI World
tapps
1
260
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
370
It's Worth the Effort
3n
188
29k
Utilizing Notion as your number one productivity tool
mfonobong
4
440
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
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!