SlideShare una empresa de Scribd logo
1 de 30
Website Optimisation




   CLUG March 2012
contents
Network
Compression
HTTP Caching
Structuring
Measurement
Application Caching
Monitoring
contents
                             Client
Network
Compression
HTTP Caching
Structuring
Measurement
Application Caching
Database tuning
Monitoring                   Server
Network
mtr ­c 10 ­r www.openquery.com
HOST: spaceman.localhost          
 Loss%   Snt   Last   Avg  Best  
 Wrst StDev
  1.|­­ 192.168.1.1                
 0.0%    10    0.8   2.6   0.7  19.3 
   5.8
  2.|­­ 192.168.3.254              
 0.0%    10    1.1   1.2   1.1   1.5 
   0.1
Network (DNS)
Check whois is showing the right nameserver
  whois openquery.com
   NS1.LINODE.COM

   NS2.LINODE.COM

   NS3.LINODE.COM

   NS4.LINODE.COM

   NS1.CREATIVECONTINGENCIES.COM

   NS2.CREATIVECONTINGENCIES.COM

   NS3.CREATIVECONTINGENCIES.COM


Ensure correct record is returned by querying
 each nameserver
dig www.openquery.com @ns1.creativecontingencies.com
Network (SSL/TLS)
Network (SSL/TLS)




Session Tickets - 8 packets 3 roundtrips before application data
EDH crypto – computational expensive by has perfect forwards secrecy
Network (HTTP keep-alive)

Request / Response header
Connection:keep-alive


On by default. Can't handle variable length pages
Compression
Gzip/deflate
Compression
Apache's HTTPd
  Enable mod_deflate
<IfModule mod_deflate.c>
    SetOutputFilter DEFLATE
</IfModule>
Lighty
  Enable “mod_compress” in server.modules
Nginx
  gzip on;
Compression
PHP
 Php.ini   zlib.output_compression On
HTTP Caching
RFC 2616 Hypertext Transfer Protocol –
 HTTP/1.1
HTTP Caching
Etag
  Unique string – usual some form of digest


Browsers request with HTTP header:
If-None-Match: “uniquestring....”
Server response: 304 not modified if nothing
 changes
HTTP Caching (Etag)
HTTPd
FileETag Mtime
HTTP Caching (Expires)
HTTP Response header
Expires: Thu, 01 Dec 2012 16:00:00 GMT
Date:Thu, 22 Mar 2012 01:00:17 GMT
Last-Modified:Sun, 11 Mar 2012 20:55:16 GMT


HTTP Request
If-Modified-Since: Sat, 29 Oct 1994 19:43:31
   GMT
HTTP Caching (Cache-Control)
 Cache-Control = "Cache-Control" ":"
1#cache-directive


cache-directive = cache-request-directive
   | cache-response-directive


cache-request-directive =
     "no-cache"                 ; Section
14.9.1
Gzip + Caching
                               Savings
                               On initial response: 104.2K (vs 255.6K) / 44
trunk/roundcubemail/.htaccess ¶ requests)

<IfModule mod_deflate.c>next page: 6.2K 2 requests (vs 204.7K / 44
                      On
                       requests)
SetOutputFilter DEFLATE
</IfModule>


<IfModule mod_headers.c>
# replace 'append' with 'merge' for Apache
  version 2.2.9 and later
Header append Cache-Control public env=!
Use Yslow / Firebug
                      Structuring
Measurement
Measurement (Application)
create table `timings` ( `id` int(4) NOT NULL
  AUTO_INCREMENT, 'host' varchar(20),'page'
  varchar(120), int t1,int t2, int t3.....)


And in the index.php


$sample = rand(0,100) < 5; # 5% sample rate


if ($sample) $t0 = microtime(TRUE);
Application Caching
Be strategic – cost / benefit
Hard to generate – graphs, database queries,
 complex maths
