SlideShare a Scribd company logo
1 of 38
Download to read offline
SPDY

http reloaded
GOOGLE PROPRIETARY PROTOCOL
(WILL BE) PART OF HTTP/2.0
HTTP Problems
•   Single request per connection. Because HTTP can only fetch one resource at a time
    (HTTP pipelining helps, but still enforces only a FIFO queue), a server delay of 500 ms
    prevents reuse of the TCP channel for additional requests. Browsers work around this
    problem by using multiple connections. Since 2008, most browsers have finally moved
    from 2 connections per domain to 6.
•   Exclusively client-initiated requests. In HTTP, only the client can initiate a request. Even
    if the server knows the client needs a resource, it has no mechanism to inform the
    client and must instead wait to receive a request for the resource from the client.
•   Uncompressed request and response headers. Request headers today vary in size from
    ~200 bytes to over 2KB. As applications use more cookies and user agents expand
    features, typical header sizes of 700-800 bytes is common. For modems or ADSL
    connections, in which the uplink bandwidth is fairly low, this latency can be
    significant. Reducing the data in headers could directly improve the serialization latency
    to send requests.
•   Redundant headers. In addition, several headers are repeatedly sent across requests on
    the same channel. However, headers such as the User-Agent, Host, and Accept* are
    generally static and do not need to be resent.
•   Optional data compression. HTTP uses optional compression encodings for data.
    Content should always be sent in a compressed format.


                                              Source: http://dev.chromium.org/spdy/spdy-whitepaper
Web Requests Are Simple
•   Open a connection
•   Send a request
•   Receive a response
•   Done
Transfer per Page
Many Requests are a Pain
• Caching
• Domain Sharding
  – Browser Limits
• Keep Alive
  – Dedicated Connections
  – Waste Ressources
• Pipelining
TCP Handshake
0ms 1) Host A sends a TCP SYNchronize packet to Host B
50ms 2) Host B receives A's SYN
50ms 3) Host B sends a SYNchronize-ACKnowledgement
100ms 4) Host A receives B's SYN-ACK
100ms 5) Host A sends ACKnowledge
150ms 6) Host B receives ACK.


• With a Ping of just 50ms, this takes us 150ms
Initial window
• Congestion Control Mechanism
• Avoid overloading clients
• Each ACK of the client increases window

• RFC 3390
  – Increasing icwnd
  – Small Resonses are complete without ACK
  – Avoid the ACK RTT
Pushing over http
• Push === Long Polling
• Consumes one connection on clients
• On server
  – Used to be expensive to hold
  – Modern servers have evented I/O


• WebSockets
Headers
         http://blog.codecentric.de/
                                text/html,application/xhtml+xml,application/xm
Accept
                                l;q=0.9,*/*;q=0.8
Accept-Encoding                 gzip, deflate
Accept-Language                 de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Connection                      keep-alive


                                __utma=40497137.1800912468.1315901303.13
                                28525769.1328537171.234;
                                __utmz=40497137.1326462670.198.110.utmcsr
                                =twitterfeed|utmccn=blogfeed_de|utmcmd=twi
                                tter; wp-settings-
                                3=editor%3Dhtml%26m0%3Do%26m1%3Do%26
                                m2%3Do%26m3%3Dc%26m4%3Do%26m5%3Do
                                %26m6%3Do%26m7%3Do%26m8%3Do%26m9
                                %3Do%26m10%3Do%26m11%3Do%26align%3D
Cookie
                                center%26imgsize%3Dfull%26urlbutton%3Dnon
                                e%26hidetb%3D0; wp-settings-time-
                                3=1328519940;
                                __utma=162617902.1417890302.1315914276.1
                                328537194.1328541774.63;
                                __utmz=162617902.1328537194.62.41.utmcsr=
                                blog.codecentric.de|utmccn=(referral)|utmcmd
                                =referral|utmcct=/; wp-settings-time-
                                81=1321966374


Host                            blog.codecentric.de
                                Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0)
User-Agent
                                Gecko/20100101 Firefox/10.0
Headers
             http://www.codecentric.de/files/2012/02/adlite.png
Accept                              image/png,image/*;q=0.8,*/*;q=0.5
Accept-Encoding                     gzip, deflate
Accept-Language                     de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Connection                          keep-alive
                                    __utma=162617902.1417890302.13159
                                    14276.1328537194.1328541774.63;
                                    __utmz=162617902.1328537194.62.41.u
                                    tmcsr=blog.codecentric.de|utmccn=(refe
                                    rral)|utmcmd=referral|utmcct=/; wp-
