SlideShare una empresa de Scribd logo
1 de 30
Descargar para leer sin conexión
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
  3.|­­ lns20.cbr1.internode.on.n  0.0%    10   22.6  22.7  22.3  23.2   0.2
  4.|­­ gi0­0­2.cor3.cbr1.interno  0.0%    10   22.2  22.5  22.0  23.1   0.4
  5.|­­ te6­0­0.bdr1.syd4.interno  0.0%    10  207.1 207.7 207.1 208.4   0.4
  6.|­­ te0­0­0.bdr1.syd7.interno  0.0%    10  208.4 210.1 207.1 228.2   6.4
  7.|­­ po3­0­0.bdr1.sjc2.interno  0.0%    10  207.5 207.2 206.7 207.9   0.4
  8.|­­ 10gigabitethernet2­3.core  0.0%    10  185.9 187.0 185.0 190.7   2.0
  9.|­­ 10gigabitethernet1­1.core  0.0%    10  186.3 205.2 186.0 367.5  57.1
 10.|­­ linode­llc.10gigabitether 10.0%    10  186.1 189.1 185.4 210.8   8.1
 11.|­­ bluefish.lentz.com.au     10.0%    10  186.5 186.6 186.0 187.9   0.6
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)




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
   | "no-store"                 ; Section 14.9.2
   | "max-age" "=" delta-seconds         ; Section 14.9.3, 14.9.4
   | "max-stale" [ "=" delta-seconds ] ; Section 14.9.3
   | "min-fresh" "=" delta-seconds       ; Section 14.9.3
   | "no-transform"               ; Section 14.9.5
   | "only-if-cached"             ; Section 14.9.4
   | cache-extension                 ; Section 14.9.6


cache-response-directive =
    "public"                    ; Section 14.9.1
   | "private" [ "=" <"> 1#field-name <"> ] ; Section 14.9.1
   | "no-cache" [ "=" <"> 1#field-name <"> ]; Section 14.9.1
   | "no-store"                  ; Section 14.9.2
   | "no-transform"                  ; Section 14.9.5
   | "must-revalidate"                ; Section 14.9.4
   | "proxy-revalidate"               ; Section 14.9.4
   | "max-age" "=" delta-seconds           ; Section 14.9.3
   | "s-maxage" "=" delta-seconds           ; Section 14.9.3
   | cache-extension                  ; Section 14.9.6
Gzip + Caching
                                            Savings
trunk/roundcubemail/.htaccess ¶             On initial response: 104.2K (vs 255.6K) / 44
<IfModule mod_deflate.c>                    requests)
SetOutputFilter DEFLATE                     On next page: 6.2K 2 requests (vs 204.7K / 44
</IfModule>                                 requests)

<IfModule mod_headers.c>
# replace 'append' with 'merge' for Apache version 2.2.9 and later
Header append Cache-Control public env=!NO_CACHE
</IfModule>


<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
</IfModule>
FileETag MTime
Use Yslow / Firebug
                      Structuring
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);


..bits of code


if ($sample) $t1 = microtime(TRUE) - $t0;
..


if ($sample) $t2 = microtime(TRUE) - $t1;


...