Frequent pages: front pages, rss, ajax
Application Caching (duplicate)
  if (!$db->count('name',             $name,
   DB_CACHE))
       {
       // if no cache entry exists, fetch the
  appropriate html and insert
...


       } else {
           // row exists - determine if it is still valid
Application Caching
Cache an entire page
Memcache is your friend – RAM, autoexpire,
 overload intelligent expire
Share between servers
Nice API in all languages
  e.g. PHP
  public mixed Memcached::get ( string $key [, callable
    $cache_cb [, float &$cas_token ]] )
Application scaling
If the application scales by adding webservers
   you will save on hosting on high power servers


Ensure application is stateless
Reverse proxy state-full bits to central server if
 needed
CDNs or separated servers for static content
 saves lots of cpu (latency, keep alives)
Application APC




Graph from apc.php as part of the php_apc package
Database
Know what indexes are and which queries aren't
 using them.
EXPLAIN {sql expression} (Postgresql and Mysql)
EXPLAIN ANALYSE {sql expression}
Slow query log – enable
Know differences between MySQL engines
Tune your server
  Defaults well out of proportion with your sever.
Database (continued)
Searching text in SQL – Use Sphinxsearch
 instead
Same sql interfaces, pulls off database – much
 quicker at full text search
Databases (application)
Eventually one DB will be too little
Plan to buy big hardware (Oracle) or plan to use
  a replicated database (for reads)
Some reads will need to occur on the master.
 The ones where the data was likely just
 changed very recently
Monitoring
Monitoring
Include resource usage
Cpu / RAM / processes / forking / swap / IO /
 Bandwidth...
Web server – pages/second, threads
Database – query cache hits/misses,
 connections, replication delay
Business value: page load time.
Alert if boundaries exceeded

Más contenido relacionado

La actualidad más candente

Pgbr 2013 postgres on aws
Pgbr 2013   postgres on awsPgbr 2013   postgres on aws
Pgbr 2013 postgres on aws
Emanuel Calvo
 

La actualidad más candente (19)

Setting up mongodb sharded cluster in 30 minutes
Setting up mongodb sharded cluster in 30 minutesSetting up mongodb sharded cluster in 30 minutes
Setting up mongodb sharded cluster in 30 minutes
 
MySQL Monitoring using Prometheus & Grafana
MySQL Monitoring using Prometheus & GrafanaMySQL Monitoring using Prometheus & Grafana
MySQL Monitoring using Prometheus & Grafana
 
Caching
CachingCaching
Caching
 
Oscon 2010 - ATS
Oscon 2010 - ATSOscon 2010 - ATS
Oscon 2010 - ATS
 
Postgres connections at scale
Postgres connections at scalePostgres connections at scale
Postgres connections at scale
 
10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production
 
High Performance Wordpress
High Performance WordpressHigh Performance Wordpress
High Performance Wordpress
 
Building Scalable Web Apps - LVL.UP KL
Building Scalable Web Apps - LVL.UP KLBuilding Scalable Web Apps - LVL.UP KL
Building Scalable Web Apps - LVL.UP KL
 
Streaming replication in PostgreSQL
Streaming replication in PostgreSQLStreaming replication in PostgreSQL
Streaming replication in PostgreSQL
 
Aerospike Go Language Client
Aerospike Go Language ClientAerospike Go Language Client
Aerospike Go Language Client
 
Caching methodology and strategies
Caching methodology and strategiesCaching methodology and strategies
Caching methodology and strategies
 
To Hire, or to train, that is the question (Percona Live 2014)
To Hire, or to train, that is the question (Percona Live 2014)To Hire, or to train, that is the question (Percona Live 2014)
To Hire, or to train, that is the question (Percona Live 2014)
 
Pgbr 2013 postgres on aws
Pgbr 2013   postgres on awsPgbr 2013   postgres on aws
Pgbr 2013 postgres on aws
 
Mysqlnd query cache plugin benchmark report
Mysqlnd query cache plugin benchmark reportMysqlnd query cache plugin benchmark report
Mysqlnd query cache plugin benchmark report
 
Background Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbitBackground Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbit
 
Accelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket CacheAccelerating HBase with NVMe and Bucket Cache
Accelerating HBase with NVMe and Bucket Cache
 
Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)Out of the box replication in postgres 9.4(pg confus)
Out of the box replication in postgres 9.4(pg confus)
 
Load Balancing with Nginx
Load Balancing with NginxLoad Balancing with Nginx
Load Balancing with Nginx
 
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, HerokuPostgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
 

Similar a Clug 2011 March web server optimisation

WE18_Performance_Up.ppt
WE18_Performance_Up.pptWE18_Performance_Up.ppt
WE18_Performance_Up.ppt
webhostingguy
 
Scalable Apache for Beginners
Scalable Apache for BeginnersScalable Apache for Beginners
Scalable Apache for Beginners
webhostingguy
 

Similar a Clug 2011 March web server optimisation (20)

DrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performanceDrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performance
 
Performance_Up.ppt
Performance_Up.pptPerformance_Up.ppt
Performance_Up.ppt
 
WE18_Performance_Up.ppt
WE18_Performance_Up.pptWE18_Performance_Up.ppt
WE18_Performance_Up.ppt
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Scalable Apache for Beginners
Scalable Apache for BeginnersScalable Apache for Beginners
Scalable Apache for Beginners
 
Scale Apache with Nginx
Scale Apache with NginxScale Apache with Nginx
Scale Apache with Nginx
 
Sun Web Server Brief
Sun Web Server BriefSun Web Server Brief
Sun Web Server Brief
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
 
Sun Web Server Brief
Sun Web Server BriefSun Web Server Brief
Sun Web Server Brief
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...
Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...
Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...
 
Zend Con 2008 Slides
Zend Con 2008 SlidesZend Con 2008 Slides
Zend Con 2008 Slides
 
21 Www Web Services
21 Www Web Services21 Www Web Services
21 Www Web Services
 
Data Grids with Oracle Coherence
Data Grids with Oracle CoherenceData Grids with Oracle Coherence
Data Grids with Oracle Coherence
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorial
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012
 
"Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets
 "Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets "Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets
"Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets
 
Building a high-performance data lake analytics engine at Alibaba Cloud with ...
Building a high-performance data lake analytics engine at Alibaba Cloud with ...Building a high-performance data lake analytics engine at Alibaba Cloud with ...
Building a high-performance data lake analytics engine at Alibaba Cloud with ...
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 

Último (20)

ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 

Clug 2011 March web server optimisation