SlideShare a Scribd company logo
1 of 22
Download to read offline
Scaling Web Applications
Scaling Web Applications



                                      Mihai Oaida
    Senior Web Developer @ www.imobiliare.ro
    Student , Politehnica Timișoara
    Web technologies instructor
      www.tehnologii-web.ro




Mihai Oaida <mihai.oaida@gmail.com>                 00
Scaling Web Applications



                        We will talk about ...
    Facts
    Theory + Myths
    Architecture
    Static content
    Dynamic content
    Caching




Mihai Oaida <mihai.oaida@gmail.com>              01
Scaling Web Applications



                      Web application facts
    Mostly stateless
    Very read intensive ( > 90% )
    Not so dynamic
    Can be fine grained

    Highly scalable, if designed to :)




Mihai Oaida <mihai.oaida@gmail.com>           02
Scaling Web Applications



                               Hardware facts
    Limited context switching
    Limited opened files
    Very limited random IO
    Limited sequential IO
    Limited RAM




Mihai Oaida <mihai.oaida@gmail.com>             03
Scaling Web Applications



                Scalability vs Performance
    Scalability
      how many

    Performance
      how fast

    Scalability + Performance
      how many and how fast

Mihai Oaida <mihai.oaida@gmail.com>          04
Scaling Web Applications



                       Vertical vs Horizontal
    Vertical Scaling
      Bigger server
      2X capacity != 2x price

    Horizontal Scaling
      More identical servers
      2X capacity ≈ 2x price



Mihai Oaida <mihai.oaida@gmail.com>             05
Scaling Web Applications



               Benchmarking and Profiling
    Benchmarking
      How fast a page loads, under certain
    conditions

    Profiling
      In a page execution, how much time each
    component consumes



Mihai Oaida <mihai.oaida@gmail.com>          06
Scaling Web Applications



               Benchmarking and Profiling
    Benchmarking
      Page / site performance?
      Page / site scalability ?

    Profiling
      What is the bottleneck?




Mihai Oaida <mihai.oaida@gmail.com>         07
Scaling Web Applications



               Benchmarking and Profiling
    Prepare tests
    Expect results
    Run repeatable tests
    Analyse data
    Interpret data correctly !!!




Mihai Oaida <mihai.oaida@gmail.com>         08
Scaling Web Applications



                                      Architecture
    Web server – dynamic, static content
    Database server
    Caching server

    + load balancer
    + network equipment




Mihai Oaida <mihai.oaida@gmail.com>                  09
Scaling Web Applications



           Static content - HTTP optimization
    Use Expires and Last-Modified headers
    Use sprites for images
    Merge css files
    Merge js files
    Use compression – gzip
    Use multiple subdomains
      img1.tehnologii-web.ro
      img2.tehnologii-web.ro

Mihai Oaida <mihai.oaida@gmail.com>             10
Scaling Web Applications



                         Static content - Server
    Use dedicated server(s) just for static
    Use asynchronous web servers
      Lighthttpd, nginx




    Or,
    Just use a CDN ( Content delivery network )

Mihai Oaida <mihai.oaida@gmail.com>                11
Scaling Web Applications



                             Dynamic content
    Usually web servers are not the bottleneck

    Code optimization
      Use less RAM and less CPU
      good performance!= good scalability
    For PHP
      Opcode cache : xCache, apc, eAccelarator



Mihai Oaida <mihai.oaida@gmail.com>              12
Scaling Web Applications



                             Dynamic content
    Dynamic = 0.x% static + 0.y% dynamic ?

    Can real-time data have a 5 minute delay ?



    Batch writes
    Pre-cache



Mihai Oaida <mihai.oaida@gmail.com>              13
Scaling Web Applications



                          Database - general
    Choose an open-source one that has proven
    to scale: MySQL :)

    Use Master – Slave architecture
      Write on master(s)
      Read from slaves