if ($sample) {
     insert into timings .....$t1*1000, $t2*1000....
}
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
          $last_update = $db->getRecord('time',             DB_CACHE, "name='$name'") ;
          ....


          if (strtotime($last_update) >= strtotime($max_age)) // value is still valid - retrieve existing
          {
                 $result = $db->getRecord('value',         DB_CACHE, "name='$name'") ;
Fetching the same database entry three times.
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

Advanced Postgres Monitoring
Advanced Postgres MonitoringAdvanced Postgres Monitoring
Advanced Postgres Monitoring
Denish Patel
 
Nginx - Tips and Tricks.
Nginx - Tips and Tricks.Nginx - Tips and Tricks.
Nginx - Tips and Tricks.
Harish S
 

La actualidad más candente (19)

Postgres connections at scale
Postgres connections at scalePostgres connections at scale
Postgres connections at scale
 
Evolution of MongoDB Replicaset and Its Best Practices
Evolution of MongoDB Replicaset and Its Best PracticesEvolution of MongoDB Replicaset and Its Best Practices
Evolution of MongoDB Replicaset and Its Best Practices
 
Advanced Postgres Monitoring
Advanced Postgres MonitoringAdvanced Postgres Monitoring
Advanced Postgres Monitoring
 
Shootout at the PAAS Corral
Shootout at the PAAS CorralShootout at the PAAS Corral
Shootout at the PAAS Corral
 
Query Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
Query Optimization with MySQL 8.0 and MariaDB 10.3: The BasicsQuery Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
Query Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
 
GUC Tutorial Package (9.0)
GUC Tutorial Package (9.0)GUC Tutorial Package (9.0)
GUC Tutorial Package (9.0)
 
Content Caching with NGINX and NGINX Plus
Content Caching with NGINX and NGINX PlusContent Caching with NGINX and NGINX Plus
Content Caching with NGINX and NGINX Plus
 
Streaming replication in practice
Streaming replication in practiceStreaming replication in practice
Streaming replication in practice
 
Containers > VMs
Containers > VMsContainers > VMs
Containers > VMs
 
Reverse proxy & web cache with NGINX, HAProxy and Varnish
Reverse proxy & web cache with NGINX, HAProxy and VarnishReverse proxy & web cache with NGINX, HAProxy and Varnish
Reverse proxy & web cache with NGINX, HAProxy and Varnish
 
Nginx - Tips and Tricks.
Nginx - Tips and Tricks.Nginx - Tips and Tricks.
Nginx - Tips and Tricks.
 
Massively Scaled High Performance Web Services with PHP
Massively Scaled High Performance Web Services with PHPMassively Scaled High Performance Web Services with PHP
Massively Scaled High Performance Web Services with PHP
 
GOTO 2013: Why Zalando trusts in PostgreSQL
GOTO 2013: Why Zalando trusts in PostgreSQLGOTO 2013: Why Zalando trusts in PostgreSQL
GOTO 2013: Why Zalando trusts in PostgreSQL
 
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
 
Streaming replication in PostgreSQL
Streaming replication in PostgreSQLStreaming replication in PostgreSQL
Streaming replication in PostgreSQL
 
Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4
 
Shootout at the AWS Corral
Shootout at the AWS CorralShootout at the AWS Corral
Shootout at the AWS Corral
 
High Availability Content Caching with NGINX
High Availability Content Caching with NGINXHigh Availability Content Caching with NGINX
High Availability Content Caching with NGINX
 
7 Ways To Crash Postgres
7 Ways To Crash Postgres7 Ways To Crash Postgres
7 Ways To Crash Postgres
 

Similar a Clug 2012 March web server optimisation

Performance Optimization using Caching | Swatantra Kumar
Performance Optimization using Caching | Swatantra KumarPerformance Optimization using Caching | Swatantra Kumar
Performance Optimization using Caching | Swatantra Kumar
Swatantra Kumar
 
Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014
bryan_call
 

Similar a Clug 2012 March web server optimisation (20)

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
 
High Availability Content Caching with NGINX
High Availability Content Caching with NGINXHigh Availability Content Caching with NGINX
High Availability Content Caching with NGINX
 
Less and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersLess and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developers
 
ITB2017 - Nginx Effective High Availability Content Caching
ITB2017 - Nginx Effective High Availability Content CachingITB2017 - Nginx Effective High Availability Content Caching
ITB2017 - Nginx Effective High Availability Content Caching
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magento
 
Mobile App Performance: Getting the Most from APIs (MBL203) | AWS re:Invent ...
Mobile App Performance:  Getting the Most from APIs (MBL203) | AWS re:Invent ...Mobile App Performance:  Getting the Most from APIs (MBL203) | AWS re:Invent ...
Mobile App Performance: Getting the Most from APIs (MBL203) | AWS re:Invent ...
 
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
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
 
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
 
Nginx Scalable Stack
Nginx Scalable StackNginx Scalable Stack
Nginx Scalable Stack
 
Performance Optimization using Caching | Swatantra Kumar
Performance Optimization using Caching | Swatantra KumarPerformance Optimization using Caching | Swatantra Kumar
Performance Optimization using Caching | Swatantra Kumar
 
Build an High-Performance and High-Durable Block Storage Service Based on Ceph
Build an High-Performance and High-Durable Block Storage Service Based on CephBuild an High-Performance and High-Durable Block Storage Service Based on Ceph
Build an High-Performance and High-Durable Block Storage Service Based on Ceph
 
Configuring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceConfiguring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web Perormance
 
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, Александр Крижа...
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
Using NGINX as an Effective and Highly Available Content Cache
Using NGINX as an Effective and Highly Available Content CacheUsing NGINX as an Effective and Highly Available Content Cache
Using NGINX as an Effective and Highly Available Content Cache
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorial
 
DevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on Kubernetes
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
 
Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

Clug 2012 March web server optimisation