Cookie                              settings-
                                    3=m0%3Do%26m1%3Do%26m5%3Do%2
                                    6m4%3Do%26editor%3Dhtml%26wplink
                                    %3D1%26align%3Dcenter%26imgsize%3
                                    Dfull%26hidetb%3D1%26m7%3Do%26m
                                    9%3Do; wp-settings-time-3=1326290899
Host                                www.codecentric.de
Referer                             http://blog.codecentric.de/
                                    Mozilla/5.0 (Windows NT 6.1; WOW64;
User-Agent
                                    rv:10.0) Gecko/20100101 Firefox/10.0
Content Compression
• Gzip is optional
• But generally best practice

LoadModule deflate_module /usr/lib/httpd/modules/mod_deflate.so
SPDY TO THE RESCUE
SPDY Solutions
• Allow many concurrent HTTP requests to run across a single
  TCP session.
• Reduce the bandwidth currently used by HTTP by
  compressing headers and eliminating unnecessary headers.
• Make SSL the underlying transport protocol, for better
  security and compatibility with existing network
  infrastructure. Although SSL does introduce a latency
  penalty, we believe that the long-term future of the web
  depends on a secure network connection. In addition, the
  use of SSL is necessary to ensure that communication
  across existing proxies is not broken.
• Enable the server to initiate communications with the client
  and push data to the client whenever possible.

                             Source: http://dev.chromium.org/spdy/spdy-whitepaper
Connection Multiplexing
• Single TCP Connection transports all requests
• TCP Handshake still exists
• Inital cwnd should be 16
Compression
• All data is compressed
• Includes headers
• Redundand data is removed
  – User Agent of second request is known to be same
    as on first
SSL
• Not said to be a problem with HTTP
• SSL should be default
  – But actually expensive
• SSL hides SPDY traffic, so that proxies don't
  break it 
Pushing
• Long Lasting Connection By Design
• Send does not close the "request"
• Two flavors
  – Server push
  – Server hint
Compatibility
• SPDY is backwards compatible
• Uses Next Protocol Negotiation
  – tools.ietf.org/html/draft-agl-tls-nextprotoneg-02
SPDY Support
Clients                    Server
• Chrome                   • Apache mod_spdy
   – On since 11           • erlang-spdy
   – Ice Cream Sandwich
                           • node-spdy
• Amazon Silk              • Netty 3.3.1
   – Kindle Fire
                              – Means JBoss
• Firefox                  • Jetty 7.6.2
   – experimental in 11
   – On in 12/13
                           • Tomcat SPDY Connector
DEMO: MIGRATING PHP ON
APACHE TO SUPPORT SPDY
PHP is not Threadsafe
• The way SPDY works is incompatible with non
  threadsafe implementations
  – one connection one httpd worker
  – But multiple requests
• Zend Threadsafe does not support some
  features (mysql!)
• Need to externalize it with cgi
mod_php to mod_fcgid + php
• yum install mod_fcgid
• vi /etc/httpd/conf/httpd.conf
 <Directory "/var/www/html">
     Options Indexes FollowSymLinks ExecCGI
 </Directory>


• mv /etc/httpd/conf.d/php.conf
  /etc/httpd/conf.d/php.conf.bak
• vi /etc/httpd/conf.d/fcgid.conf
DirectoryIndex index.php
AddHandler fcgid-script .fcgi .php

