SlideShare a Scribd company logo
PHP at Scale:
Knowing enough to be dangerous!
Oleksii Petrov
Skelia Ukraine / ETWater
Who am I
System Architect
Team Lead
PHP Developer
Find me on
@alexhelkar
alexhelkar
https://github.com/alexhelkar
What does it mean
"to scale"?
Does it mean?
Or does it mean?
Often it means
"To scale"
Improve system metrics
without changing the
system*
* (dramaticaly)
Scale roadmap is predefined
by your stack and software architecture
Let's go!
Performance
Story
PHP 7 facts
isset 1.55 times faster than array_key_exists
is_file 26 times faster than file_exists
single quotes slower that double quotes
instanceof faster is_a
etc.
Code performance?
Blackfire.io & Symfony Blog
Current results:
Total request time: 18.4 ms
file_exists called: 7 times
Exec. time for file_exists: 460 µs
Expected results:
Exec/ time: ~17.6 µs
Total request time: ~18.3996 ms
PHP lang performance
...овно?
OR
...амно?
Why a system is
slow?
Because of
Database!
Scaling strategies
Caching
Queueing
Reads/Writes Spliting
Sharding
Caching
Typical Request Flow
DB Cache
Application Cache
Web Cache
Cache: Rule of thumb
IF Application is SLOW
Enable Caching
IF Application has GLITCHES
Disable Caching
Queueing
Queue as The Equalizer
Queue as The Equalizer
Problems?
Delays
Queue as Load Balancer
Problems?
Unbounded
buffers!
Read/Write Splitting
Master-Slave replication
async/semi-sync
Writes
Reads Reads
Problems?
Replication lag
Galera Replication
aka sync replication
Problems?
Writes
Performance
What is IoT?
IoT is like
Canvas
REST API
Weather Data
Avg. Request Size 325b
Data Sample
{
"deviceId": 231,
"lat":"45.22838254",
"lng":"-114.23725403",
"timestamp":1459509524,
"temperature":2.99,
"precipProbability":0.386,
"humidity":0.055,
"pressure":1035.617
}
Load Generator
Yandex Tank
Tasks
Create platform setup
Gather performance metrics
Calculate budgets
Plan 1: 86k req/day (1 rps)
Plan 2: 8.64M req/day (100 rps)
Setup: 20$
Response Time
Limitation
Same Setup: 200rps
Why 3 database
servers?
Probability?
Head: 50% | Tails: 50%
Probability of 2 consecutive Heads?
25%
Probability of 3 consecutive Heads?
12.5% 0.5^3
Servers reliability
1 Server 99%
10 Servers 90.4%
100 Servers 36.6%
Distributed System
High Availability
Any
should consider
Plan 4: 43.2M req/day (500rps)
Setup Variant 1: 380$
Quantiles
Setup Variant 2: 150$
Quantiles
Mircoservices
230 Reasons to choose
380$ - 150$ = 230$
Plan 5: 84.6M req/day (1k rps)
Plan 5: 84.6M req/day (1k rps)
Plan 6: 432M req/day (5k rps)
Started to think
about bulk inserts?
Plan 7: 1.26B req/day (15k rps)
Quantiles
TCP/IP
TCP Flow
Packets Rate
Packets Rate
1 Request
15k Requests
~10 Packets
~15k Packets
Load Balancer Trick
Load Balancer Trick
Load Balancer Trick
Load Balancer Trick
Why?
Load Balancer Trick
75k pack.
75k pack.
LB Recieved: 150k packets
Plan 7: 50000 req/sec
Commodity
Hardware
Commodity Hardware
$5 Server 1 CPU
20 CPU $100 Server
$640 Server
c4.8xlarge: $1222.750/monthly
DNS Load Distribution
DNS Load Distribution
DNS Cache
Rule of Thumb: Add LB
What if?
Floating IP
Sharding?
Last Resort
Mysql: Manual Sharding
Mysql: Fabric (pre-alpha)
<?php
$mysqli = new mysqli("myapp", "user", "password", "database");
mysqlnd_ms_fabric_select_shard($mysqli, "test.fabrictest", 10);
$mysqli->query("INSERT INTO fabrictest(id) VALUES (10)");
mysqlnd_ms_fabric_select_shard($mysqli, "test.fabrictest", 10);
$mysqli->query("SELECT id FROM test WHERE id = 10");
http://php.net/manual/ru/mysqlnd-
ms.quickstart.mysql_fabric.php
MariaDB: Spider
Mysql Cluster (NDB)
MongoDB Sharding
Apache Cassandra
RabbitMQ
Hits 1 Million Messages Per
Second. 32 machines
https://blog.pivotal.io/pivotal/products/rab
bitmq-hits-one-million-messages-per-
second-on-google-compute-engine
Apache Kafka
2 Million Writes Per Second
3 machines
https://engineering.linkedin.com/kafka/be
nchmarking-apache-kafka-2-million-writes-
second-three-cheap-machines
Instead Summary
Scalability as afterwords doesn't work
Database is not a queue
Database is not a lock system
Redis is not a queue
Load balancers as a must
Linear disk writes wins
Perfomance in PHP is done by everything except PHP
Being distributed is freaking hard
Questions?
Find me on
@alexhelkar
alexhelkar
https://github.com/alexhelkar

