SlideShare a Scribd company logo
Alternative Infrastucture

 if we do it, we might as well do it
                right
Experiments

Twitter clone "retwis":
    Key Value Store: redis
    Web Framework: sinatra

Mediawiki:
    Webserver: Nginx (!= Apache)
    PHP: php-fpm (!= mod_php)
Retwis-RB
"An example Twitter application using the Redis key-value
database" --> http://github.com/danlucraft/retwis-rb
        sinatra               redis
        require 'rubygems'    require 'rubygems'
        require 'sinatra'     require 'redis'
        get '/hi' do 
           "Hello World!"     r = Redis.new
        end                   puts "set foo to bar"
                              r['foo'] = 'bar'
Redis Benchmark
root@keyvalue:~# redis-benchmark -q

SET: 105273.69 requests per second
GET: 107526.88 requests per second
INCR: 95238.10 requests per second
LPUSH: 121987.80 requests per second
LPOP: 108728.26 requests per second
PING: 133386.66 requests per second
testing @ HdM

CPU:
100% httperf            
57% redis-server
40% ruby1.9.1 
 

Durchsatz: 6 req/s           Ò_ó
Context Switches?




                    ?!
server ->



home ->
Home Tests:

httperf --server=localhost --port=4567 --uri=/test --num-
conns=100 --num-calls=50

Webserver: "thin"

EventMachine:
a library for Ruby, C++, and Java programs. It provides event-
driven I/O using the Reactor pattern
single connection
                                home
Total: 
                Request rate    56.7 req/s
connections 1                   (17.6 ms/req)
requests 500    Reply rate      min 41.6
                [replies/s]     avg 41.6
replies 500                     max 41.6

                Reply time      response 17.6
                [ms]            transfer 0.0

                Reply status:   1xx=0 2xx=500 3xx=0 4xx=0 5xx=0

                test-duration   8.824 s
100 connections
                                  home
Total:
                  Request rate    48.5 req/s
connections 100                   (20.6 ms/req)
requests 5000
                  Reply rate      min 16.2
replies 5000      [replies/s]     avg 48.7
                                  max 71.6

                  Reply time      response 20.6
                  [ms]            transfer 0.0
                  Reply status:   1xx=0 2xx=5000 3xx=0 4xx=0 5xx=0

                  test-duration   103.160 s
2nd Experimental Setup

        Replacing 
   Apache+mod_php by 
     Nginx+PHP-FPM
Nginx ...

is...
    a lightweight Web Server
    a Reverse Proxy
    an IMAP/POP3 proxy
 
    used by 14,988,610 domains today
    implmented by larges sites as WordPress, Github,
    SourceForge etc.
 
Nginx vs Apache

      Apache
            process based
            each connection requires a new thread
            high concurrency
          -> high memory usage
          -> CPU overhead (e.g. context switches)
            PHP is usally included in Apache Web Server as module (mod_php)
       
      Nginx
            fork of apache 1.3 with the multi-processing ripped out in favor of an
            event loop
      asynchronous model (event based)
      uses only one thread for all connections (master thread)
      PHP is used as seperate process over FastCGI (PHP-FPM)
            Web Server and PHP-FPM are used as seperate applications
            communication via TCP-connetions or Unix-sockets
        -> little overhead due to communication costs
Event Loop

What is an event loop?

usually you write code like:
var result = db.query("select..");
result.do_something();