DefaultInitEnv PHPRC      "/etc/"
MaxRequestsPerProcess     1000
MaxProcessCount           10
MaxRequestLen             209715200
IPCCommTimeout            240
IdleTimeout               240
FCGIWrapper /usr/bin/php-cgi .php
mod_prefork to mod_worker
• Needs recompilation
• Luckily we have both already 
  – httpd -V | grep MPM
  – httpd.worker -V | grep MPM


• sudo vi /etc/init.d/httpd
httpd=${HTTPD-/usr/sbin/httpd.worker}
prog=httpd.worker
mod_ssl
• We need mod_ssl patched with NPN
• yum install subversion curl gcc-c++
  patch binutils make
• mkdir modssl; cd modssl
• svn export http://mod-
  spdy.googlecode.com/svn/trunk/src/bu
  ild_modssl_with_npn.sh
• ./build_modssl_with_npn.sh
• cp /root/modssl/mod_ssl.so
  /etc/httpd/modules/mod_ssl.so
[root@centos57 modssl]# ./build_modssl_with_npn.sh
Using buildroot: /tmp/tmp.CooHIy8770
Downloading http://www.openssl.org/source/openssl-1.0.1-beta2.tar.gz
######################################################################## 100.0%
Downloading http://www.apache.org/dist/httpd/httpd-2.2.21.tar.gz
######################################################################## 100.0%
Downloading https://issues.apache.org/bugzilla/attachment.cgi?id=27969context=patch
######################################################################## 100.0%
Uncompressing openssl-1.0.1-beta2.tar.gz ... done
Uncompressing httpd-2.2.21.tar.gz ... done
Applying Apache mod_ssl NPN patch ...
patching file modules/ssl/ssl_private.h
patching file modules/ssl/ssl_engine_init.c
patching file modules/ssl/ssl_engine_io.c
patching file modules/ssl/ssl_engine_kernel.c
patching file modules/ssl/mod_ssl.c
patching file modules/ssl/mod_ssl.h
done
Configuring OpenSSL ... done
Building OpenSSL (this may take a while) ... done

Configuring Apache mod_ssl ... done
Building Apache mod_ssl (this may take a while) ... done

Generated mod_ssl.so at /root/modssl/mod_ssl.so.
mod_spdy
• Built from source
•   mkdir mod_spdy; cd mod_spdy
•   svn co
    http://src.chromium.org/svn/trunk/tools/depot_tools
•   export PATH="$PATH":`pwd`/depot_tools
•   gclient config http://mod-
    spdy.googlecode.com/svn/trunk/src
•   gclient sync --force
•   cd src; make BUILDTYPE=Release

•   sudo cp out/Release/libmod_spdy.so
    /etc/httpd/modules/mod_spdy.so
•   vi /etc/httpd/conf.d/spdy.conf

LoadModule spdy_module /etc/httpd/modules/mod_spdy.so
SpdyEnabled on
chrome://net-internals/#spdy
Is it spdy?
• www.devthought.com/2012/03/10/chrome-
  spdy-indicator/
• ckon.wordpress.com/2012/03/11/spdy-
  indicator-for-firefox/
HTTP




  2.07
seconds
HTTPS




  4.94
seconds
SPDY




  2.65
seconds
real HTTP




 17.83
seconds
real SPDY




 11.70
seconds
LET'S MAKE THE WEB FASTER

More Related Content

What's hot

Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsMarcus Frödin
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & ExpressChristian Joudrey
 
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming  Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming Tom Croucher
 
Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST APIFabien Vauchelles
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDDSudar Muthu
 
Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2동수 장
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialTom Croucher
 
All aboard the NodeJS Express
All aboard the NodeJS ExpressAll aboard the NodeJS Express
All aboard the NodeJS ExpressDavid Boyer
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JSCakra Danu Sedayu
 
Nodejs getting started
Nodejs getting startedNodejs getting started
Nodejs getting startedTriet Ho
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs Irfan Maulana
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)Chris Cowan
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBHengki Sihombing
 