More Related Content

PDF
Александр Махомет "Beyond the code или как мониторить ваш PHP сайт"
PPTX
Andres Gutierrez "Phalcon 3.0, Zephir & PHP7"
PPTX
5 things you didn't know nginx could do velocity
PPTX
Node.js
PDF
Nginx وب سروری برای تمام فصول
PDF
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
PDF
Jean-Baptiste Favre - How to Monitor Bilions of Miles Shared by 20 Million Us...
PPTX
HTML5 Programming
Александр Махомет "Beyond the code или как мониторить ваш PHP сайт"
Andres Gutierrez "Phalcon 3.0, Zephir & PHP7"
5 things you didn't know nginx could do velocity
Node.js
Nginx وب سروری برای تمام فصول
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
Jean-Baptiste Favre - How to Monitor Bilions of Miles Shared by 20 Million Us...
HTML5 Programming

What's hot (20)

PDF
Introduction to performance tuning perl web applications
KEY
Nginx - Tips and Tricks.
PDF
Multiple django applications on a single server with nginx
PDF
Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...
PPTX
5 things you didn't know nginx could do
PDF
Monitoring a billion kilometers of monthly ride sharing at BlaBlaCar - Zabbix...
PDF
Continuous Integration on Steroids
PDF
Volker Fröhlich - How to Debug Common Agent Issues
PDF
Solving some of the scalability problems at booking.com
PDF
The Integration of Laravel with Swoole
PPT
Learn ELK in docker
PDF
Cortex: Prometheus as a Service, One Year On
PDF
Building GUI App with Electron and Lisp
PDF
Lukas Macura - Employing Zabbix to monitor OpenWrt (Beesip) devices with Uciprov
PDF
High Performance Systems in Go - GopherCon 2014
PDF
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
PDF
Writing a fast HTTP parser
PDF
How to monitor NGINX
PDF
From zero to hero - Easy log centralization with Logstash and Elasticsearch
PDF
События, шины и интеграция данных в непростом мире микросервисов / Валентин Г...
Introduction to performance tuning perl web applications
Nginx - Tips and Tricks.
Multiple django applications on a single server with nginx
Как сделать высоконагруженный сервис, не зная количество нагрузки / Олег Обле...
5 things you didn't know nginx could do
Monitoring a billion kilometers of monthly ride sharing at BlaBlaCar - Zabbix...
Continuous Integration on Steroids
Volker Fröhlich - How to Debug Common Agent Issues
Solving some of the scalability problems at booking.com
The Integration of Laravel with Swoole
Learn ELK in docker
Cortex: Prometheus as a Service, One Year On
Building GUI App with Electron and Lisp
Lukas Macura - Employing Zabbix to monitor OpenWrt (Beesip) devices with Uciprov
High Performance Systems in Go - GopherCon 2014
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
Writing a fast HTTP parser
How to monitor NGINX
From zero to hero - Easy log centralization with Logstash and Elasticsearch
События, шины и интеграция данных в непростом мире микросервисов / Валентин Г...
Ad

