Date post: | 15-Oct-2015 |
Category: |
Documents |
Upload: | yeferson-torres-berru |
View: | 18 times |
Download: | 0 times |
of 61
5/25/2018 Mod_spdy Architectural Overview
1/61
mod_spdy:
SPDY in ApacheMatthew Steele
April 2012
5/25/2018 Mod_spdy Architectural Overview
2/61
Why make mod_spdy?
SPDY makes the web faster
Apache is the most popular webserver bymarket share.
To help increase SPDY adoption, we want a
dead-easy-to-use, drop-in SPDY module for
Apache.
5/25/2018 Mod_spdy Architectural Overview
3/61
History of mod_spdy
Work began January 2010. We
implemented framing, and serial
multiplexing.
The project was placed on indefinite hold a
few months later, pending better SPDY
experimental results.
Resumed the project November 2011. We
now have a complete SPDY implementation.
5/25/2018 Mod_spdy Architectural Overview
4/61
Critical SPDY features
Next Protocol Negotiation (NPN)
Framing and header compression
Stream multiplexing
Server push
5/25/2018 Mod_spdy Architectural Overview
5/61
How Apache works
The MPMaccepts connections and assigns
each one to a child process/thread.
For each connection, most of the work is
done by handlersand filters.
A handlertakes control of completely processing a
connection or an HTTP request.
A filtertransforms the input or output data passingbetween the handler and the socket.
5/25/2018 Mod_spdy Architectural Overview
6/61
How Apache works
Apache's behavior can be extended by
modules, which register hooks.
Hook functions are called at various
interesting events, and give the module a
chance to do something in response.
For example, a module could register a hook
to insert a filter for each request that arrives.
5/25/2018 Mod_spdy Architectural Overview
7/61
Critical SPDY features
Next Protocol Negotiation (NPN)
Framing and header compression
Stream multiplexing
Server push
5/25/2018 Mod_spdy Architectural Overview
8/61
Next Protocol Negotiation (NPN)
server client
5/25/2018 Mod_spdy Architectural Overview
9/61
Next Protocol Negotiation (NPN)
server client
Hello!
SSL handshake
5/25/2018 Mod_spdy Architectural Overview
10/61
Next Protocol Negotiation (NPN)
client
I support: - spdy/3 - spdy/2
- foo/1.1
SSL handshake
server
5/25/2018 Mod_spdy Architectural Overview
11/61
Next Protocol Negotiation (NPN)
server client
I support: - spdy/3 - spdy/2
- foo/1.1
I choose:
spdy/2
SSL handshake
5/25/2018 Mod_spdy Architectural Overview
12/61
Next Protocol Negotiation (NPN)
Our patched version of mod_ssl provides
two NPN-related hooks.
5/25/2018 Mod_spdy Architectural Overview
13/61
Next Protocol Negotiation (NPN)
Our patched version of mod_ssl provides
two NPN-related hooks.
The first hook lets us add protocols to be
advertised.
The second hook informs us which protocol
was chosen by the client.
5/25/2018 Mod_spdy Architectural Overview
14/61
Next Protocol Negotiation (NPN)
Our patched version of mod_ssl provides
two NPN-related hooks.
The first hook lets us add protocols to be
advertised.
The second hook informs us which protocol
was chosen by the client.
Other modules could use these hooks too.
5/25/2018 Mod_spdy Architectural Overview
15/61
Apache server
Next Protocol Negotiation (NPN)
clientmod_ssl
mod_spdy
mod_foo
5/25/2018 Mod_spdy Architectural Overview
16/61
Apache server
Next Protocol Negotiation (NPN)
clientmod_ssl
mod_spdy
mod_foo
Hello!
SSL handshake
5/25/2018 Mod_spdy Architectural Overview
17/61
Apache server
Next Protocol Negotiation (NPN)
clientmod_ssl
mod_spdy
mod_foo
What do we
support?
NPN advertise hook
Hello!
SSL handshake
5/25/2018 Mod_spdy Architectural Overview
18/61
Apache server
Next Protocol Negotiation (NPN)
clientmod_ssl
mod_spdy
mod_foo
spdy/3
spdy/2
NPN advertise hook
foo/1.1
Hello!
SSL handshake
5/25/2018 Mod_spdy Architectural Overview
19/61
Apache server
Next Protocol Negotiation (NPN)
clientSSL handshakemod_ssl
mod_spdy
mod_foo
I support: - spdy/3 - spdy/2
- foo/1.1
5/25/2018 Mod_spdy Architectural Overview
20/61
Apache server
Next Protocol Negotiation (NPN)
client
I support: - spdy/3 - spdy/2
- foo/1.1
I choose:
spdy/2
SSL handshakemod_ssl
mod_spdy
mod_foo
5/25/2018 Mod_spdy Architectural Overview
21/61
Apache server
Next Protocol Negotiation (NPN)
clientmod_ssl
mod_spdy
mod_foo
The client
chose spdy/2
NPN done hook
5/25/2018 Mod_spdy Architectural Overview
22/61
Apache server
Next Protocol Negotiation (NPN)
clientmod_ssl
mod_spdy
mod_foo
The client
chose spdy/2
Hooray!
Aww...
5/25/2018 Mod_spdy Architectural Overview
23/61
Critical SPDY features
Next Protocol Negotiation (NPN)
Framing and header compression
Stream multiplexing
Server push
5/25/2018 Mod_spdy Architectural Overview
24/61
Framing and header compression
We insert filters to translate from SPDY
frames to equivalent HTTP data, and back.
Do this at the connection (not request) level,
to maintain header compression state.
This approach lets the site owner use the
same, HTTP-specific Apache modules to
process requests as without mod_spdy.
5/25/2018 Mod_spdy Architectural Overview
25/61
Critical SPDY features
Next Protocol Negotiation (NPN)
Framing and header compression
Stream multiplexing
Server push
5/25/2018 Mod_spdy Architectural Overview
26/61
How Apache works
5/25/2018 Mod_spdy Architectural Overview
27/61
How Apache works
MPM
server
socket
5/25/2018 Mod_spdy Architectural Overview
28/61
How Apache works
MPM
server
socket
client
socket
client
socket
client
socket
5/25/2018 Mod_spdy Architectural Overview
29/61
How Apache works
MPM
server
socket
connectionobject client
socket
connection
object clientsocket
connectionobject client
socket
5/25/2018 Mod_spdy Architectural Overview
30/61
thread/process 1
How Apache works
MPM
server
socket
connectionobject client
socket
thread/process 2
connection
object clientsocket
thread/process 3
connectionobject client
socket
5/25/2018 Mod_spdy Architectural Overview
31/61
thread/process 1
connectionobject
How Apache works
MPM
server
socket
client
socket
5/25/2018 Mod_spdy Architectural Overview
32/61
thread/process 1
connectionobject
How Apache works
MPM
server
socket
client
socket
networkfilters
5/25/2018 Mod_spdy Architectural Overview
33/61
thread/process 1
connectionobject
How Apache works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
networkfilters
5/25/2018 Mod_spdy Architectural Overview
34/61
thread/process 1
connectionobject
How Apache works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
connectionhandler
(e.g. HTTP)
networkfilters
5/25/2018 Mod_spdy Architectural Overview
35/61
thread/process 1
connectionobject
How Apache works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
networkfilters
request
object
connectionhandler
(e.g. HTTP)
5/25/2018 Mod_spdy Architectural Overview
36/61
thread/process 1
connectionobject
How Apache works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
connectionhandler
(e.g. HTTP)
requestfilters
(e.g. gzip)
requesthandler
(e.g. CGI)
networkfilters
request
object
5/25/2018 Mod_spdy Architectural Overview
37/61
thread/process 1
connectionobject
How Apache works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
connectionhandler
(e.g. HTTP)
networkfilters
5/25/2018 Mod_spdy Architectural Overview
38/61
Stream multiplexing
Once a request handler takes over, it does
not return control until the request is
finished.
Apache (and modules) assume onethread
per connection; the core data structures are
notthread-safe.
So we can't be event-driven, and we can't be
multithreaded. What to do?
5/25/2018 Mod_spdy Architectural Overview
39/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
networkfilters
5/25/2018 Mod_spdy Architectural Overview
40/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
5/25/2018 Mod_spdy Architectural Overview
41/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY
stream
SPDYstream
SPDY
stream
5/25/2018 Mod_spdy Architectural Overview
42/61
SPDY thread 3
SPDY thread 2
SPDY thread 1
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY
stream
SPDYstream
SPDY
stream
5/25/2018 Mod_spdy Architectural Overview
43/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY thread 1SPDY
stream
5/25/2018 Mod_spdy Architectural Overview
44/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY thread 1
connection
object
SPDY
stream
5/25/2018 Mod_spdy Architectural Overview
45/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY thread 1
connection
objectfake
socket
SPDY
stream
5/25/2018 Mod_spdy Architectural Overview
46/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY thread 1
connection
objectfake
socket
SPDY
stream
SSL filters
5/25/2018 Mod_spdy Architectural Overview
47/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY thread 1
connection
objectfake
socket
SPDY
stream
5/25/2018 Mod_spdy Architectural Overview
48/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY thread 1
connection
objectfake
socket
SPDY
stream
network
filters
5/25/2018 Mod_spdy Architectural Overview
49/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY thread 1
connection
objectfake
socket
SPDY
stream
5/25/2018 Mod_spdy Architectural Overview
50/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY thread 1
connection
objectfake
socket
SPDY
stream
connectionhandler
(e.g. HTTP)
5/25/2018 Mod_spdy Architectural Overview
51/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY thread 1
connection
objectfake
socket
SPDY/HTTPconversion
filters
connectionhandler
(e.g. HTTP)
SPDY
stream
5/25/2018 Mod_spdy Architectural Overview
52/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY thread 1
connection
objectfake
socket
SPDY
stream
requestobject
SPDY/HTTPconversion
filters
connectionhandler
(e.g. HTTP)
5/25/2018 Mod_spdy Architectural Overview
53/61
thread/process 1
connectionobject
How mod_spdy works
MPM
server
socket
client
socket
connectionfilters
(e.g. SSL)
SPDYconnection
handler
networkfilters
SPDY thread 1
connection
objectfake
socket
request
filters(e.g. gzip)
request
handler(e.g. CGI)
requestobject
SPDY
stream
SPDY/HTTPconversion
filters
connectionhandler
(e.g. HTTP)
5/25/2018 Mod_spdy Architectural Overview
54/61
Critical SPDY features
Next Protocol Negotiation (NPN)
Framing and header compression
Stream multiplexing
Server push
5/25/2018 Mod_spdy Architectural Overview
55/61
Server push
mod_spdy provides a server-push function
to other modules.
When called (e.g. from a stream request
handler), the main SPDY connection thread
creates a new server-push stream.
We synthesize a request to imaginethat the
client sent us, and allow Apache to respond
accordingly.
5/25/2018 Mod_spdy Architectural Overview
56/61
Server push
One wrinkle: by the spec, we must send the
pushed SYN_STREAM beforethe
associated stream's FLAG_FIN.
5/25/2018 Mod_spdy Architectural Overview
57/61
Server push
One wrinkle: by the spec, we must send the
pushed SYN_STREAM beforethe
associated stream's FLAG_FIN.
But we don't have response headers yet,
and don't want to impose a synchronization
between stream threads.
5/25/2018 Mod_spdy Architectural Overview
58/61
Server push
One wrinkle: by the spec, we must send the
pushed SYN_STREAM beforethe
associated stream's FLAG_FIN.
But we don't have response headers yet,
and don't want to impose a synchronization
between stream threads.
Solution: send SYN_STREAM sans
headers; follow up with HEADERS frame
5/25/2018 Mod_spdy Architectural Overview
59/61
Critical SPDY features
Next Protocol Negotiation (NPN)
Framing and header compression
Stream multiplexing
Server push
5/25/2018 Mod_spdy Architectural Overview
60/61
Remaining tasks/challenges
Get SSL changes into Apache trunk.https://issues.apache.org/bugzilla/show_bug.cgi?id=52210
Support SPDY v3 in addition to v2.
Experiment further with server push.
https://issues.apache.org/bugzilla/show_bug.cgi?id=522105/25/2018 Mod_spdy Architectural Overview
61/61
Open source project:
http://code.google.com/p/mod-spdy/
Download DEB/RPM packages:
https://developers.google.com/speed/spdy/mod_spdy/
http://code.google.com/p/mod-spdy/https://developers.google.com/speed/spdy/mod_spdy/http://code.google.com/p/mod-spdy/