vert.x 소개 및 개발 실습
vert.x 소개 및 개발 실습vert.x 소개 및 개발 실습
vert.x 소개 및 개발 실습John Kim
 
Node.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseNode.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseAaron Silverman
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS Ganesh Kondal
 
Server Side Apocalypse, JS
Server Side Apocalypse, JSServer Side Apocalypse, JS
Server Side Apocalypse, JSMd. Sohel Rana
 

What's hot (20)

Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & Express
 
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming  Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
 
Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST API
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 
Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
Node js
Node jsNode js
Node js
 
All aboard the NodeJS Express
All aboard the NodeJS ExpressAll aboard the NodeJS Express
All aboard the NodeJS Express
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JS
 
Nodejs getting started
Nodejs getting startedNodejs getting started
Nodejs getting started
 
Node ppt
Node pptNode ppt
Node ppt
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
 
vert.x 소개 및 개발 실습
vert.x 소개 및 개발 실습vert.x 소개 및 개발 실습
vert.x 소개 및 개발 실습
 
Node.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseNode.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash Course
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS
 
Server Side Apocalypse, JS
Server Side Apocalypse, JSServer Side Apocalypse, JS
Server Side Apocalypse, JS
 
Node.js debugging
Node.js debuggingNode.js debugging
Node.js debugging
 

Similar to The SPDY Protocol

SPDY - http reloaded - WebTechConference 2012
SPDY - http reloaded - WebTechConference 2012SPDY - http reloaded - WebTechConference 2012
SPDY - http reloaded - WebTechConference 2012Fabian Lange
 
Lonestar php scalingmagento
Lonestar php scalingmagentoLonestar php scalingmagento
Lonestar php scalingmagentoMathew Beane
 
Introduction to HTTP protocol
Introduction to HTTP protocolIntroduction to HTTP protocol
Introduction to HTTP protocolAviran Mordo
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magentoMathew Beane
 
Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014bryan_call
 
SPDY, TCP, and the Single Connection Throttle
SPDY, TCP, and the Single Connection ThrottleSPDY, TCP, and the Single Connection Throttle
SPDY, TCP, and the Single Connection ThrottleMike Belshe
 
Primer to Browser Netwroking
Primer to Browser NetwrokingPrimer to Browser Netwroking
Primer to Browser NetwrokingShuya Osaki
 
Clug 2012 March web server optimisation
Clug 2012 March   web server optimisationClug 2012 March   web server optimisation
Clug 2012 March web server optimisationgrooverdan
 
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)Ericom Software
 
17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]Krisman Tarigan
 
The Real World - Plugging the Enterprise Into It (nodejs)
The Real World - Plugging  the Enterprise Into It (nodejs)The Real World - Plugging  the Enterprise Into It (nodejs)
The Real World - Plugging the Enterprise Into It (nodejs)Aman Kohli
 
HTTP/2 What's inside and Why
HTTP/2 What's inside and WhyHTTP/2 What's inside and Why
HTTP/2 What's inside and WhyAdrian Cole
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on SteroidsSiteGround.com
 
Reducing latency on the web with the Azure CDN- TechDays NL 2014
Reducing latency on the web with the Azure CDN- TechDays NL 2014Reducing latency on the web with the Azure CDN- TechDays NL 2014
Reducing latency on the web with the Azure CDN- TechDays NL 2014Maarten Balliauw
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindSam Keen
 
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014Amazon Web Services
 
WordPress performance tuning
WordPress performance tuningWordPress performance tuning
WordPress performance tuningVladimír Smitka
 

Similar to The SPDY Protocol (20)

SPDY - http reloaded - WebTechConference 2012
SPDY - http reloaded - WebTechConference 2012SPDY - http reloaded - WebTechConference 2012
SPDY - http reloaded - WebTechConference 2012
 
Lonestar php scalingmagento
Lonestar php scalingmagentoLonestar php scalingmagento
Lonestar php scalingmagento
 
