SlideShare a Scribd company logo
Scaling your PHP Web Applications (a.k.a. make your web applications alive and still responsive even with thousands of users hammering your site per second)‏
There is no silver bullet Merely adding more servers, or buying the hype for some exotic architecture, or getting that ultra-expensive technology will not make your web application scale in the long run.
Start with the fundamentals in coding Design your code to be testable at all levels Know your data structures and algorithms Design your application with eventual change in mind
Design your code to be testable at all levels Write unit and integration tests that test both behavior and outcome in positive and error conditions. The design of classes and functions affect testability.
Know your data structures and algorithms Inelegant data structures and algorithms collapse when subjected to high load due to protracted run times and insane memory usage Certain problems will require different algorithms and data structures to be deployed, and will have to be deployed and used by your application differently
Design your application with eventual change in mind Make classes and functions that do only one thing and do it well Favor loose coupling of dependencies Improve on software design patterns that promote extensible design Eventually you will replace pieces of your application with better parts
Going further Getting rid of obvious boo-boos Using an RDBMS Caching Know how and when to take advantage of the language Further tuning the performance of your application
Getting rid of obvious boo-boos Avoid multiple loops over the same structure when processing Simpler usually means better – you do not need to bring out tanks to crush ants Reserve use of encryption to where you really need it.
Using an RDBMS A relational database is primarily intended to store relational data You won't miss doing referential integrity checks at the database level Forget about using SQL JOIN in a live web application Query in chunks when the data set is huge Favor a bulk database query rather than doing multiple loops with the same database query Make judicious use of database indexes during queries
Caching To avoid expensive page rebuilds, use output page caching – PHP has output buffering (via the  ob_  functions) by default, and there are libraries that abstract this functionality Reduce compile time for redundant objects by using op-code caching (e.g.  APC ,  eAccelerator ,  XCache )‏ Take a look at other caching strategies (e.g. CDN, caching HTTP proxies,  memcached )‏ If you are using  memcached , chunk entries into smaller collections rather than storing very big objects in cache. Cache database results as much as you can
Know how and when to take advantage of the language PHP  isset()  is implemented as a hash table – consider using this over the function  in_array()  for huge array searches PHP evaluates strings within single quotes faster than strings within double quotes Consider passing references rather than copies of objects and arrays to save memory The  ctype_  functions are faster than using regular expression testing for validating types
Further tuning the performance of your application Optimize and profile your database queries so that the results will fit in memory Do performance tests that simulate real-world conditions to ensure your application survives high loads.  Profile the code to find out bottle necks and excessive calls – there are tools like  APD  and  Xdebug  to aid in this task.  Know the capabilities and limitations of your application's dependencies and tune according to the purpose of the said dependency, or replace them.
Surviving the horde Employing asynchronous and parallel computing techniques Knowing when to use the better tools for the job Spreading your application's infrastructure across many machines Employing a service oriented architecture
Employing asynchronous and parallel computing techniques Responsiveness is a highly desirable goal. Do not put long running routines on code that will be rendered by the application. Consider using a queueing service for long running tasks.  Maximize parallelism. Some tasks can be executed off-line and in parallel as long as they do not lock on the same resources.
Knowing when to use the better tools for the job Consider writing extensions for commonly-used functions that are not practical (speed-wise) to implement in PHP, yet require to constantly interact with PHP Parallel distributed computing, or any computing that requires concurrency (e.g. threads, shared memory, map-reduce) is outside PHP's strengths. You may consider using more appropriate tools (MPI, etc)‏ Sometimes the filesystem is better than a database.
Spreading your application's infrastructure across many machines Your application will vertically-scale up to a certain point – after which you have to start considering employing more machines for better throughput. Depending on a couple of factors (e.g. CPU intensiveness, network traffic, e.g.) - some application dependencies will have to be deployed on their own clusters (e.g. databases), while some can be bundled together with the application, in order for the application to remain responsive.
Employing a service-oriented architecture This allows replacement and isolation of component dependencies much easier as component dependencies are designed to perform one task and perform them well, while isolating problems is reduced to targeting the service responsible. The use of persistent connections to resources (e.g. databases, cache, etc) from services (to save memory, multiplex requests, etc) scales better than having all application servers connect directly to the resources.
After everything else... Throwing money at the problem would probably work

More Related Content

PPS
Building Low Cost Scalable Web Applications Tools & Techniques
PPTX
ImpalaToGo use case
PPTX
Big-Data Hadoop Tutorials - MindScripts Technologies, Pune
PPTX
Building Big data solutions in Azure
PDF
Accelerating Analytics with EMR on your S3 Data Lake
PPTX
Big data solutions in azure
PDF
AWS tutorial-Part59:AWS Cloud Database Products-2nd Intro Session
PPTX
Big data solutions in Azure
Building Low Cost Scalable Web Applications Tools & Techniques
ImpalaToGo use case
Big-Data Hadoop Tutorials - MindScripts Technologies, Pune
Building Big data solutions in Azure
Accelerating Analytics with EMR on your S3 Data Lake
Big data solutions in azure
AWS tutorial-Part59:AWS Cloud Database Products-2nd Intro Session
Big data solutions in Azure