Mihai Oaida <mihai.oaida@gmail.com>            14
Scaling Web Applications



                                      Database
    Don't run on the default configuration

    key_buffer, query cache, sort buffer, etc

    All need tuning as data changes




Mihai Oaida <mihai.oaida@gmail.com>              15
Scaling Web Applications



                                      Database
    Use indexes – don't index everything
    Create very selective indexes, high
    cardinality
    Join tables very carefully
    Denormalize




Mihai Oaida <mihai.oaida@gmail.com>              16
Scaling Web Applications



                                      Database
    Optimize queries
    Use DESCRIBE command
    Activate slow query log and monitor it!




Mihai Oaida <mihai.oaida@gmail.com>              17
Scaling Web Applications



                             Cache - Memcache
    Asynchronous server
    No authentication
    Key value database
    In memory
    Very scalable
    Has api in many languages
    Small limitations



Mihai Oaida <mihai.oaida@gmail.com>             18
Scaling Web Applications



                                      Conclusions
    There is no secret recipe, no easy solution
    It is very application specific

    To scale you need not only the right tools
    but the right thinking!




Mihai Oaida <mihai.oaida@gmail.com>                 19
Scaling Web Applications




                              Questions?



Mihai Oaida <mihai.oaida@gmail.com>        20

More Related Content

What's hot

Introduction to ajax
Introduction  to  ajaxIntroduction  to  ajax
Introduction to ajaxPihu Goel
 
The BestBuy.com Cloud Architecture
The BestBuy.com Cloud ArchitectureThe BestBuy.com Cloud Architecture
The BestBuy.com Cloud Architecturejoelcrabb
 
How to Develop and Deploy Web-Scale Applications on AWS
How to Develop and Deploy Web-Scale Applications on AWSHow to Develop and Deploy Web-Scale Applications on AWS
How to Develop and Deploy Web-Scale Applications on AWSDatabarracks
 
Cloud Expo Europe 2014: Practical methods to improve your security in the cloud
Cloud Expo Europe 2014: Practical methods to improve your security in the cloudCloud Expo Europe 2014: Practical methods to improve your security in the cloud
Cloud Expo Europe 2014: Practical methods to improve your security in the cloudDatabarracks
 
Cloud migrations Experiences from the Field
Cloud migrations Experiences from the FieldCloud migrations Experiences from the Field
Cloud migrations Experiences from the FieldMariano Kovo
 
Supersizing Magento
Supersizing MagentoSupersizing Magento
Supersizing MagentoClustrix
 
Building Better WordPress Sites
Building Better WordPress SitesBuilding Better WordPress Sites
Building Better WordPress SitesBrian LaFrance
 
A Simpler Web App Architecture (jDays 2016)
A Simpler Web App Architecture (jDays 2016)A Simpler Web App Architecture (jDays 2016)
A Simpler Web App Architecture (jDays 2016)Gustaf Nilsson Kotte
 
Scale out magento 2 at aws
Scale out magento 2 at awsScale out magento 2 at aws
Scale out magento 2 at awsroot360 GmbH
 
Grokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKIGrokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKIGrokking VN
 
Pyramid Analytics vs Sisense
Pyramid Analytics vs SisensePyramid Analytics vs Sisense
Pyramid Analytics vs SisensePyramid Analytics
 
Windows azure learning poster
Windows azure learning posterWindows azure learning poster
Windows azure learning posterMahmoud Moussa
 
Cloud computing
Cloud computingCloud computing
Cloud computinghwalice666
 
雲端運算 英文Ppt
雲端運算 英文Ppt雲端運算 英文Ppt
雲端運算 英文Ppthwalice666
 

What's hot (20)

Introduction to ajax
Introduction  to  ajaxIntroduction  to  ajax
Introduction to ajax
 
The BestBuy.com Cloud Architecture
The BestBuy.com Cloud ArchitectureThe BestBuy.com Cloud Architecture
The BestBuy.com Cloud Architecture
 