Http2 in practice
Http2 in practiceHttp2 in practice
Http2 in practice
 
Introduction to HTTP protocol
Introduction to HTTP protocolIntroduction to HTTP protocol
Introduction to HTTP protocol
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magento
 
Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014Choosing A Proxy Server - Apachecon 2014
Choosing A Proxy Server - Apachecon 2014
 
SPDY, TCP, and the Single Connection Throttle
SPDY, TCP, and the Single Connection ThrottleSPDY, TCP, and the Single Connection Throttle
SPDY, TCP, and the Single Connection Throttle
 
Primer to Browser Netwroking
Primer to Browser NetwrokingPrimer to Browser Netwroking
Primer to Browser Netwroking
 
Clug 2012 March web server optimisation
Clug 2012 March   web server optimisationClug 2012 March   web server optimisation
Clug 2012 March web server optimisation
 
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
 
17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]
 
SPDY - or maybe HTTP2.0
SPDY - or maybe HTTP2.0SPDY - or maybe HTTP2.0
SPDY - or maybe HTTP2.0
 
The Real World - Plugging the Enterprise Into It (nodejs)
The Real World - Plugging  the Enterprise Into It (nodejs)The Real World - Plugging  the Enterprise Into It (nodejs)
The Real World - Plugging the Enterprise Into It (nodejs)
 
6 app-tcp
6 app-tcp6 app-tcp
6 app-tcp
 
HTTP/2 What's inside and Why
HTTP/2 What's inside and WhyHTTP/2 What's inside and Why
HTTP/2 What's inside and Why
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on Steroids
 
Reducing latency on the web with the Azure CDN- TechDays NL 2014
Reducing latency on the web with the Azure CDN- TechDays NL 2014Reducing latency on the web with the Azure CDN- TechDays NL 2014
Reducing latency on the web with the Azure CDN- TechDays NL 2014
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
 
WordPress performance tuning
WordPress performance tuningWordPress performance tuning
WordPress performance tuning
 

More from Fabian Lange

Aspects of modern APM solutions
Aspects of modern APM solutionsAspects of modern APM solutions
Aspects of modern APM solutionsFabian Lange
 
Web Performance Optimization - Web Tech Conference 2011 Talk
Web Performance Optimization - Web Tech Conference 2011 TalkWeb Performance Optimization - Web Tech Conference 2011 Talk
Web Performance Optimization - Web Tech Conference 2011 TalkFabian Lange
 
Performance - a challenging craft
Performance  - a challenging craftPerformance  - a challenging craft
Performance - a challenging craftFabian Lange
 
Web Performance Optimization - JAX 2011 Talk
Web Performance Optimization - JAX 2011 TalkWeb Performance Optimization - JAX 2011 Talk
Web Performance Optimization - JAX 2011 TalkFabian Lange
 
Agile Development of High Performance Applications
Agile Development of High Performance ApplicationsAgile Development of High Performance Applications
Agile Development of High Performance ApplicationsFabian Lange
 
Rich Ajax Platform - Programming for Web and Rich Client
Rich Ajax Platform - Programming for Web and Rich ClientRich Ajax Platform - Programming for Web and Rich Client
Rich Ajax Platform - Programming for Web and Rich ClientFabian Lange
 
Eclipse Rich Ajax Platform
Eclipse Rich Ajax PlatformEclipse Rich Ajax Platform
Eclipse Rich Ajax PlatformFabian Lange
 
Codecentric At Ajax World Conference San Jose
Codecentric At Ajax World Conference San JoseCodecentric At Ajax World Conference San Jose
Codecentric At Ajax World Conference San JoseFabian Lange
 
Full Stack Web Application Performance Tuning
Full Stack Web Application Performance TuningFull Stack Web Application Performance Tuning
Full Stack Web Application Performance TuningFabian Lange
 

More from Fabian Lange (10)

Aspects of modern APM solutions
Aspects of modern APM solutionsAspects of modern APM solutions
Aspects of modern APM solutions
 