Viewers also liked (20)

PDF
Алексей Петров "Dockerize Me: Distributed PHP applications with Symfony, Dock...
PDF
Olivier Dolbeau, Benjamin De Bernardi "25+ millions members in 22 countries, ...
PDF
Сергей Яковлев "Техническая сторона email-маркетинга"
PPT
Игорь Карпенко "Data, Context, Interaction – парадигма программирования от ав...
PDF
Эффективный сайт медицинского учреждения
PPTX
Аналитика и стратегия развития каналов интернет-маркетинга
PDF
Продвижение видео в ютуб и других видеохостингах
PDF
Designing for Privacy
PPT
"Spring Boot. Boot up your development" Сергей Моренец
PDF
Сергей Яковлев "Phalcon 2 - стабилизация и производительность"
PDF
Андрей Шумада | Tank.ly
PPTX
Швейцарія, масштабування Scrum і розподілені команди от Романа Сахарова
PDF
Анастасия Войтова: "Building profanity filters on mobile: clbuttic sh!t"
PDF
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
PDF
"После OOD: как моделировать предметную область в пост-объектном мире" Руслан...
PDF
Fighting Fat Models (Богдан Гусев)
PDF
Алексей Рыбаков: "Wearable OS год спустя: Apple Watch 2.0, Android Wear 5.1.1...
PPTX
Сергей Жук "Android Performance Tips & Tricks"
PDF
Евгений Обрезков "Behind the terminal"
PDF
Светлана Старикова "Building a self-managing team: why you should not have e...
Алексей Петров "Dockerize Me: Distributed PHP applications with Symfony, Dock...
Olivier Dolbeau, Benjamin De Bernardi "25+ millions members in 22 countries, ...
Сергей Яковлев "Техническая сторона email-маркетинга"
Игорь Карпенко "Data, Context, Interaction – парадигма программирования от ав...
Эффективный сайт медицинского учреждения
Аналитика и стратегия развития каналов интернет-маркетинга
Продвижение видео в ютуб и других видеохостингах
Designing for Privacy
"Spring Boot. Boot up your development" Сергей Моренец
Сергей Яковлев "Phalcon 2 - стабилизация и производительность"
Андрей Шумада | Tank.ly
Швейцарія, масштабування Scrum і розподілені команди от Романа Сахарова
Анастасия Войтова: "Building profanity filters on mobile: clbuttic sh!t"
Александр Махомет "Feature Flags. Уменьшаем риски при выпуске изменений"
"После OOD: как моделировать предметную область в пост-объектном мире" Руслан...
Fighting Fat Models (Богдан Гусев)
Алексей Рыбаков: "Wearable OS год спустя: Apple Watch 2.0, Android Wear 5.1.1...
Сергей Жук "Android Performance Tips & Tricks"
Евгений Обрезков "Behind the terminal"
Светлана Старикова "Building a self-managing team: why you should not have e...
Ad

Similar to Алексей Петров "PHP at Scale: Knowing enough to be dangerous!" (20)

PPTX
Northeast PHP - High Performance PHP
PPTX
Full Stack Load Testing
KEY
Site Performance - From Pinto to Ferrari
KEY
PHP to Python with No Regrets
PPTX
PHP Performance with APC + Memcached
ODP
Improving PHP Application Performance with APC
PDF
PHP 7 performances from PHP 5
PDF
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
PPT
How Many Slaves (Ukoug)
PPTX
Software Network Data Plane - Satisfying the need for speed - FD.io - VPP and...
PDF
Performance
PDF
The Anatomy of Failure - Lessons from running systems to serve millions of pe...
PPTX
Emerging technologies /frameworks in Big Data
PDF
Top ten-list
PDF
MySQL Manchester TT - 5.7 Whats new
PPTX
Hadoop Query Performance Smackdown
PPTX
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
PDF
Meet a parallel, asynchronous PHP world
PPTX
Nexcess Magento Imagine 2014 Performance Breakout
KEY
Profiling php applications
Northeast PHP - High Performance PHP
Full Stack Load Testing
Site Performance - From Pinto to Ferrari
PHP to Python with No Regrets
PHP Performance with APC + Memcached
Improving PHP Application Performance with APC
PHP 7 performances from PHP 5
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
How Many Slaves (Ukoug)
Software Network Data Plane - Satisfying the need for speed - FD.io - VPP and...
Performance
The Anatomy of Failure - Lessons from running systems to serve millions of pe...
Emerging technologies /frameworks in Big Data
Top ten-list
MySQL Manchester TT - 5.7 Whats new
Hadoop Query Performance Smackdown
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Meet a parallel, asynchronous PHP world
Nexcess Magento Imagine 2014 Performance Breakout
Profiling php applications