How to Develop and Deploy Web-Scale Applications on AWS
How to Develop and Deploy Web-Scale Applications on AWSHow to Develop and Deploy Web-Scale Applications on AWS
How to Develop and Deploy Web-Scale Applications on AWS
 
Ajax
AjaxAjax
Ajax
 
Cloud Expo Europe 2014: Practical methods to improve your security in the cloud
Cloud Expo Europe 2014: Practical methods to improve your security in the cloudCloud Expo Europe 2014: Practical methods to improve your security in the cloud
Cloud Expo Europe 2014: Practical methods to improve your security in the cloud
 
Careers In Java Script Ajax - Java Script Ajax Tutorials & Programs by Learni...
Careers In Java Script Ajax - Java Script Ajax Tutorials & Programs by Learni...Careers In Java Script Ajax - Java Script Ajax Tutorials & Programs by Learni...
Careers In Java Script Ajax - Java Script Ajax Tutorials & Programs by Learni...
 
The RAW stack
The RAW stackThe RAW stack
The RAW stack
 
Cloud migrations Experiences from the Field
Cloud migrations Experiences from the FieldCloud migrations Experiences from the Field
Cloud migrations Experiences from the Field
 
Supersizing Magento
Supersizing MagentoSupersizing Magento
Supersizing Magento
 
Building Better WordPress Sites
Building Better WordPress SitesBuilding Better WordPress Sites
Building Better WordPress Sites
 
A Simpler Web App Architecture (jDays 2016)
A Simpler Web App Architecture (jDays 2016)A Simpler Web App Architecture (jDays 2016)
A Simpler Web App Architecture (jDays 2016)
 
Mern stack developement
Mern stack developementMern stack developement
Mern stack developement
 
Pyramid vs QlikView
Pyramid vs QlikViewPyramid vs QlikView
Pyramid vs QlikView
 
Scale out magento 2 at aws
Scale out magento 2 at awsScale out magento 2 at aws
Scale out magento 2 at aws
 
Grokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKIGrokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKI
 
Pyramid Analytics vs Sisense
Pyramid Analytics vs SisensePyramid Analytics vs Sisense
Pyramid Analytics vs Sisense
 
Windows azure learning poster
Windows azure learning posterWindows azure learning poster
Windows azure learning poster
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
雲端運算 英文Ppt
雲端運算 英文Ppt雲端運算 英文Ppt
雲端運算 英文Ppt
 

Viewers also liked

Notiuni avansate MySQL - Infoeducatie 2008
Notiuni avansate MySQL - Infoeducatie 2008Notiuni avansate MySQL - Infoeducatie 2008
Notiuni avansate MySQL - Infoeducatie 2008Mihai Oaida
 
jQuery - GeekMeet Timisoara
jQuery - GeekMeet TimisoarajQuery - GeekMeet Timisoara
jQuery - GeekMeet TimisoaraMihai Oaida
 
Arhitecturi de cacheing server side - LVLE 2009
Arhitecturi de cacheing server side - LVLE 2009Arhitecturi de cacheing server side - LVLE 2009
Arhitecturi de cacheing server side - LVLE 2009Mihai Oaida
 
Teme - Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
Teme - Proiectarea si normalizarea bazelor de date - Infoeducatie 2008Teme - Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
Teme - Proiectarea si normalizarea bazelor de date - Infoeducatie 2008Mihai Oaida
 
Notiuni avansate MySQL - LVLE 2009
Notiuni avansate MySQL - LVLE 2009Notiuni avansate MySQL - LVLE 2009
Notiuni avansate MySQL - LVLE 2009Mihai Oaida
 
Linux/Unix-based Operating Systems
Linux/Unix-based Operating SystemsLinux/Unix-based Operating Systems
Linux/Unix-based Operating SystemsMihai Oaida
 

Viewers also liked (7)

Notiuni avansate MySQL - Infoeducatie 2008
Notiuni avansate MySQL - Infoeducatie 2008Notiuni avansate MySQL - Infoeducatie 2008
Notiuni avansate MySQL - Infoeducatie 2008
 