but an event loop looks like:
db.query("select..", function (result) { result.do_something()});
Motivation
           Apache+mod_php compared to Nginx+php-fpm
             (comparison made by Boštjan Škufca - http://blog.a2o.si))


5 Different scenarios
    HelloWorld.php – simple echo of “Hello, World!” (13 bytes),
    HelloWorld.txt – static file with “Hello, World!” (also 13 bytes)
    100KB.txt – static content
    1MB.txt - static content
    index.php – more complex site with several DB-queries, HTML
    template parsing…

Tests with keepalive-feature [-k] and without keepalive
(same socket can be used for request and response)
Benchmark Setup
  Benchmark tests conducted using
  ApacheBench
  ab -n NREQ -c NCONC [-k] http://server.domain.
  com/bench/FileName
  NREQ is the number of requests:
  - HelloWorld.php: 500000
  - HelloWorld.txt: 500000
  - 100KB.txt: 500000
  - 1MB.txt: 50000
  - AppFront: 5000

   NCONC = number of concurrent requests
1 ,2,4,8,16,32,64,128,256,512
PHP-generated Hello World!
Apche is always faster than Nginx
This demonstrates the overhead of the
communication between Nginx and PHP-
FPM
Static Hello World!
Nginx with keepalive is more than twice as fast as
Apache
This demonstrates the overhead that is caused by
creating TCP-connections
Static 100kb.txt File
This test should demonstrate a „real world
“ example of a static page request
Again, Nginx is twice as fast as Apache
1MB.txt File
This test demonstates a more complex file transfer
Keepalive was not tested, because the file size is so
large that TCP-connections aren‘t important
Nginx is just slightly better
Application Frontpage (index.
             php)
Again a „real world“ example with a more
complex PHP-site
Nginx is just slightly better
Apache PHP vs TXT
Dynamically generated content and static
content are nearly equally fast
Nginx PHP vs TXT
Nginx serves static content twice as fast
as dynamic content
Additional Comparison
Conclusion
When is it worth to use Nginx?
  If you have limited hardware resources
  (e.g. on VPS)
  If you have a lot of static content
Further Alternative
    Nginx works as reverse proxy
    static content is passed by Nginx (e.g. Pictures)
    dynamic Content will be forwarded to an Apache
       behind the proxy

    advantages:
        static content will be returned very fast
        slow user connections do no longer hold
       resources, because the "blocking"
       connection is now between Nginx and
       Apache; not the user and Apache
our problems

mysql dumps:
create dump + copy dump + insert dump = hours

loadtesting:
     client == server
--> no testing for high concurrency, no isolation of variables.
     client too slow 
     different configurations
          keepalives
          Nginx workers/processes vs apache threads/clients
          ...

More Related Content

What's hot

Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!
Trygve Vea
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
Tom Croucher
 
Full Stack Load Testing
Full Stack Load Testing Full Stack Load Testing
Full Stack Load Testing
Terral R Jordan
 
Interactive web. O rly?
Interactive web. O rly?Interactive web. O rly?
Interactive web. O rly?
timbc
 
Load Balancing with Nginx
Load Balancing with NginxLoad Balancing with Nginx
Load Balancing with Nginx
Marian Marinov
 
Boyan Ivanov - latency, the #1 metric of your cloud
Boyan Ivanov - latency, the #1 metric of your cloudBoyan Ivanov - latency, the #1 metric of your cloud
Boyan Ivanov - latency, the #1 metric of your cloud
ShapeBlue
 
Apache Traffic Server
Apache Traffic ServerApache Traffic Server
Apache Traffic Server
supertom
 
Netty - anfix tech&beers
Netty - anfix tech&beersNetty - anfix tech&beers
Netty - anfix tech&beers
jorgecarabias
 
Nginx Scalable Stack
Nginx Scalable StackNginx Scalable Stack
Nginx Scalable Stack
Bruno Paiuca
 
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
Marcus Frödin
 
Compressing & decompressing in mule
Compressing & decompressing in muleCompressing & decompressing in mule
Compressing & decompressing in mule
Anirban Sen Chowdhary
 
Grafana is not enough: DIY user interfaces for Prometheus
Grafana is not enough: DIY user interfaces for PrometheusGrafana is not enough: DIY user interfaces for Prometheus
Grafana is not enough: DIY user interfaces for Prometheus
Weaveworks
 
Haproxy - zastosowania
Haproxy - zastosowaniaHaproxy - zastosowania
Haproxy - zastosowania
Łukasz Jagiełło
 
Backing up thousands of containers
Backing up thousands of containersBacking up thousands of containers
Backing up thousands of containers
Marian Marinov
 
Debugging Network Issues
Debugging Network IssuesDebugging Network Issues
Debugging Network Issues
Apcera
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with Prometheus
Shiao-An Yuan
 
Netty from the trenches
Netty from the trenchesNetty from the trenches
Netty from the trenches
Jordi Gerona
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + Memcached
Ford AntiTrust
 
Oscon 2010 - ATS
Oscon 2010 - ATSOscon 2010 - ATS
Oscon 2010 - ATS
Leif Hedstrom
 
Node js
Node jsNode js

What's hot (20)

Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
 
Full Stack Load Testing
Full Stack Load Testing Full Stack Load Testing
Full Stack Load Testing
 
Interactive web. O rly?
Interactive web. O rly?Interactive web. O rly?
Interactive web. O rly?
 
Load Balancing with Nginx
Load Balancing with NginxLoad Balancing with Nginx
Load Balancing with Nginx
 
Boyan Ivanov - latency, the #1 metric of your cloud
Boyan Ivanov - latency, the #1 metric of your cloudBoyan Ivanov - latency, the #1 metric of your cloud
Boyan Ivanov - latency, the #1 metric of your cloud
 
Apache Traffic Server
Apache Traffic ServerApache Traffic Server
Apache Traffic Server
 
Netty - anfix tech&beers
Netty - anfix tech&beersNetty - anfix tech&beers
Netty - anfix tech&beers
 
Nginx Scalable Stack
Nginx Scalable StackNginx Scalable Stack
Nginx Scalable Stack
 
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
 
Compressing & decompressing in mule
Compressing & decompressing in muleCompressing & decompressing in mule
Compressing & decompressing in mule
 
Grafana is not enough: DIY user interfaces for Prometheus
Grafana is not enough: DIY user interfaces for PrometheusGrafana is not enough: DIY user interfaces for Prometheus
Grafana is not enough: DIY user interfaces for Prometheus
 
Haproxy - zastosowania
Haproxy - zastosowaniaHaproxy - zastosowania
Haproxy - zastosowania
 
Backing up thousands of containers
Backing up thousands of containersBacking up thousands of containers
Backing up thousands of containers
 
Debugging Network Issues
Debugging Network IssuesDebugging Network Issues
Debugging Network Issues
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with Prometheus
 
Netty from the trenches
Netty from the trenchesNetty from the trenches
Netty from the trenches
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + Memcached
 
Oscon 2010 - ATS
Oscon 2010 - ATSOscon 2010 - ATS
Oscon 2010 - ATS
 
Node js
Node jsNode js
Node js
 

Viewers also liked

From LAMP to LNNP
From LAMP to LNNPFrom LAMP to LNNP
From LAMP to LNNP
Giorgio Cefaro
 
Word press on conoha このべん #3
Word press on conoha このべん #3Word press on conoha このべん #3
Word press on conoha このべん #3
Wataru OKAMOTO
 
mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较
Ji ZHANG
 
Running php on nginx
Running php on nginxRunning php on nginx
Running php on nginx
Harald Zeitlhofer
 
Nginx + PHP
Nginx + PHPNginx + PHP
Nginx + PHP
Wataru OKAMOTO
 
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OSSupercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
CloudLinux
 
High performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructureHigh performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructure
mkherlakian
 
PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春
Ryo Tomidokoro
 
Techtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPMTechtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPM
Webscale
 
PHP Files: An Introduction
PHP Files: An IntroductionPHP Files: An Introduction
PHP Files: An Introduction
Jacques Woodcock
 
第2回勉強会資料 柏木
第2回勉強会資料 柏木第2回勉強会資料 柏木
第2回勉強会資料 柏木
beyond0iwamoto
 
mod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLImod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLI
Jacques Woodcock
 
Nginx pres
Nginx presNginx pres
Nginx pres
James Fuller
 
PHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探るPHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探るYoshio Hanawa
 
Ultrafast WordPress Virtual Word camp2015
Ultrafast WordPress Virtual  Word camp2015 Ultrafast WordPress Virtual  Word camp2015
Ultrafast WordPress Virtual Word camp2015
Yuta Sakamoto
 
realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係
Yoshio Hanawa
 
PHP development with Docker
PHP development with DockerPHP development with Docker
PHP development with Docker
Yosh de Vos
 
CDW and You
CDW and YouCDW and You
CDW and You
Kimhig
 
Harold J resume+041216
Harold J resume+041216Harold J resume+041216
Harold J resume+041216
Harold Berg
 
Non-Specialized File Format Extension
Non-Specialized File Format ExtensionNon-Specialized File Format Extension
Non-Specialized File Format Extension
CSCJournals
 

Viewers also liked (20)

From LAMP to LNNP
From LAMP to LNNPFrom LAMP to LNNP
From LAMP to LNNP
 
Word press on conoha このべん #3
Word press on conoha このべん #3Word press on conoha このべん #3
Word press on conoha このべん #3
 
mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较
 
Running php on nginx
Running php on nginxRunning php on nginx
Running php on nginx
 
Nginx + PHP
Nginx + PHPNginx + PHP
Nginx + PHP
 
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OSSupercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
 
High performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructureHigh performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructure
 
PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春
 
Techtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPMTechtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPM
 
PHP Files: An Introduction
PHP Files: An IntroductionPHP Files: An Introduction
PHP Files: An Introduction
 
第2回勉強会資料 柏木
第2回勉強会資料 柏木第2回勉強会資料 柏木
第2回勉強会資料 柏木
 
mod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLImod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLI
 
Nginx pres
Nginx presNginx pres
Nginx pres
 
PHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探るPHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探る
 
Ultrafast WordPress Virtual Word camp2015
Ultrafast WordPress Virtual  Word camp2015 Ultrafast WordPress Virtual  Word camp2015
Ultrafast WordPress Virtual Word camp2015
 
realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係
 
PHP development with Docker
PHP development with DockerPHP development with Docker
PHP development with Docker
 
CDW and You
CDW and YouCDW and You
CDW and You
 
Harold J resume+041216
Harold J resume+041216Harold J resume+041216
Harold J resume+041216
 
Non-Specialized File Format Extension
Non-Specialized File Format ExtensionNon-Specialized File Format Extension
Non-Specialized File Format Extension
 

Similar to Alternative Infrastucture

Nginx
NginxNginx
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect ToolboxWebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisation
grooverdan
 
Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java
Baruch Sadogursky
 
Optimizing wordpress
Optimizing wordpressOptimizing wordpress
Optimizing wordpress
ReactiveOps, Inc.
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Joseph Scott
 
Supercharging Content Delivery with Varnish
Supercharging Content Delivery with VarnishSupercharging Content Delivery with Varnish
Supercharging Content Delivery with Varnish
Samantha Quiñones
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
No callbacks, No Threads - Cooperative web servers in Ruby 1.9No callbacks, No Threads - Cooperative web servers in Ruby 1.9
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
Ilya Grigorik
 
21 Www Web Services
21 Www Web Services21 Www Web Services
21 Www Web Services
royans
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & Performance
Arjan
 
Rack
RackRack
Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015
fukamachi
 
Scalable Apache for Beginners
Scalable Apache for BeginnersScalable Apache for Beginners
Scalable Apache for Beginners
webhostingguy
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
Nir Noy
 
Nginx internals
Nginx internalsNginx internals
Nginx internals
liqiang xu
 
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web serverNginx 0.8.x + php 5.2.13 (fast cgi) setup web server
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
wruben
 
NoSQL afternoon in Japan Kumofs & MessagePack
NoSQL afternoon in Japan Kumofs & MessagePackNoSQL afternoon in Japan Kumofs & MessagePack
NoSQL afternoon in Japan Kumofs & MessagePack
Sadayuki Furuhashi
 
NoSQL afternoon in Japan kumofs & MessagePack
NoSQL afternoon in Japan kumofs & MessagePackNoSQL afternoon in Japan kumofs & MessagePack
NoSQL afternoon in Japan kumofs & MessagePack
Sadayuki Furuhashi
 
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
Ontico
 

Similar to Alternative Infrastucture (20)

Nginx
NginxNginx
Nginx
 
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect ToolboxWebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisation
 
Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java
 
Optimizing wordpress
Optimizing wordpressOptimizing wordpress
Optimizing wordpress
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
Supercharging Content Delivery with Varnish
Supercharging Content Delivery with VarnishSupercharging Content Delivery with Varnish
Supercharging Content Delivery with Varnish
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
No callbacks, No Threads - Cooperative web servers in Ruby 1.9No callbacks, No Threads - Cooperative web servers in Ruby 1.9
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
 
21 Www Web Services
21 Www Web Services21 Www Web Services
21 Www Web Services
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & Performance
 
Rack
RackRack
Rack
 
Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015
 
Scalable Apache for Beginners
Scalable Apache for BeginnersScalable Apache for Beginners
Scalable Apache for Beginners
 
Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
 
Nginx internals
Nginx internalsNginx internals
Nginx internals
 
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web serverNginx 0.8.x + php 5.2.13 (fast cgi) setup web server
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
 
NoSQL afternoon in Japan Kumofs & MessagePack
NoSQL afternoon in Japan Kumofs & MessagePackNoSQL afternoon in Japan Kumofs & MessagePack
NoSQL afternoon in Japan Kumofs & MessagePack
 
NoSQL afternoon in Japan kumofs & MessagePack
NoSQL afternoon in Japan kumofs & MessagePackNoSQL afternoon in Japan kumofs & MessagePack
NoSQL afternoon in Japan kumofs & MessagePack
 
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
 

More from Marc Seeger

DevOps Boston - Heartbleed at Acquia
DevOps Boston - Heartbleed at AcquiaDevOps Boston - Heartbleed at Acquia
DevOps Boston - Heartbleed at Acquia
Marc Seeger
 
The current state of anonymous filesharing
The current state of anonymous filesharingThe current state of anonymous filesharing
The current state of anonymous filesharing
Marc Seeger
 
Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraLunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and Capybara
Marc Seeger
 
NoSQL databases
NoSQL databasesNoSQL databases
NoSQL databases
Marc Seeger
 
building blocks of a scalable webcrawler
building blocks of a scalable webcrawlerbuilding blocks of a scalable webcrawler
building blocks of a scalable webcrawler
Marc Seeger
 
Communitygetriebe Android Systementwicklung
Communitygetriebe Android SystementwicklungCommunitygetriebe Android Systementwicklung
Communitygetriebe Android SystementwicklungMarc Seeger
 
Eventdriven I/O - A hands on introduction
Eventdriven I/O - A hands on introductionEventdriven I/O - A hands on introduction
Eventdriven I/O - A hands on introduction
Marc Seeger
 
Communitygetriebene Android Systemerweiterungen
Communitygetriebene Android SystemerweiterungenCommunitygetriebene Android Systemerweiterungen
Communitygetriebene Android Systemerweiterungen
Marc Seeger
 
Key-Value Stores: a practical overview
Key-Value Stores: a practical overviewKey-Value Stores: a practical overview
Key-Value Stores: a practical overview
Marc Seeger
 
ZFS
ZFSZFS
The Dirac Video CoDec
The Dirac Video CoDecThe Dirac Video CoDec
The Dirac Video CoDec
Marc Seeger
 
Anonimität - Konzepte und Werkzeuge
Anonimität - Konzepte und WerkzeugeAnonimität - Konzepte und Werkzeuge
Anonimität - Konzepte und Werkzeuge
Marc Seeger
 
Security In Dect
Security In DectSecurity In Dect
Security In Dect
Marc Seeger
 
Social Media in der Unternehmenskommunikation
Social Media in der UnternehmenskommunikationSocial Media in der Unternehmenskommunikation
Social Media in der Unternehmenskommunikation
Marc Seeger
 
xDSL, DSLAM & CO
xDSL, DSLAM & COxDSL, DSLAM & CO
xDSL, DSLAM & CO
Marc Seeger
 
Ruby Xml Mapping
Ruby Xml MappingRuby Xml Mapping
Ruby Xml Mapping
Marc Seeger
 
HdM Stuttgart Präsentationstag PPTP VPN WLAN Update
HdM Stuttgart Präsentationstag PPTP VPN WLAN UpdateHdM Stuttgart Präsentationstag PPTP VPN WLAN Update
HdM Stuttgart Präsentationstag PPTP VPN WLAN Update
Marc Seeger
 

More from Marc Seeger (17)

DevOps Boston - Heartbleed at Acquia
DevOps Boston - Heartbleed at AcquiaDevOps Boston - Heartbleed at Acquia
DevOps Boston - Heartbleed at Acquia
 
The current state of anonymous filesharing
The current state of anonymous filesharingThe current state of anonymous filesharing
The current state of anonymous filesharing
 
Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraLunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and Capybara
 
NoSQL databases
NoSQL databasesNoSQL databases
NoSQL databases
 
building blocks of a scalable webcrawler
building blocks of a scalable webcrawlerbuilding blocks of a scalable webcrawler
building blocks of a scalable webcrawler
 
Communitygetriebe Android Systementwicklung
Communitygetriebe Android SystementwicklungCommunitygetriebe Android Systementwicklung
Communitygetriebe Android Systementwicklung
 
Eventdriven I/O - A hands on introduction
Eventdriven I/O - A hands on introductionEventdriven I/O - A hands on introduction
Eventdriven I/O - A hands on introduction
 
Communitygetriebene Android Systemerweiterungen
Communitygetriebene Android SystemerweiterungenCommunitygetriebene Android Systemerweiterungen
Communitygetriebene Android Systemerweiterungen
 
Key-Value Stores: a practical overview
Key-Value Stores: a practical overviewKey-Value Stores: a practical overview
Key-Value Stores: a practical overview
 
ZFS
ZFSZFS
ZFS
 
The Dirac Video CoDec
The Dirac Video CoDecThe Dirac Video CoDec
The Dirac Video CoDec
 
Anonimität - Konzepte und Werkzeuge
Anonimität - Konzepte und WerkzeugeAnonimität - Konzepte und Werkzeuge
Anonimität - Konzepte und Werkzeuge
 
Security In Dect
Security In DectSecurity In Dect
Security In Dect
 
Social Media in der Unternehmenskommunikation
Social Media in der UnternehmenskommunikationSocial Media in der Unternehmenskommunikation
Social Media in der Unternehmenskommunikation
 
xDSL, DSLAM & CO
xDSL, DSLAM & COxDSL, DSLAM & CO
xDSL, DSLAM & CO
 
Ruby Xml Mapping
Ruby Xml MappingRuby Xml Mapping
Ruby Xml Mapping
 
HdM Stuttgart Präsentationstag PPTP VPN WLAN Update
HdM Stuttgart Präsentationstag PPTP VPN WLAN UpdateHdM Stuttgart Präsentationstag PPTP VPN WLAN Update
HdM Stuttgart Präsentationstag PPTP VPN WLAN Update
 

Recently uploaded

A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
ScyllaDB
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
Enterprise Knowledge
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdfLee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
leebarnesutopia
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
Fwdays
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
Tobias Schneck
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
LizaNolte
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
Fwdays
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
HarpalGohil4
 

Recently uploaded (20)

A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdfLee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
 

Alternative Infrastucture

  • 1. Alternative Infrastucture if we do it, we might as well do it right
  • 2. Experiments Twitter clone "retwis":     Key Value Store: redis     Web Framework: sinatra Mediawiki:     Webserver: Nginx (!= Apache)     PHP: php-fpm (!= mod_php)
  • 3. Retwis-RB "An example Twitter application using the Redis key-value database" --> http://github.com/danlucraft/retwis-rb sinatra redis require 'rubygems' require 'rubygems' require 'sinatra' require 'redis' get '/hi' do     "Hello World!"  r = Redis.new end puts "set foo to bar" r['foo'] = 'bar'
  • 4. Redis Benchmark root@keyvalue:~# redis-benchmark -q SET: 105273.69 requests per second GET: 107526.88 requests per second INCR: 95238.10 requests per second LPUSH: 121987.80 requests per second LPOP: 108728.26 requests per second PING: 133386.66 requests per second
  • 5. testing @ HdM CPU: 100% httperf             57% redis-server 40% ruby1.9.1    Durchsatz: 6 req/s         Ò_ó
  • 8. Home Tests: httperf --server=localhost --port=4567 --uri=/test --num- conns=100 --num-calls=50 Webserver: "thin" EventMachine: a library for Ruby, C++, and Java programs. It provides event- driven I/O using the Reactor pattern
  • 9. single connection home Total:  Request rate 56.7 req/s connections 1 (17.6 ms/req) requests 500 Reply rate min 41.6 [replies/s] avg 41.6 replies 500 max 41.6 Reply time response 17.6 [ms] transfer 0.0 Reply status: 1xx=0 2xx=500 3xx=0 4xx=0 5xx=0 test-duration 8.824 s
  • 10. 100 connections home Total: Request rate 48.5 req/s connections 100 (20.6 ms/req) requests 5000 Reply rate min 16.2 replies 5000 [replies/s] avg 48.7 max 71.6 Reply time response 20.6 [ms] transfer 0.0 Reply status: 1xx=0 2xx=5000 3xx=0 4xx=0 5xx=0 test-duration 103.160 s
  • 11. 2nd Experimental Setup Replacing  Apache+mod_php by  Nginx+PHP-FPM
  • 12. Nginx ... is... a lightweight Web Server a Reverse Proxy an IMAP/POP3 proxy   used by 14,988,610 domains today implmented by larges sites as WordPress, Github, SourceForge etc.  
  • 13. Nginx vs Apache Apache process based each connection requires a new thread high concurrency     -> high memory usage     -> CPU overhead (e.g. context switches) PHP is usally included in Apache Web Server as module (mod_php)   Nginx fork of apache 1.3 with the multi-processing ripped out in favor of an event loop asynchronous model (event based) uses only one thread for all connections (master thread) PHP is used as seperate process over FastCGI (PHP-FPM) Web Server and PHP-FPM are used as seperate applications communication via TCP-connetions or Unix-sockets         -> little overhead due to communication costs
  • 14. Event Loop What is an event loop? usually you write code like: var result = db.query("select.."); result.do_something(); but an event loop looks like: db.query("select..", function (result) { result.do_something()});
  • 15. Motivation Apache+mod_php compared to Nginx+php-fpm (comparison made by Boštjan Škufca - http://blog.a2o.si)) 5 Different scenarios HelloWorld.php – simple echo of “Hello, World!” (13 bytes), HelloWorld.txt – static file with “Hello, World!” (also 13 bytes) 100KB.txt – static content 1MB.txt - static content index.php – more complex site with several DB-queries, HTML template parsing… Tests with keepalive-feature [-k] and without keepalive (same socket can be used for request and response)
  • 16. Benchmark Setup Benchmark tests conducted using ApacheBench ab -n NREQ -c NCONC [-k] http://server.domain. com/bench/FileName NREQ is the number of requests: - HelloWorld.php: 500000 - HelloWorld.txt: 500000 - 100KB.txt: 500000 - 1MB.txt: 50000 - AppFront: 5000 NCONC = number of concurrent requests 1 ,2,4,8,16,32,64,128,256,512
  • 17. PHP-generated Hello World! Apche is always faster than Nginx This demonstrates the overhead of the communication between Nginx and PHP- FPM
  • 18. Static Hello World! Nginx with keepalive is more than twice as fast as Apache This demonstrates the overhead that is caused by creating TCP-connections
  • 19. Static 100kb.txt File This test should demonstrate a „real world “ example of a static page request Again, Nginx is twice as fast as Apache
  • 20. 1MB.txt File This test demonstates a more complex file transfer Keepalive was not tested, because the file size is so large that TCP-connections aren‘t important Nginx is just slightly better
  • 21. Application Frontpage (index. php) Again a „real world“ example with a more complex PHP-site Nginx is just slightly better
  • 22. Apache PHP vs TXT Dynamically generated content and static content are nearly equally fast
  • 23. Nginx PHP vs TXT Nginx serves static content twice as fast as dynamic content
  • 25. Conclusion When is it worth to use Nginx? If you have limited hardware resources (e.g. on VPS) If you have a lot of static content
  • 26. Further Alternative Nginx works as reverse proxy static content is passed by Nginx (e.g. Pictures) dynamic Content will be forwarded to an Apache        behind the proxy advantages: static content will be returned very fast slow user connections do no longer hold resources, because the "blocking" connection is now between Nginx and Apache; not the user and Apache
  • 27. our problems mysql dumps: create dump + copy dump + insert dump = hours loadtesting: client == server --> no testing for high concurrency, no isolation of variables. client too slow  different configurations keepalives Nginx workers/processes vs apache threads/clients ...