12 : REST : Apache Tomcat Node.js 1 / 29
basic auth/:.htaccess.htpasswd.htaccess Web ( MIME ) testcgi.c: CGI rest.rb: yahoo CGI (written in ruby) tomcat/ testform.html: form.jsp form.jsp: PUT JSP form jsp.java: form.jsp java test.jsp: <% <%! JSP test jsp.java: src/: servlet (HelloWorld.java, web.xml) server.js: Node.js 2 / 29
Web Apache The Apache Software Foundation Apache HTTP Server LAMP: Linux, Apache, MySQL, PHP/Perl Web IIS (Internet Information Server) Nginx Lighttpd Node.js GWS (Google Web Server) 3 / 29
apache apache1.3 (apache 2 ) apache apache core apache modules (core ) module http://httpd.apache.org/docs/2.4/mod/ 4 / 29
Apache O.A.Dragoi, The Conceptual Architecture of the Apache Web Server, CS746G, Univ. of Waterloo.
Apache Core O.A.Dragoi, The Conceptual Architecture of the Apache Web Server, CS746G, Univ. of Waterloo.
http request http request URI to filename translation Check access based on host address, and other available information Get an user id from the HTTP request and validate it Authorize the user Determine the MIME type of the requested object (the content type, the encoding and the language) Fix-ups (for example replace aliases by the actual path) Send the actual data back to the client Log the request 7 / 29
Module handler O.A.Dragoi, The Conceptual Architecture of the Apache Web Server, CS746G, Univ. of Waterloo.
(prefork) O.A.Dragoi, The Conceptual Architecture of the Apache Web Server, CS746G, Univ. of Waterloo.
Apache2 MPM (Multi-processing module) module apache MPM prefork (apache 1.3 ) worker ( ) APR (Apache Portable Runtime) apache http server OS (http server ) 10 / 29
apache prefork/worker vs lighttpd (1) ab http://thinkit.co.jp/book/2008/07/31/150 11 / 29
apache prefork/worker vs lighttpd (2) http load http://thinkit.co.jp/book/2008/07/31/150 12 / 29
/etc/apache2/apache2.conf Debian Include : : /etc/apache2/mods-enabled/*.load /etc/apache2/mods-enabled/*.conf : /etc/apache2/httpd.conf : /etc/apache2/ports.conf : /etc/apache2/conf.d/ : /etc/apache2/sites-enabled/ 13 / 29
IP IP NameVirtualHost *:80 <VirtualHost *:80> ServerName www.example.com DocumentRoot /var/www1 </VirtualHost> <VirtualHost *:80> ServerName www.example.org DocumentRoot /var/www2 </VirtualHost> IP <VirtualHost 10.0.0.1> ServerName DocumentRoot </VirtualHost> <VirtualHost *:8080> 14 / 29
Proxy ( ) mod cache GET Host URL ProxyRequests on ProxyPass /test http://localhost:3000/test 15 / 29
[proxy.de.shibaura-it.ac.jp ] GET http://www.google.co.jp/ HTTP/1.1 Host: www.google.co.jp Proxy-Connection: keep-alive Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,i User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.13 ( Accept-Encoding: gzip,deflate,sdch Accept-Language: ja,en-us;q=0.8,en;q=0.6 Accept-Charset: Shift_JIS,utf-8;q=0.7,*;q=0.3 Cookie: PREF=ID=3e5f9 [proxy.de.shibaura-it.ac.jp ] HTTP/1.0 200 OK Content-Type: text/html; charset=utf-8 Date: Thu, 10 Feb 2011 07:12:13 GMT Expires: Thu, 10 Feb 2011 07:12:13 GMT Cache-Control: private, must-revalidate, max-age=0 Last-Modified: Thu, 10 Feb 2011 07:12:13 GMT ETag: 7869640352321481114 Set-Cookie: IGTP=LI=1:LM=1297321933; expires=sat, 09-Feb-2013 07:12:13 GMT; path Set-Cookie: SID=DQAAA ; expires=sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.g X-Content-Type-Options: nosniff Server: igfe Content-Encoding: gzip X-Cache: MISS from proxyyi01.sic.shibaura-it.ac.jp Via: 1.0 proxyyi01.sic.shibaura-it.ac.jp:10080 (squid/2.7.stable9) Connection: close 16 / 29
mod alias Alias Redirect Alias /foo/bar /baz Redirect "/example" "http://www2.example.com/new/location" Redirect "example(/.*)" "http://www2.example.com/new/location" Rewrite 17 / 29
module http://httpd.apache.org/docs/2.4/mod/ mod proxy: mod ssl: https mod cache: mod disk cache mod mem cache mod rewrite: URL URL redirect mod deflate: mod perl, mod php: perl php 18 / 29
CGI (Common Gateway Interface) Web http://www.example.com/cgi-bin/test.cgi test.cgi test.cgi 19 / 29
cgi /etc/apache2/sites-enabled/000-default : ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> 20 / 29
cgi testcgi.c: GET 3 testform.c: POST name=yamazaki&birthday=10 method="get" QUERY_STRING apache getenv() http HTTP_ Last-event-id HTTP_LAST_EVENT_ID rest.rb: ruby 21 / 29
Tomcat Tomcat Servlet ( Java ) JSP (HTML ) Apache Servlet Java CGI (Java VM ) Java 22 / 29
Servlet tomcat/src/web-inf web.xml => URL classes/* => lib/* =>? 23 / 29
JSP (Java Server Pages) HTML Java : <body>... <% out.println(expr) %> <%= expr =%> expr HTML (tostring() ) <%@... %> page <%!... %> 24 / 29
JSP src/tomcat/ testform.html: submit form.jsp method= PUT POST JSP form.jsp test.jsp form_jsp.java: form.jsp test_jsp.java: test.jsp 25 / 29
Node.js JavaScript Web Server Web Server Web Server server.js http://code.google.com/p/node-js-vs-apache-php-benchmark/wiki/tests ( JavaScript ) JSON WebSocket 26 / 29
C10K Problem: 10000 select/poll + IO (AIO) [nginx, lighttpd, node.js] IO [Apache] select/poll checksum IO : : Citrix Netscaler ( Gbps ) : Linux LVS DSR (Direct Server Return) 27 / 29
引 用 元 http://seravo.fi/2012/the-fastest-web-server-in-the-world The fastest web server in the world? Speed of individual requests How long did it take to deliver 414000 files? Average total time in milliseconds
: ( ) : : : 3 API HTML5 (Web ) : Apache/Tomcat/Node.js PC : IaaS: Amazon EC2 PaaS: Heroku MyVolume public html JS (google Twitter ) API 15 (2014 1 23 ) ( ) ( ) + + 29 / 29