K-Means
K-MeansK-Means
K-Means
 
jQuery - GeekMeet Timisoara
jQuery - GeekMeet TimisoarajQuery - GeekMeet Timisoara
jQuery - GeekMeet Timisoara
 
Arhitecturi de cacheing server side - LVLE 2009
Arhitecturi de cacheing server side - LVLE 2009Arhitecturi de cacheing server side - LVLE 2009
Arhitecturi de cacheing server side - LVLE 2009
 
Teme - Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
Teme - Proiectarea si normalizarea bazelor de date - Infoeducatie 2008Teme - Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
Teme - Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
 
Notiuni avansate MySQL - LVLE 2009
Notiuni avansate MySQL - LVLE 2009Notiuni avansate MySQL - LVLE 2009
Notiuni avansate MySQL - LVLE 2009
 
Linux/Unix-based Operating Systems
Linux/Unix-based Operating SystemsLinux/Unix-based Operating Systems
Linux/Unix-based Operating Systems
 

Similar to Scaling web-applications

reModernize - Updating & Consolidating MySQL
reModernize - Updating & Consolidating MySQLreModernize - Updating & Consolidating MySQL
reModernize - Updating & Consolidating MySQLAmazon Web Services
 
Microservices & Data Design: Database Week SF
Microservices & Data Design: Database Week SFMicroservices & Data Design: Database Week SF
Microservices & Data Design: Database Week SFAmazon Web Services
 
Microservices and Data Design
Microservices and Data DesignMicroservices and Data Design
Microservices and Data DesignAWS Germany
 
Microservices & Data Design: Database Week San Francisco
Microservices & Data Design: Database Week San FranciscoMicroservices & Data Design: Database Week San Francisco
Microservices & Data Design: Database Week San FranciscoAmazon Web Services
 
OaaS - Operations as a Service
OaaS - Operations as a ServiceOaaS - Operations as a Service
OaaS - Operations as a Serviceian236
 
Website development
Website developmentWebsite development
Website developmentAnurag Gupta
 
Optimization 2020 | Using Edge SEO For Technical Issues ft. Dan Taylor
Optimization 2020 | Using Edge SEO For Technical Issues ft. Dan TaylorOptimization 2020 | Using Edge SEO For Technical Issues ft. Dan Taylor
Optimization 2020 | Using Edge SEO For Technical Issues ft. Dan TaylorDan Taylor
 
Introducing dashDB MPP: The Power of Data Warehousing in the Cloud
Introducing dashDB MPP: The Power of Data Warehousing in the CloudIntroducing dashDB MPP: The Power of Data Warehousing in the Cloud
Introducing dashDB MPP: The Power of Data Warehousing in the CloudIBM Cloud Data Services
 
Scaling wix.com to 100 million users
Scaling wix.com to 100 million users Scaling wix.com to 100 million users
Scaling wix.com to 100 million users Aviran Mordo
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
CDS Overview (May 2015)
CDS Overview (May 2015)CDS Overview (May 2015)
CDS Overview (May 2015)Karim Lalji
 
Migrating Microsoft Applications to AWS like an Expert
Migrating Microsoft Applications to AWS like an ExpertMigrating Microsoft Applications to AWS like an Expert
Migrating Microsoft Applications to AWS like an ExpertInjae Kwak
 
Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)
Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)
Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)Ido Green
 
IBM THINK 2020 - Cloud Data Lake with IBM Cloud Data Services
IBM THINK 2020 - Cloud Data Lake with IBM Cloud Data Services IBM THINK 2020 - Cloud Data Lake with IBM Cloud Data Services
IBM THINK 2020 - Cloud Data Lake with IBM Cloud Data Services Torsten Steinbach
 