Web Performance Optimization - Web Tech Conference 2011 Talk
Web Performance Optimization - Web Tech Conference 2011 TalkWeb Performance Optimization - Web Tech Conference 2011 Talk
Web Performance Optimization - Web Tech Conference 2011 Talk
 
Performance - a challenging craft
Performance  - a challenging craftPerformance  - a challenging craft
Performance - a challenging craft
 
Web Performance Optimization - JAX 2011 Talk
Web Performance Optimization - JAX 2011 TalkWeb Performance Optimization - JAX 2011 Talk
Web Performance Optimization - JAX 2011 Talk
 
Agile Development of High Performance Applications
Agile Development of High Performance ApplicationsAgile Development of High Performance Applications
Agile Development of High Performance Applications
 
Rich Ajax Platform - Programming for Web and Rich Client
Rich Ajax Platform - Programming for Web and Rich ClientRich Ajax Platform - Programming for Web and Rich Client
Rich Ajax Platform - Programming for Web and Rich Client
 
Eclipse Rich Ajax Platform
Eclipse Rich Ajax PlatformEclipse Rich Ajax Platform
Eclipse Rich Ajax Platform
 
Ant Maven
Ant MavenAnt Maven
Ant Maven
 
Codecentric At Ajax World Conference San Jose
Codecentric At Ajax World Conference San JoseCodecentric At Ajax World Conference San Jose
Codecentric At Ajax World Conference San Jose
 
Full Stack Web Application Performance Tuning
Full Stack Web Application Performance TuningFull Stack Web Application Performance Tuning
Full Stack Web Application Performance Tuning
 

Recently uploaded

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 