More from Fwdays (20)

PDF
"Mastering UI Complexity: State Machines and Reactive Patterns at Grammarly",...
PDF
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
PPTX
"Computer Use Agents: From SFT to Classic RL", Maksym Shamrai
PPTX
"Як ми переписали Сільпо на Angular", Євген Русаков
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
PDF
"Validation and Observability of AI Agents", Oleksandr Denisyuk
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
PPTX
"Co-Authoring with a Machine: What I Learned from Writing a Book on Generativ...
PPTX
"Human-AI Collaboration Models for Better Decisions, Faster Workflows, and Cr...
PDF
"AI is already here. What will happen to your team (and your role) tomorrow?"...
PPTX
"Is it worth investing in AI in 2025?", Alexander Sharko
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
PDF
"Scaling in space and time with Temporal", Andriy Lupa.pdf
PDF
"Database isolation: how we deal with hundreds of direct connections to the d...
PDF
"Scaling in space and time with Temporal", Andriy Lupa .pdf
PPTX
"Provisioning via DOT-Chain: from catering to drone marketplaces", Volodymyr ...
PPTX
" Observability with Elasticsearch: Best Practices for High-Load Platform", A...
PPTX
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
PPTX
"Istio Ambient Mesh in production: our way from Sidecar to Sidecar-less",Hlib...
"Mastering UI Complexity: State Machines and Reactive Patterns at Grammarly",...
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
"Computer Use Agents: From SFT to Classic RL", Maksym Shamrai
"Як ми переписали Сільпо на Angular", Євген Русаков
"AI Transformation: Directions and Challenges", Pavlo Shaternik
"Validation and Observability of AI Agents", Oleksandr Denisyuk
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
"Co-Authoring with a Machine: What I Learned from Writing a Book on Generativ...
"Human-AI Collaboration Models for Better Decisions, Faster Workflows, and Cr...
"AI is already here. What will happen to your team (and your role) tomorrow?"...
"Is it worth investing in AI in 2025?", Alexander Sharko
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Database isolation: how we deal with hundreds of direct connections to the d...
"Scaling in space and time with Temporal", Andriy Lupa .pdf
"Provisioning via DOT-Chain: from catering to drone marketplaces", Volodymyr ...
" Observability with Elasticsearch: Best Practices for High-Load Platform", A...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"Istio Ambient Mesh in production: our way from Sidecar to Sidecar-less",Hlib...

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Empathic Computing: Creating Shared Understanding
PDF
Encapsulation theory and applications.pdf
PDF
Getting Started with Data Integration: FME Form 101
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
A Presentation on Artificial Intelligence
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPT
Teaching material agriculture food technology
PDF
Approach and Philosophy of On baking technology
Advanced methodologies resolving dimensionality complications for autism neur...
SOPHOS-XG Firewall Administrator PPT.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Per capita expenditure prediction using model stacking based on satellite ima...
Big Data Technologies - Introduction.pptx
Spectroscopy.pptx food analysis technology
Empathic Computing: Creating Shared Understanding
Encapsulation theory and applications.pdf
Getting Started with Data Integration: FME Form 101
Programs and apps: productivity, graphics, security and other tools
Reach Out and Touch Someone: Haptics and Empathic Computing
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
“AI and Expert System Decision Support & Business Intelligence Systems”
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
A Presentation on Artificial Intelligence
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Machine Learning_overview_presentation.pptx
Assigned Numbers - 2025 - Bluetooth® Document
Teaching material agriculture food technology
Approach and Philosophy of On baking technology

Алексей Петров "PHP at Scale: Knowing enough to be dangerous!"