Real-Time Web Analytics with Amazon Kinesis Data Analytics (ADT401) - AWS re:...
Real-Time Web Analytics with Amazon Kinesis Data Analytics (ADT401) - AWS re:...Real-Time Web Analytics with Amazon Kinesis Data Analytics (ADT401) - AWS re:...
Real-Time Web Analytics with Amazon Kinesis Data Analytics (ADT401) - AWS re:...Amazon Web Services
 
Web Application Development Fundamentals
Web Application Development FundamentalsWeb Application Development Fundamentals
Web Application Development FundamentalsMohammed Makhlouf
 
Scaling wix to over 70 m users
Scaling wix to over 70 m usersScaling wix to over 70 m users
Scaling wix to over 70 m usersYoav Avrahami
 
IBM Cloud Storage - Cleversafe
IBM Cloud Storage - CleversafeIBM Cloud Storage - Cleversafe
IBM Cloud Storage - CleversafeMichael Beatty
 

Similar to Scaling web-applications (20)

Data Design for Microservices
Data Design for MicroservicesData Design for Microservices
Data Design for Microservices
 
reModernize - Updating & Consolidating MySQL
reModernize - Updating & Consolidating MySQLreModernize - Updating & Consolidating MySQL
reModernize - Updating & Consolidating MySQL
 
Microservices & Data Design: Database Week SF
Microservices & Data Design: Database Week SFMicroservices & Data Design: Database Week SF
Microservices & Data Design: Database Week SF
 
Microservices and Data Design
Microservices and Data DesignMicroservices and Data Design
Microservices and Data Design
 
Microservices & Data Design: Database Week San Francisco
Microservices & Data Design: Database Week San FranciscoMicroservices & Data Design: Database Week San Francisco
Microservices & Data Design: Database Week San Francisco
 
OaaS - Operations as a Service
OaaS - Operations as a ServiceOaaS - Operations as a Service
OaaS - Operations as a Service
 
Website development
Website developmentWebsite development
Website development
 
Optimization 2020 | Using Edge SEO For Technical Issues ft. Dan Taylor
Optimization 2020 | Using Edge SEO For Technical Issues ft. Dan TaylorOptimization 2020 | Using Edge SEO For Technical Issues ft. Dan Taylor
Optimization 2020 | Using Edge SEO For Technical Issues ft. Dan Taylor
 
Introducing dashDB MPP: The Power of Data Warehousing in the Cloud
Introducing dashDB MPP: The Power of Data Warehousing in the CloudIntroducing dashDB MPP: The Power of Data Warehousing in the Cloud
Introducing dashDB MPP: The Power of Data Warehousing in the Cloud
 
Scaling wix.com to 100 million users
Scaling wix.com to 100 million users Scaling wix.com to 100 million users
Scaling wix.com to 100 million users
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Microservices & Data Design
Microservices & Data DesignMicroservices & Data Design
Microservices & Data Design
 
CDS Overview (May 2015)
CDS Overview (May 2015)CDS Overview (May 2015)
CDS Overview (May 2015)
 
Migrating Microsoft Applications to AWS like an Expert
Migrating Microsoft Applications to AWS like an ExpertMigrating Microsoft Applications to AWS like an Expert
Migrating Microsoft Applications to AWS like an Expert
 
Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)
Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)
Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)
 
IBM THINK 2020 - Cloud Data Lake with IBM Cloud Data Services
IBM THINK 2020 - Cloud Data Lake with IBM Cloud Data Services IBM THINK 2020 - Cloud Data Lake with IBM Cloud Data Services
IBM THINK 2020 - Cloud Data Lake with IBM Cloud Data Services
 
Real-Time Web Analytics with Amazon Kinesis Data Analytics (ADT401) - AWS re:...
Real-Time Web Analytics with Amazon Kinesis Data Analytics (ADT401) - AWS re:...Real-Time Web Analytics with Amazon Kinesis Data Analytics (ADT401) - AWS re:...
Real-Time Web Analytics with Amazon Kinesis Data Analytics (ADT401) - AWS re:...
 
Web Application Development Fundamentals
Web Application Development FundamentalsWeb Application Development Fundamentals
Web Application Development Fundamentals
 