Recently uploaded (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 

The SPDY Protocol

  • 2. GOOGLE PROPRIETARY PROTOCOL (WILL BE) PART OF HTTP/2.0
  • 3. HTTP Problems • Single request per connection. Because HTTP can only fetch one resource at a time (HTTP pipelining helps, but still enforces only a FIFO queue), a server delay of 500 ms prevents reuse of the TCP channel for additional requests. Browsers work around this problem by using multiple connections. Since 2008, most browsers have finally moved from 2 connections per domain to 6. • Exclusively client-initiated requests. In HTTP, only the client can initiate a request. Even if the server knows the client needs a resource, it has no mechanism to inform the client and must instead wait to receive a request for the resource from the client. • Uncompressed request and response headers. Request headers today vary in size from ~200 bytes to over 2KB. As applications use more cookies and user agents expand features, typical header sizes of 700-800 bytes is common. For modems or ADSL connections, in which the uplink bandwidth is fairly low, this latency can be significant. Reducing the data in headers could directly improve the serialization latency to send requests. • Redundant headers. In addition, several headers are repeatedly sent across requests on the same channel. However, headers such as the User-Agent, Host, and Accept* are generally static and do not need to be resent. • Optional data compression. HTTP uses optional compression encodings for data. Content should always be sent in a compressed format. Source: http://dev.chromium.org/spdy/spdy-whitepaper
  • 4. Web Requests Are Simple • Open a connection • Send a request • Receive a response • Done
  • 5.
  • 7. Many Requests are a Pain • Caching • Domain Sharding – Browser Limits • Keep Alive – Dedicated Connections – Waste Ressources • Pipelining
  • 8. TCP Handshake 0ms 1) Host A sends a TCP SYNchronize packet to Host B 50ms 2) Host B receives A's SYN 50ms 3) Host B sends a SYNchronize-ACKnowledgement 100ms 4) Host A receives B's SYN-ACK 100ms 5) Host A sends ACKnowledge 150ms 6) Host B receives ACK. • With a Ping of just 50ms, this takes us 150ms
  • 9. Initial window • Congestion Control Mechanism • Avoid overloading clients • Each ACK of the client increases window • RFC 3390 – Increasing icwnd – Small Resonses are complete without ACK – Avoid the ACK RTT
  • 10. Pushing over http • Push === Long Polling • Consumes one connection on clients • On server – Used to be expensive to hold – Modern servers have evented I/O • WebSockets
  • 11. Headers http://blog.codecentric.de/ text/html,application/xhtml+xml,application/xm Accept l;q=0.9,*/*;q=0.8 Accept-Encoding gzip, deflate Accept-Language de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 Connection keep-alive __utma=40497137.1800912468.1315901303.13 28525769.1328537171.234; __utmz=40497137.1326462670.198.110.utmcsr =twitterfeed|utmccn=blogfeed_de|utmcmd=twi tter; wp-settings- 3=editor%3Dhtml%26m0%3Do%26m1%3Do%26 m2%3Do%26m3%3Dc%26m4%3Do%26m5%3Do %26m6%3Do%26m7%3Do%26m8%3Do%26m9 %3Do%26m10%3Do%26m11%3Do%26align%3D Cookie center%26imgsize%3Dfull%26urlbutton%3Dnon e%26hidetb%3D0; wp-settings-time- 3=1328519940; __utma=162617902.1417890302.1315914276.1 328537194.1328541774.63; __utmz=162617902.1328537194.62.41.utmcsr= blog.codecentric.de|utmccn=(referral)|utmcmd =referral|utmcct=/; wp-settings-time- 81=1321966374 Host blog.codecentric.de Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) User-Agent Gecko/20100101 Firefox/10.0
  • 12. Headers http://www.codecentric.de/files/2012/02/adlite.png Accept image/png,image/*;q=0.8,*/*;q=0.5 Accept-Encoding gzip, deflate Accept-Language de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 Connection keep-alive __utma=162617902.1417890302.13159 14276.1328537194.1328541774.63; __utmz=162617902.1328537194.62.41.u tmcsr=blog.codecentric.de|utmccn=(refe rral)|utmcmd=referral|utmcct=/; wp- Cookie settings- 3=m0%3Do%26m1%3Do%26m5%3Do%2 6m4%3Do%26editor%3Dhtml%26wplink %3D1%26align%3Dcenter%26imgsize%3 Dfull%26hidetb%3D1%26m7%3Do%26m 9%3Do; wp-settings-time-3=1326290899 Host www.codecentric.de Referer http://blog.codecentric.de/ Mozilla/5.0 (Windows NT 6.1; WOW64; User-Agent rv:10.0) Gecko/20100101 Firefox/10.0
  • 13. Content Compression • Gzip is optional • But generally best practice LoadModule deflate_module /usr/lib/httpd/modules/mod_deflate.so
  • 14. SPDY TO THE RESCUE
  • 15. SPDY Solutions • Allow many concurrent HTTP requests to run across a single TCP session. • Reduce the bandwidth currently used by HTTP by compressing headers and eliminating unnecessary headers. • Make SSL the underlying transport protocol, for better security and compatibility with existing network infrastructure. Although SSL does introduce a latency penalty, we believe that the long-term future of the web depends on a secure network connection. In addition, the use of SSL is necessary to ensure that communication across existing proxies is not broken. • Enable the server to initiate communications with the client and push data to the client whenever possible. Source: http://dev.chromium.org/spdy/spdy-whitepaper
  • 16. Connection Multiplexing • Single TCP Connection transports all requests • TCP Handshake still exists • Inital cwnd should be 16
  • 17. Compression • All data is compressed • Includes headers • Redundand data is removed – User Agent of second request is known to be same as on first
  • 18. SSL • Not said to be a problem with HTTP • SSL should be default – But actually expensive • SSL hides SPDY traffic, so that proxies don't break it 
  • 19. Pushing • Long Lasting Connection By Design • Send does not close the "request" • Two flavors – Server push – Server hint
  • 20. Compatibility • SPDY is backwards compatible • Uses Next Protocol Negotiation – tools.ietf.org/html/draft-agl-tls-nextprotoneg-02
  • 21. SPDY Support Clients Server • Chrome • Apache mod_spdy – On since 11 • erlang-spdy – Ice Cream Sandwich • node-spdy • Amazon Silk • Netty 3.3.1 – Kindle Fire – Means JBoss • Firefox • Jetty 7.6.2 – experimental in 11 – On in 12/13 • Tomcat SPDY Connector
  • 22. DEMO: MIGRATING PHP ON APACHE TO SUPPORT SPDY
  • 23. PHP is not Threadsafe • The way SPDY works is incompatible with non threadsafe implementations – one connection one httpd worker – But multiple requests • Zend Threadsafe does not support some features (mysql!) • Need to externalize it with cgi
  • 24. mod_php to mod_fcgid + php • yum install mod_fcgid • vi /etc/httpd/conf/httpd.conf <Directory "/var/www/html"> Options Indexes FollowSymLinks ExecCGI </Directory> • mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.bak • vi /etc/httpd/conf.d/fcgid.conf
  • 25. DirectoryIndex index.php AddHandler fcgid-script .fcgi .php DefaultInitEnv PHPRC "/etc/" MaxRequestsPerProcess 1000 MaxProcessCount 10 MaxRequestLen 209715200 IPCCommTimeout 240 IdleTimeout 240 FCGIWrapper /usr/bin/php-cgi .php
  • 26. mod_prefork to mod_worker • Needs recompilation • Luckily we have both already  – httpd -V | grep MPM – httpd.worker -V | grep MPM • sudo vi /etc/init.d/httpd httpd=${HTTPD-/usr/sbin/httpd.worker} prog=httpd.worker
  • 27. mod_ssl • We need mod_ssl patched with NPN • yum install subversion curl gcc-c++ patch binutils make • mkdir modssl; cd modssl • svn export http://mod- spdy.googlecode.com/svn/trunk/src/bu ild_modssl_with_npn.sh • ./build_modssl_with_npn.sh • cp /root/modssl/mod_ssl.so /etc/httpd/modules/mod_ssl.so
  • 28. [root@centos57 modssl]# ./build_modssl_with_npn.sh Using buildroot: /tmp/tmp.CooHIy8770 Downloading http://www.openssl.org/source/openssl-1.0.1-beta2.tar.gz ######################################################################## 100.0% Downloading http://www.apache.org/dist/httpd/httpd-2.2.21.tar.gz ######################################################################## 100.0% Downloading https://issues.apache.org/bugzilla/attachment.cgi?id=27969context=patch ######################################################################## 100.0% Uncompressing openssl-1.0.1-beta2.tar.gz ... done Uncompressing httpd-2.2.21.tar.gz ... done Applying Apache mod_ssl NPN patch ... patching file modules/ssl/ssl_private.h patching file modules/ssl/ssl_engine_init.c patching file modules/ssl/ssl_engine_io.c patching file modules/ssl/ssl_engine_kernel.c patching file modules/ssl/mod_ssl.c patching file modules/ssl/mod_ssl.h done Configuring OpenSSL ... done Building OpenSSL (this may take a while) ... done Configuring Apache mod_ssl ... done Building Apache mod_ssl (this may take a while) ... done Generated mod_ssl.so at /root/modssl/mod_ssl.so.
  • 29. mod_spdy • Built from source • mkdir mod_spdy; cd mod_spdy • svn co http://src.chromium.org/svn/trunk/tools/depot_tools • export PATH="$PATH":`pwd`/depot_tools • gclient config http://mod- spdy.googlecode.com/svn/trunk/src • gclient sync --force • cd src; make BUILDTYPE=Release • sudo cp out/Release/libmod_spdy.so /etc/httpd/modules/mod_spdy.so • vi /etc/httpd/conf.d/spdy.conf LoadModule spdy_module /etc/httpd/modules/mod_spdy.so SpdyEnabled on
  • 31.
  • 32. Is it spdy? • www.devthought.com/2012/03/10/chrome- spdy-indicator/ • ckon.wordpress.com/2012/03/11/spdy- indicator-for-firefox/
  • 38. LET'S MAKE THE WEB FASTER