What's hot (19)

PDF
An Introduction to Sparkling Water by Michal Malohlava
PDF
AWS tutorial-Part82: Exam Essentials#2
PPT
PDF
The hidden engineering behind machine learning products at Helixa
PPT
2 hadoop@e bay-hug-2010-07-21
PDF
Low latency access of bigdata using spark and shark
PDF
AWS tutorial-Part5 to 10(Combined):Overview of various AWS services and offer...
PDF
AWS tutorial-Part58:AWS Cloud Database Products-1st Intro Session
PDF
AWS tutorial-Part27:AWS EC2
PPTX
03 net saturday anton samarskyy ''document oriented databases for the .net pl...
PDF
Challenges for running Hadoop on AWS - AdvancedAWS Meetup
PDF
FOSSASIA 2016 - 7 Tips to design web centric high-performance applications
PDF
Bursting on-premise analytic workloads to Amazon EMR using Alluxio
PDF
Regression Test Old ETL
PPTX
Rich Data Graphs for MapReduce
PPTX
Google cloud certification data engineer
PDF
How to optimize asp dot-net application
PPTX
Sparkflows.io
DOCX
Hadoop online training course
An Introduction to Sparkling Water by Michal Malohlava
AWS tutorial-Part82: Exam Essentials#2
The hidden engineering behind machine learning products at Helixa
2 hadoop@e bay-hug-2010-07-21
Low latency access of bigdata using spark and shark
AWS tutorial-Part5 to 10(Combined):Overview of various AWS services and offer...
AWS tutorial-Part58:AWS Cloud Database Products-1st Intro Session
AWS tutorial-Part27:AWS EC2
03 net saturday anton samarskyy ''document oriented databases for the .net pl...
Challenges for running Hadoop on AWS - AdvancedAWS Meetup
FOSSASIA 2016 - 7 Tips to design web centric high-performance applications
Bursting on-premise analytic workloads to Amazon EMR using Alluxio
Regression Test Old ETL
Rich Data Graphs for MapReduce
Google cloud certification data engineer
How to optimize asp dot-net application
Sparkflows.io
Hadoop online training course
Ad

Similar to Scaling Web Apps P Falcone (20)

PPT
scale_perf_best_practices
PDF
System Design Interview Questions PDF By ScholarHat
ODP
Best practice adoption (and lack there of)
PPT
Web Speed And Scalability
PPSX
Flex 4.5 jeyasekar
PDF
Atmosphere 2014: Switching from monolithic approach to modular cloud computin...
ODP
Front Range PHP NoSQL Databases
PPT
Top 10 Scalability Mistakes
PPT
Apache Con 2008 Top 10 Mistakes
PPTX
Black Friday and Cyber Monday- Best Practices for Your E-Commerce Database
PPTX
Handling Data in Mega Scale Systems
PPTX
L19 Application Architecture
PPT
J2EE Performance And Scalability Bp
PPTX
SQL Server Integration Services and Analysis Services
PPTX
cakephp UDUYKTHA (1)
PPTX
Adopting AnswerModules ModuleSuite
PPTX
MongoDB Schema Design by Examples
PDF
Deep dive into the native multi model database ArangoDB
PPT
I/O & virtualization performance with a search engine based on an xml databa...
PDF
System design for Web Application
scale_perf_best_practices
System Design Interview Questions PDF By ScholarHat
Best practice adoption (and lack there of)
Web Speed And Scalability
Flex 4.5 jeyasekar
Atmosphere 2014: Switching from monolithic approach to modular cloud computin...
Front Range PHP NoSQL Databases
Top 10 Scalability Mistakes
Apache Con 2008 Top 10 Mistakes
Black Friday and Cyber Monday- Best Practices for Your E-Commerce Database
Handling Data in Mega Scale Systems
L19 Application Architecture
J2EE Performance And Scalability Bp
SQL Server Integration Services and Analysis Services
cakephp UDUYKTHA (1)
Adopting AnswerModules ModuleSuite
MongoDB Schema Design by Examples
Deep dive into the native multi model database ArangoDB
I/O & virtualization performance with a search engine based on an xml databa...
System design for Web Application
Ad

Recently uploaded (20)

PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Modernizing your data center with Dell and AMD
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
A Presentation on Artificial Intelligence
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
NewMind AI Monthly Chronicles - July 2025
PPT
Teaching material agriculture food technology
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Per capita expenditure prediction using model stacking based on satellite ima...
Modernizing your data center with Dell and AMD
Unlocking AI with Model Context Protocol (MCP)
Mobile App Security Testing_ A Comprehensive Guide.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
A Presentation on Artificial Intelligence
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Chapter 3 Spatial Domain Image Processing.pdf
cuic standard and advanced reporting.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Digital-Transformation-Roadmap-for-Companies.pptx
NewMind AI Weekly Chronicles - August'25 Week I
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Dropbox Q2 2025 Financial Results & Investor Presentation
NewMind AI Monthly Chronicles - July 2025
Teaching material agriculture food technology

Scaling Web Apps P Falcone

  • 1. Scaling your PHP Web Applications (a.k.a. make your web applications alive and still responsive even with thousands of users hammering your site per second)‏
  • 2. There is no silver bullet Merely adding more servers, or buying the hype for some exotic architecture, or getting that ultra-expensive technology will not make your web application scale in the long run.
  • 3. Start with the fundamentals in coding Design your code to be testable at all levels Know your data structures and algorithms Design your application with eventual change in mind
  • 4. Design your code to be testable at all levels Write unit and integration tests that test both behavior and outcome in positive and error conditions. The design of classes and functions affect testability.
  • 5. Know your data structures and algorithms Inelegant data structures and algorithms collapse when subjected to high load due to protracted run times and insane memory usage Certain problems will require different algorithms and data structures to be deployed, and will have to be deployed and used by your application differently
  • 6. Design your application with eventual change in mind Make classes and functions that do only one thing and do it well Favor loose coupling of dependencies Improve on software design patterns that promote extensible design Eventually you will replace pieces of your application with better parts
  • 7. Going further Getting rid of obvious boo-boos Using an RDBMS Caching Know how and when to take advantage of the language Further tuning the performance of your application
  • 8. Getting rid of obvious boo-boos Avoid multiple loops over the same structure when processing Simpler usually means better – you do not need to bring out tanks to crush ants Reserve use of encryption to where you really need it.
  • 9. Using an RDBMS A relational database is primarily intended to store relational data You won't miss doing referential integrity checks at the database level Forget about using SQL JOIN in a live web application Query in chunks when the data set is huge Favor a bulk database query rather than doing multiple loops with the same database query Make judicious use of database indexes during queries
  • 10. Caching To avoid expensive page rebuilds, use output page caching – PHP has output buffering (via the ob_ functions) by default, and there are libraries that abstract this functionality Reduce compile time for redundant objects by using op-code caching (e.g. APC , eAccelerator , XCache )‏ Take a look at other caching strategies (e.g. CDN, caching HTTP proxies, memcached )‏ If you are using memcached , chunk entries into smaller collections rather than storing very big objects in cache. Cache database results as much as you can
  • 11. Know how and when to take advantage of the language PHP isset() is implemented as a hash table – consider using this over the function in_array() for huge array searches PHP evaluates strings within single quotes faster than strings within double quotes Consider passing references rather than copies of objects and arrays to save memory The ctype_ functions are faster than using regular expression testing for validating types
  • 12. Further tuning the performance of your application Optimize and profile your database queries so that the results will fit in memory Do performance tests that simulate real-world conditions to ensure your application survives high loads. Profile the code to find out bottle necks and excessive calls – there are tools like APD and Xdebug to aid in this task. Know the capabilities and limitations of your application's dependencies and tune according to the purpose of the said dependency, or replace them.
  • 13. Surviving the horde Employing asynchronous and parallel computing techniques Knowing when to use the better tools for the job Spreading your application's infrastructure across many machines Employing a service oriented architecture
  • 14. Employing asynchronous and parallel computing techniques Responsiveness is a highly desirable goal. Do not put long running routines on code that will be rendered by the application. Consider using a queueing service for long running tasks. Maximize parallelism. Some tasks can be executed off-line and in parallel as long as they do not lock on the same resources.
  • 15. Knowing when to use the better tools for the job Consider writing extensions for commonly-used functions that are not practical (speed-wise) to implement in PHP, yet require to constantly interact with PHP Parallel distributed computing, or any computing that requires concurrency (e.g. threads, shared memory, map-reduce) is outside PHP's strengths. You may consider using more appropriate tools (MPI, etc)‏ Sometimes the filesystem is better than a database.
  • 16. Spreading your application's infrastructure across many machines Your application will vertically-scale up to a certain point – after which you have to start considering employing more machines for better throughput. Depending on a couple of factors (e.g. CPU intensiveness, network traffic, e.g.) - some application dependencies will have to be deployed on their own clusters (e.g. databases), while some can be bundled together with the application, in order for the application to remain responsive.
  • 17. Employing a service-oriented architecture This allows replacement and isolation of component dependencies much easier as component dependencies are designed to perform one task and perform them well, while isolating problems is reduced to targeting the service responsible. The use of persistent connections to resources (e.g. databases, cache, etc) from services (to save memory, multiplex requests, etc) scales better than having all application servers connect directly to the resources.
  • 18. After everything else... Throwing money at the problem would probably work