Scaling wix to over 70 m users
Scaling wix to over 70 m usersScaling wix to over 70 m users
Scaling wix to over 70 m users
 
IBM Cloud Storage - Cleversafe
IBM Cloud Storage - CleversafeIBM Cloud Storage - Cleversafe
IBM Cloud Storage - Cleversafe
 

More from Mihai Oaida

Advanced Mysql - GeekMeet Timisoara
Advanced Mysql - GeekMeet TimisoaraAdvanced Mysql - GeekMeet Timisoara
Advanced Mysql - GeekMeet TimisoaraMihai Oaida
 
Notiuni avansate MySQL - Infoeducatie 2009
Notiuni avansate MySQL - Infoeducatie 2009Notiuni avansate MySQL - Infoeducatie 2009
Notiuni avansate MySQL - Infoeducatie 2009Mihai Oaida
 
jQuery - Infoeducatie 2008
jQuery - Infoeducatie 2008jQuery - Infoeducatie 2008
jQuery - Infoeducatie 2008Mihai Oaida
 
Arhitecturi de caching server-side - Infoeducatie 2008
Arhitecturi de caching server-side - Infoeducatie 2008 Arhitecturi de caching server-side - Infoeducatie 2008
Arhitecturi de caching server-side - Infoeducatie 2008 Mihai Oaida
 
Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
Proiectarea si normalizarea bazelor de date - Infoeducatie 2008Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
Proiectarea si normalizarea bazelor de date - Infoeducatie 2008Mihai Oaida
 
Arhitectura Si Managementul Proiectelor - Infoeducatie 2007
Arhitectura Si Managementul Proiectelor - Infoeducatie 2007Arhitectura Si Managementul Proiectelor - Infoeducatie 2007
Arhitectura Si Managementul Proiectelor - Infoeducatie 2007Mihai Oaida
 

More from Mihai Oaida (6)

Advanced Mysql - GeekMeet Timisoara
Advanced Mysql - GeekMeet TimisoaraAdvanced Mysql - GeekMeet Timisoara
Advanced Mysql - GeekMeet Timisoara
 
Notiuni avansate MySQL - Infoeducatie 2009
Notiuni avansate MySQL - Infoeducatie 2009Notiuni avansate MySQL - Infoeducatie 2009
Notiuni avansate MySQL - Infoeducatie 2009
 
jQuery - Infoeducatie 2008
jQuery - Infoeducatie 2008jQuery - Infoeducatie 2008
jQuery - Infoeducatie 2008
 
Arhitecturi de caching server-side - Infoeducatie 2008
Arhitecturi de caching server-side - Infoeducatie 2008 Arhitecturi de caching server-side - Infoeducatie 2008
Arhitecturi de caching server-side - Infoeducatie 2008
 
Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
Proiectarea si normalizarea bazelor de date - Infoeducatie 2008Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
Proiectarea si normalizarea bazelor de date - Infoeducatie 2008
 
Arhitectura Si Managementul Proiectelor - Infoeducatie 2007
Arhitectura Si Managementul Proiectelor - Infoeducatie 2007Arhitectura Si Managementul Proiectelor - Infoeducatie 2007
Arhitectura Si Managementul Proiectelor - Infoeducatie 2007
 

