SlideShare a Scribd company logo
1 of 27
Download to read offline
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

Interactive web. O rly?
Interactive web. O rly?Interactive web. O rly?
Interactive web. O rly?
timbc
 
Netty - anfix tech&beers
Netty - anfix tech&beersNetty - anfix tech&beers
Netty - anfix tech&beers
jorgecarabias
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + Memcached
Ford AntiTrust
 

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

PHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探るPHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探る
Yoshio Hanawa
 
Harold J resume+041216
Harold J resume+041216Harold J resume+041216
Harold J resume+041216
Harold Berg
 

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

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
 
Scalable Apache for Beginners
Scalable Apache for BeginnersScalable Apache for Beginners
Scalable Apache for Beginners
webhostingguy
 
Nginx internals
Nginx internalsNginx internals
Nginx internals
liqiang xu
 
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

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
 
Communitygetriebe Android Systementwicklung
Communitygetriebe Android SystementwicklungCommunitygetriebe Android Systementwicklung
Communitygetriebe Android Systementwicklung
Marc 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
 
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
 
Security In Dect
Security In DectSecurity In Dect
Security In Dect
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

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

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 ...