Scaling web-applications

  • 2. Scaling Web Applications Mihai Oaida Senior Web Developer @ www.imobiliare.ro Student , Politehnica Timișoara Web technologies instructor www.tehnologii-web.ro Mihai Oaida <mihai.oaida@gmail.com> 00
  • 3. Scaling Web Applications We will talk about ... Facts Theory + Myths Architecture Static content Dynamic content Caching Mihai Oaida <mihai.oaida@gmail.com> 01
  • 4. Scaling Web Applications Web application facts Mostly stateless Very read intensive ( > 90% ) Not so dynamic Can be fine grained Highly scalable, if designed to :) Mihai Oaida <mihai.oaida@gmail.com> 02
  • 5. Scaling Web Applications Hardware facts Limited context switching Limited opened files Very limited random IO Limited sequential IO Limited RAM Mihai Oaida <mihai.oaida@gmail.com> 03
  • 6. Scaling Web Applications Scalability vs Performance Scalability how many Performance how fast Scalability + Performance how many and how fast Mihai Oaida <mihai.oaida@gmail.com> 04
  • 7. Scaling Web Applications Vertical vs Horizontal Vertical Scaling Bigger server 2X capacity != 2x price Horizontal Scaling More identical servers 2X capacity ≈ 2x price Mihai Oaida <mihai.oaida@gmail.com> 05
  • 8. Scaling Web Applications Benchmarking and Profiling Benchmarking How fast a page loads, under certain conditions Profiling In a page execution, how much time each component consumes Mihai Oaida <mihai.oaida@gmail.com> 06
  • 9. Scaling Web Applications Benchmarking and Profiling Benchmarking Page / site performance? Page / site scalability ? Profiling What is the bottleneck? Mihai Oaida <mihai.oaida@gmail.com> 07
  • 10. Scaling Web Applications Benchmarking and Profiling Prepare tests Expect results Run repeatable tests Analyse data Interpret data correctly !!! Mihai Oaida <mihai.oaida@gmail.com> 08
  • 11. Scaling Web Applications Architecture Web server – dynamic, static content Database server Caching server + load balancer + network equipment Mihai Oaida <mihai.oaida@gmail.com> 09
  • 12. Scaling Web Applications Static content - HTTP optimization Use Expires and Last-Modified headers Use sprites for images Merge css files Merge js files Use compression – gzip Use multiple subdomains img1.tehnologii-web.ro img2.tehnologii-web.ro Mihai Oaida <mihai.oaida@gmail.com> 10
  • 13. Scaling Web Applications Static content - Server Use dedicated server(s) just for static Use asynchronous web servers Lighthttpd, nginx Or, Just use a CDN ( Content delivery network ) Mihai Oaida <mihai.oaida@gmail.com> 11
  • 14. Scaling Web Applications Dynamic content Usually web servers are not the bottleneck Code optimization Use less RAM and less CPU good performance!= good scalability For PHP Opcode cache : xCache, apc, eAccelarator Mihai Oaida <mihai.oaida@gmail.com> 12
  • 15. Scaling Web Applications Dynamic content Dynamic = 0.x% static + 0.y% dynamic ? Can real-time data have a 5 minute delay ? Batch writes Pre-cache Mihai Oaida <mihai.oaida@gmail.com> 13
  • 16. Scaling Web Applications Database - general Choose an open-source one that has proven to scale: MySQL :) Use Master – Slave architecture Write on master(s) Read from slaves Mihai Oaida <mihai.oaida@gmail.com> 14
  • 17. Scaling Web Applications Database Don't run on the default configuration key_buffer, query cache, sort buffer, etc All need tuning as data changes Mihai Oaida <mihai.oaida@gmail.com> 15
  • 18. Scaling Web Applications Database Use indexes – don't index everything Create very selective indexes, high cardinality Join tables very carefully Denormalize Mihai Oaida <mihai.oaida@gmail.com> 16
  • 19. Scaling Web Applications Database Optimize queries Use DESCRIBE command Activate slow query log and monitor it! Mihai Oaida <mihai.oaida@gmail.com> 17
  • 20. Scaling Web Applications Cache - Memcache Asynchronous server No authentication Key value database In memory Very scalable Has api in many languages Small limitations Mihai Oaida <mihai.oaida@gmail.com> 18
  • 21. Scaling Web Applications Conclusions There is no secret recipe, no easy solution It is very application specific To scale you need not only the right tools but the right thinking! Mihai Oaida <mihai.oaida@gmail.com> 19
  • 22. Scaling Web Applications Questions? Mihai Oaida <mihai.oaida@gmail.com> 20