SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
From LAMP to LNNP
              A Transition from

     Linux Apache Mysql (mod_)PHP
                     to

 Linux (what else?) Nginx Nosql PHP(-FPM)


              Giorgio Cefaro
           http://giorgiocefaro.com
                     @giorrrgio
L→L
from Linux to...Linux
(intentionally blank)
A→N
from Apache to Nginx
Vs



                            From Wikipedia:

Nginx uses an asynchronous event-driven approach to handling requests
    which can provide more predictable performance under high loads,
 in contrast to the Apache HTTP server model that defaults to a threaded
            or process-oriented approach to handling requests
PHP Hello world benchmarks
        Ab -k -n 50000 -c 10 http://10.0.0.3/test.php




Concurrency Level:      10               Concurrency Level:      10
Time taken for tests:   31.796 seconds   Time taken for tests:   18.646 seconds
Complete requests:      50000            Complete requests:      50000
Failed requests:        0                Failed requests:        0
Write errors:           0                Write errors:           0
Keep-Alive requests:    0                Keep-Alive requests:    49509
Total transferred:      8450000 bytes    Total transferred:      12928406 bytes
HTML transferred:       550000 bytes     HTML transferred:       550000 bytes
Requests per second:    1572.54          Requests per second:    2681.54
[#/sec] (mean)                           [#/sec] (mean)
Time per request:       6.359 [ms]       Time per request:       3.729 [ms]
(mean)                                   (mean)
Time per request:       0.636 [ms]       Time per request:       0.373 [ms]
(mean, across all concurrent requests)   (mean, across all concurrent requests)
Transfer rate:          259.53           Transfer rate:          677.11
[Kbytes/sec] received                    [Kbytes/sec] received


Load average: 4.38, 1.29, 0.46           Load average: 3.00, 0.89, 0.32
PHP Hello world benchmarks
        Ab -k -n 50000 -c 100 http://10.0.0.3/test.php




Concurrency Level:      100              Concurrency Level:      100
Time taken for tests:   28.143 seconds   Time taken for tests:   18.398 seconds
Complete requests:      50000            Complete requests:      50000
Failed requests:        0                Failed requests:        0
Write errors:           0                Write errors:           0
Keep-Alive requests:    0                Keep-Alive requests:    49573
Total transferred:      8450000 bytes    Total transferred:      12931199 bytes
HTML transferred:       550000 bytes     HTML transferred:       550000 bytes
Requests per second:    1776.66          Requests per second:    2717.69
[#/sec] (mean)                           [#/sec] (mean)
Time per request:       56.285 [ms]      Time per request:       36.796 [ms]
(mean)                                   (mean)
Time per request:       0.563 [ms]       Time per request:       0.368 [ms]
(mean, across all concurrent requests)   (mean, across all concurrent requests)
Transfer rate:          293.22           Transfer rate:          686.39
[Kbytes/sec] received                    [Kbytes/sec] received


Load average: 13.70, 3.54, 1.20          Load average: 38.49, 10.07, 3.41
PHP Hello world benchmarks
        Ab -k -n 50000 -c 1000 http://10.0.0.3/test.php




Concurrency Level:      1000             Completed 5000 requests
Time taken for tests:   64.339 seconds   Completed 10000 requests
Complete requests:      50000            Completed 15000 requests
Failed requests:        474              apr_socket_recv: Connection reset by
   (Connect: 0, Receive: 0, Length:      peer (104)
474, Exceptions: 0)                      Total of 17522 requests completed
Write errors:           0
Non-2xx responses:      474
Total transferred:      8522996 bytes
HTML transferred:       626314 bytes
Requests per second:    777.13 [#/sec]
(mean)
Time per request:       1286.778 [ms]
(mean)
Time per request:       1.287 [ms]
(mean, across all concurrent requests)
Transfer rate:          129.37
[Kbytes/sec] received

Load average: 20.50, 7.13, 2.64          Load average: 36.86, 9.02, 3.03
Static HTML benchmarks
        ab -n 50000 -c 10 http://10.0.0.3/test.html




Concurrency Level:      10               Concurrency Level:      10
Time taken for tests:   14.023 seconds   Time taken for tests:   11.887 seconds
Complete requests:      50000            Complete requests:      50000
Failed requests:        0                Failed requests:        0
Write errors:           0                Write errors:           0
Total transferred:      10650000 bytes   Total transferred:      13950000 bytes
HTML transferred:       250000 bytes     HTML transferred:       250000 bytes
Requests per second:    3565.47          Requests per second:    4206.43
[#/sec] (mean)                           [#/sec] (mean)
Time per request:       2.805 [ms]       Time per request:       2.377 [ms]
(mean)                                   (mean)
Time per request:       0.280 [ms]       Time per request:       0.238 [ms]
(mean, across all concurrent requests)   (mean, across all concurrent requests)
Transfer rate:          741.65           Transfer rate:          1146.09
[Kbytes/sec] received                    [Kbytes/sec] received
Static HTML benchmarks
        ab -n 50000 -c 100 http://10.0.0.3/test.html




Concurrency Level:      100              Concurrency Level:      100
Time taken for tests:   12.785 seconds   Time taken for tests:   11.875 seconds
Complete requests:      50000            Complete requests:      50000
Failed requests:        0                Failed requests:        0
Write errors:           0                Write errors:           0
Total transferred:      10650000 bytes   Total transferred:      13950000 bytes
HTML transferred:       250000 bytes     HTML transferred:       250000 bytes
Requests per second:    3910.97          Requests per second:    4210.42
[#/sec] (mean)                           [#/sec] (mean)
Time per request:       25.569 [ms]      Time per request:       23.751 [ms]
(mean)                                   (mean)
Time per request:       0.256 [ms]       Time per request:       0.238 [ms]
(mean, across all concurrent requests)   (mean, across all concurrent requests)
Transfer rate:          813.51           Transfer rate:          1147.17
[Kbytes/sec] received                    [Kbytes/sec] received
Static HTML benchmarks
        ab -n 50000 -c 100 http://10.0.0.3/test.html




Concurrency Level:      100              Concurrency Level:      100
Time taken for tests:   12.785 seconds   Time taken for tests:   11.875 seconds
Complete requests:      50000            Complete requests:      50000
Failed requests:        0                Failed requests:        0
Write errors:           0                Write errors:           0
Total transferred:      10650000 bytes   Total transferred:      13950000 bytes
HTML transferred:       250000 bytes     HTML transferred:       250000 bytes
Requests per second:    3910.97          Requests per second:    4210.42
[#/sec] (mean)                           [#/sec] (mean)
Time per request:       25.569 [ms]      Time per request:       23.751 [ms]
(mean)                                   (mean)
Time per request:       0.256 [ms]       Time per request:       0.238 [ms]
(mean, across all concurrent requests)   (mean, across all concurrent requests)
Transfer rate:          813.51           Transfer rate:          1147.17
[Kbytes/sec] received                    [Kbytes/sec] received
Static HTML benchmarks
        ab -n 10000 -c 1000 http://10.0.0.3/test.html




Concurrency Level:      1000             Completed 1000 requests
Time taken for tests:   4.915 seconds    Completed 2000 requests
Complete requests:      10000            Completed 3000 requests
Failed requests:        0                Completed 4000 requests
Write errors:           0                Completed 5000 requests
Total transferred:      2130000 bytes    Completed 6000 requests
HTML transferred:       50000 bytes      Completed 7000 requests
Requests per second:    2034.45          Completed 8000 requests
[#/sec] (mean)                           Completed 9000 requests
Time per request:       491.533 [ms]     apr_socket_recv: Connection reset by
(mean)                                   peer (104)
Time per request:       0.492 [ms]       Total of 9561 requests completed
(mean, across all concurrent requests)
Transfer rate:          423.18
[Kbytes/sec] received
M→N
from MySQL to NoSQL
NoSQL?
●   SQL, tables, relations, JOINS...

●   Just documents, graphs, key-value pairs.

●   Really useful when working with a huge quantity of data

●   Really useful when working with data that you want not staticly
    structured


●   Really useful for statistical or real-time analyses for growing list
    of elements
My NoSql choice: MongoDB
●    Data in MongoDB is stored in JSON-like documents

●    horizontal scalability, auto-sharding to distribute data across many
     nodes (auto balancing, easy scaling)

●    full consistency and transactional updates

●    Data integrity is guaranteed through journalling and replication

●    Supported by Doctrine2 through Mongo

●    Warning: not fully ACID* compliant (missing some transactional use
     cases)


    * atomicity, consistency, isolation, durability
P→P
from mod_Php to PHP-FPM
Apache with modphp works
               but...
●   Every apache forked process is fat with all its modules
    loaded, though before-fork code is shared among processes

●   PHP is part of the apache process itself

●   You have to load PHP even when you serve static files
    (server memory footprint)

●   You have to rely on a unique PHP version for all you apps
...we can do better: FastCGI PHP
●   Multiple versions of PHP, each executed by a different user

●   Reduces the memory footprint of your web server for static
    files

●   PHP can be executed on a separate machine
We can do even better! PHP-
               FPM
●   FastCGI Process Manager
●   PHP daemonization
    pid file, log file, setsid(), setuid(), setgid(), chroot()
●   Adaptive process spawning
    Dynamic number of processes, depending on the load
●   Worker level configuration
    uid/gid/chroot/environment and different php.ini for each worker
●   Logging stdout and stderr
●   Forcing the completion of process if set_time_limit() fails
Workers, Daemons, WTF?
●   At startup a configurable number of workers ar launched,
    waiting for requests

●   Once requests arrive if needed workers are spawned

●   Each worker serves a request

●   You can fine tune the behaviour to adapt it to your machine
Wanna try?
 Let's get our hands dirty
Hot to install Nginx + PHP-FPM on
                    Ubuntu
●   Version 1.1.19 of nginx is included in the standard ubuntu
    12.04 repo
●   Unofficial PPA for current stable and development versions




sudo add-apt-repository ppa:nginx/stable

sudo apt-get update

sudo apt-get install nginx

sudo apt-get install php5-fpm php5-cgi
A simple nginx host
                 configuration
#/etc/nginx/sites-available/default

server {
  listen          80;
  server_name     localhost;
  index           index.php;
  root            /var/www;
  location ~* .php$ {
     #prevent cgi.fix_pathinfo=1 security hole
    if (!-f $request_filename) {
      return 404;
    }
    fastcgi_pass 127.0.0.1:9000;
    include      fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SERVER_NAME $host;
  }
}
Installing MongoDB
●   Available through the standard Ubuntu repo
●   10gen repositories have fresher stable versions

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

#add to /etc/apt/sources.list
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

sudo apt-get update

sudo apt-get install mongodb-10gen

sudo apt-get install php5-mongo



●   Mongo is the 10gen-supported PHP driver for MongoDB
●   Missing phpMyAdmin? Try phpMoAdmin :-)
Using Mongo: a simple example




Source: http://www.php.net/manual/en/mongo.tutorial.php
Useful links
Nginx:
http://wiki.nginx.org/

Apache vs Nginx – deathmatch
http://www.discusswire.com/apache-vs-nginx-deathmatch/

PHP-FPM
http://php-fpm.org/about/#why

http://www.if-not-true-then-false.com/2011/nginx-and-php-fpm-configuration-and-optimizing-tips-and-tricks/

MongoDB
http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages

PhpMoAdmin
http://www.phpmoadmin.com/

Mongo
http://php.net/manual/en/book.mongo.php

Contenu connexe

Tendances

Low latency for high throughput
Low latency for high throughputLow latency for high throughput
Low latency for high throughputPeter Lawrey
 
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016Zabbix
 
Full Stack Load Testing
Full Stack Load Testing Full Stack Load Testing
Full Stack Load Testing Terral R Jordan
 
Advanced off heap ipc
Advanced off heap ipcAdvanced off heap ipc
Advanced off heap ipcPeter Lawrey
 
An Introduction to Twisted
An Introduction to TwistedAn Introduction to Twisted
An Introduction to Twistedsdsern
 
Low level java programming
Low level java programmingLow level java programming
Low level java programmingPeter Lawrey
 
Primeiros Passos na API do Zabbix com Python - 2º ZABBIX MEETUP DO INTERIOR-SP
Primeiros Passos na API do Zabbix com Python - 2º ZABBIX MEETUP DO INTERIOR-SPPrimeiros Passos na API do Zabbix com Python - 2º ZABBIX MEETUP DO INTERIOR-SP
Primeiros Passos na API do Zabbix com Python - 2º ZABBIX MEETUP DO INTERIOR-SPZabbix BR
 
Open HFT libraries in @Java
Open HFT libraries in @JavaOpen HFT libraries in @Java
Open HFT libraries in @JavaPeter Lawrey
 
PyGotham 2014 Introduction to Profiling
PyGotham 2014 Introduction to ProfilingPyGotham 2014 Introduction to Profiling
PyGotham 2014 Introduction to ProfilingPerrin Harkins
 
Высокопроизводительный инференс глубоких сетей на GPU с помощью TensorRT / Ма...
Высокопроизводительный инференс глубоких сетей на GPU с помощью TensorRT / Ма...Высокопроизводительный инференс глубоких сетей на GPU с помощью TensorRT / Ма...
Высокопроизводительный инференс глубоких сетей на GPU с помощью TensorRT / Ма...Ontico
 
초보자를 위한 분산 캐시 이야기
초보자를 위한 분산 캐시 이야기초보자를 위한 분산 캐시 이야기
초보자를 위한 분산 캐시 이야기OnGameServer
 
GC free coding in @Java presented @Geecon
GC free coding in @Java presented @GeeconGC free coding in @Java presented @Geecon
GC free coding in @Java presented @GeeconPeter Lawrey
 
Preview of Apache Pulsar 2.5.0
Preview of Apache Pulsar 2.5.0Preview of Apache Pulsar 2.5.0
Preview of Apache Pulsar 2.5.0StreamNative
 
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...Ontico
 
GopherFest 2017 - Adding Context to NATS
GopherFest 2017 -  Adding Context to NATSGopherFest 2017 -  Adding Context to NATS
GopherFest 2017 - Adding Context to NATSwallyqs
 
Troubleshooting redis
Troubleshooting redisTroubleshooting redis
Troubleshooting redisDaeMyung Kang
 
Responding rapidly when you have 100+ GB data sets in Java
Responding rapidly when you have 100+ GB data sets in JavaResponding rapidly when you have 100+ GB data sets in Java
Responding rapidly when you have 100+ GB data sets in JavaPeter Lawrey
 
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015Fastly
 

Tendances (20)

Low latency for high throughput
Low latency for high throughputLow latency for high throughput
Low latency for high throughput
 
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
 
Full Stack Load Testing
Full Stack Load Testing Full Stack Load Testing
Full Stack Load Testing
 
DNS Delegation
DNS DelegationDNS Delegation
DNS Delegation
 
Advanced off heap ipc
Advanced off heap ipcAdvanced off heap ipc
Advanced off heap ipc
 
An Introduction to Twisted
An Introduction to TwistedAn Introduction to Twisted
An Introduction to Twisted
 
Low level java programming
Low level java programmingLow level java programming
Low level java programming
 
Primeiros Passos na API do Zabbix com Python - 2º ZABBIX MEETUP DO INTERIOR-SP
Primeiros Passos na API do Zabbix com Python - 2º ZABBIX MEETUP DO INTERIOR-SPPrimeiros Passos na API do Zabbix com Python - 2º ZABBIX MEETUP DO INTERIOR-SP
Primeiros Passos na API do Zabbix com Python - 2º ZABBIX MEETUP DO INTERIOR-SP
 
Open HFT libraries in @Java
Open HFT libraries in @JavaOpen HFT libraries in @Java
Open HFT libraries in @Java
 
PyGotham 2014 Introduction to Profiling
PyGotham 2014 Introduction to ProfilingPyGotham 2014 Introduction to Profiling
PyGotham 2014 Introduction to Profiling
 
Высокопроизводительный инференс глубоких сетей на GPU с помощью TensorRT / Ма...
Высокопроизводительный инференс глубоких сетей на GPU с помощью TensorRT / Ма...Высокопроизводительный инференс глубоких сетей на GPU с помощью TensorRT / Ма...
Высокопроизводительный инференс глубоких сетей на GPU с помощью TensorRT / Ма...
 
초보자를 위한 분산 캐시 이야기
초보자를 위한 분산 캐시 이야기초보자를 위한 분산 캐시 이야기
초보자를 위한 분산 캐시 이야기
 
GC free coding in @Java presented @Geecon
GC free coding in @Java presented @GeeconGC free coding in @Java presented @Geecon
GC free coding in @Java presented @Geecon
 
Preview of Apache Pulsar 2.5.0
Preview of Apache Pulsar 2.5.0Preview of Apache Pulsar 2.5.0
Preview of Apache Pulsar 2.5.0
 
How we use Twisted in Launchpad
How we use Twisted in LaunchpadHow we use Twisted in Launchpad
How we use Twisted in Launchpad
 
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
 
GopherFest 2017 - Adding Context to NATS
GopherFest 2017 -  Adding Context to NATSGopherFest 2017 -  Adding Context to NATS
GopherFest 2017 - Adding Context to NATS
 
Troubleshooting redis
Troubleshooting redisTroubleshooting redis
Troubleshooting redis
 
Responding rapidly when you have 100+ GB data sets in Java
Responding rapidly when you have 100+ GB data sets in JavaResponding rapidly when you have 100+ GB data sets in Java
Responding rapidly when you have 100+ GB data sets in Java
 
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
 

En vedette

mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较Ji ZHANG
 
Word press on conoha このべん #3
Word press on conoha このべん #3Word press on conoha このべん #3
Word press on conoha このべん #3Wataru 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 OSCloudLinux
 
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 infrastructuremkherlakian
 
Techtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPMTechtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPMWebscale
 
PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春Ryo Tomidokoro
 
PHP Files: An Introduction
PHP Files: An IntroductionPHP Files: An Introduction
PHP Files: An IntroductionJacques 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 CLIJacques Woodcock
 
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 DockerYosh de Vos
 
How to deploy PHP projects with docker
How to deploy PHP projects with dockerHow to deploy PHP projects with docker
How to deploy PHP projects with dockerRuoshi Ling
 

En vedette (18)

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
 
Word press on conoha このべん #3
Word press on conoha このべん #3Word press on conoha このべん #3
Word press on conoha このべん #3
 
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
 
Techtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPMTechtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPM
 
PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春
 
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
 
How to deploy PHP projects with docker
How to deploy PHP projects with dockerHow to deploy PHP projects with docker
How to deploy PHP projects with docker
 
How Flipkart scales PHP
How Flipkart scales PHPHow Flipkart scales PHP
How Flipkart scales PHP
 

Similaire à From LAMP to LNNP

Dicas e truques de otimização de websites python
Dicas e truques de otimização de websites pythonDicas e truques de otimização de websites python
Dicas e truques de otimização de websites pythonFabiano Weimar
 
Nginx وب سروری برای تمام فصول
Nginx وب سروری برای تمام فصولNginx وب سروری برای تمام فصول
Nginx وب سروری برای تمام فصولefazati
 
Node.js Performance Case Study
Node.js Performance Case StudyNode.js Performance Case Study
Node.js Performance Case StudyFabian Frank
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsMarcus Frödin
 
Tuning the Kernel for Varnish Cache
Tuning the Kernel for Varnish CacheTuning the Kernel for Varnish Cache
Tuning the Kernel for Varnish CachePer Buer
 
Scylla Summit 2018: Scylla Feature Talks - Scylla Streaming and Repair Updates
Scylla Summit 2018: Scylla Feature Talks - Scylla Streaming and Repair UpdatesScylla Summit 2018: Scylla Feature Talks - Scylla Streaming and Repair Updates
Scylla Summit 2018: Scylla Feature Talks - Scylla Streaming and Repair UpdatesScyllaDB
 
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 ToolboxWebCamp
 
On the way to low latency (2nd edition)
On the way to low latency (2nd edition)On the way to low latency (2nd edition)
On the way to low latency (2nd edition)Artem Orobets
 
Donatas Mažionis, Building low latency web APIs
Donatas Mažionis, Building low latency web APIsDonatas Mažionis, Building low latency web APIs
Donatas Mažionis, Building low latency web APIsTanya Denisyuk
 
Acsug scalable windows azure patterns
Acsug scalable windows azure patternsAcsug scalable windows azure patterns
Acsug scalable windows azure patternsNikolai Blackie
 
Much Faster Networking
Much Faster NetworkingMuch Faster Networking
Much Faster NetworkingC4Media
 
Highly concurrent yet natural programming
Highly concurrent yet natural programmingHighly concurrent yet natural programming
Highly concurrent yet natural programmingInfinit
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceArjan
 
Asynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAsynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAlex Thissen
 
High Frequency Trading and NoSQL database
High Frequency Trading and NoSQL databaseHigh Frequency Trading and NoSQL database
High Frequency Trading and NoSQL databasePeter Lawrey
 

Similaire à From LAMP to LNNP (20)

Dicas e truques de otimização de websites python
Dicas e truques de otimização de websites pythonDicas e truques de otimização de websites python
Dicas e truques de otimização de websites python
 
Nginx وب سروری برای تمام فصول
Nginx وب سروری برای تمام فصولNginx وب سروری برای تمام فصول
Nginx وب سروری برای تمام فصول
 
Node.js Performance Case Study
Node.js Performance Case StudyNode.js Performance Case Study
Node.js Performance Case Study
 
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
 
Tuning the Kernel for Varnish Cache
Tuning the Kernel for Varnish CacheTuning the Kernel for Varnish Cache
Tuning the Kernel for Varnish Cache
 
Scylla Summit 2018: Scylla Feature Talks - Scylla Streaming and Repair Updates
Scylla Summit 2018: Scylla Feature Talks - Scylla Streaming and Repair UpdatesScylla Summit 2018: Scylla Feature Talks - Scylla Streaming and Repair Updates
Scylla Summit 2018: Scylla Feature Talks - Scylla Streaming and Repair Updates
 
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
 
Yet another node vs php
Yet another node vs phpYet another node vs php
Yet another node vs php
 
On the way to low latency (2nd edition)
On the way to low latency (2nd edition)On the way to low latency (2nd edition)
On the way to low latency (2nd edition)
 
Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)
 
Nginx
NginxNginx
Nginx
 
AWS Lambda Deep Dive
AWS Lambda Deep DiveAWS Lambda Deep Dive
AWS Lambda Deep Dive
 
Donatas Mažionis, Building low latency web APIs
Donatas Mažionis, Building low latency web APIsDonatas Mažionis, Building low latency web APIs
Donatas Mažionis, Building low latency web APIs
 
Acsug scalable windows azure patterns
Acsug scalable windows azure patternsAcsug scalable windows azure patterns
Acsug scalable windows azure patterns
 
Much Faster Networking
Much Faster NetworkingMuch Faster Networking
Much Faster Networking
 
WebSockets in JEE 7
WebSockets in JEE 7WebSockets in JEE 7
WebSockets in JEE 7
 
Highly concurrent yet natural programming
Highly concurrent yet natural programmingHighly concurrent yet natural programming
Highly concurrent yet natural programming
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & Performance
 
Asynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAsynchronous programming in ASP.NET
Asynchronous programming in ASP.NET
 
High Frequency Trading and NoSQL database
High Frequency Trading and NoSQL databaseHigh Frequency Trading and NoSQL database
High Frequency Trading and NoSQL database
 

Plus de Giorgio Cefaro

Alexa, AWS lambda & wikidata (ITA)
Alexa, AWS lambda & wikidata (ITA)Alexa, AWS lambda & wikidata (ITA)
Alexa, AWS lambda & wikidata (ITA)Giorgio Cefaro
 
PHP object calisthenics
PHP object calisthenicsPHP object calisthenics
PHP object calisthenicsGiorgio Cefaro
 
Import golang; struct microservice - Codemotion Rome 2015
Import golang; struct microservice - Codemotion Rome 2015Import golang; struct microservice - Codemotion Rome 2015
Import golang; struct microservice - Codemotion Rome 2015Giorgio Cefaro
 
I came, I saw, I GO! - Golangit meetup @ Codemotion Rome 2014
I came, I saw, I GO! - Golangit meetup @ Codemotion Rome 2014I came, I saw, I GO! - Golangit meetup @ Codemotion Rome 2014
I came, I saw, I GO! - Golangit meetup @ Codemotion Rome 2014Giorgio Cefaro
 
Nanos gigantium humeris insidentes (design patterns inside symfony 2)
Nanos gigantium humeris insidentes (design patterns inside symfony 2)Nanos gigantium humeris insidentes (design patterns inside symfony 2)
Nanos gigantium humeris insidentes (design patterns inside symfony 2)Giorgio Cefaro
 
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridGiorgio Cefaro
 
High Performance Web Apps con PHP e Symfony 2
High Performance Web Apps con PHP  e Symfony 2High Performance Web Apps con PHP  e Symfony 2
High Performance Web Apps con PHP e Symfony 2Giorgio Cefaro
 
An introduction to Symfony 2 for symfony 1 developers
An introduction to Symfony 2 for symfony 1 developersAn introduction to Symfony 2 for symfony 1 developers
An introduction to Symfony 2 for symfony 1 developersGiorgio Cefaro
 
Netbeans e Xdebug per debugging e profiling di applicazioni PHP
Netbeans e Xdebug per debugging e profiling di applicazioni PHPNetbeans e Xdebug per debugging e profiling di applicazioni PHP
Netbeans e Xdebug per debugging e profiling di applicazioni PHPGiorgio Cefaro
 

Plus de Giorgio Cefaro (11)

Alexa, AWS lambda & wikidata (ITA)
Alexa, AWS lambda & wikidata (ITA)Alexa, AWS lambda & wikidata (ITA)
Alexa, AWS lambda & wikidata (ITA)
 
PHP object calisthenics
PHP object calisthenicsPHP object calisthenics
PHP object calisthenics
 
Don't fear the rebase
Don't fear the rebaseDon't fear the rebase
Don't fear the rebase
 
jsDay 2016 recap
jsDay 2016 recapjsDay 2016 recap
jsDay 2016 recap
 
Import golang; struct microservice - Codemotion Rome 2015
Import golang; struct microservice - Codemotion Rome 2015Import golang; struct microservice - Codemotion Rome 2015
Import golang; struct microservice - Codemotion Rome 2015
 
I came, I saw, I GO! - Golangit meetup @ Codemotion Rome 2014
I came, I saw, I GO! - Golangit meetup @ Codemotion Rome 2014I came, I saw, I GO! - Golangit meetup @ Codemotion Rome 2014
I came, I saw, I GO! - Golangit meetup @ Codemotion Rome 2014
 
Nanos gigantium humeris insidentes (design patterns inside symfony 2)
Nanos gigantium humeris insidentes (design patterns inside symfony 2)Nanos gigantium humeris insidentes (design patterns inside symfony 2)
Nanos gigantium humeris insidentes (design patterns inside symfony 2)
 
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid
 
High Performance Web Apps con PHP e Symfony 2
High Performance Web Apps con PHP  e Symfony 2High Performance Web Apps con PHP  e Symfony 2
High Performance Web Apps con PHP e Symfony 2
 
An introduction to Symfony 2 for symfony 1 developers
An introduction to Symfony 2 for symfony 1 developersAn introduction to Symfony 2 for symfony 1 developers
An introduction to Symfony 2 for symfony 1 developers
 
Netbeans e Xdebug per debugging e profiling di applicazioni PHP
Netbeans e Xdebug per debugging e profiling di applicazioni PHPNetbeans e Xdebug per debugging e profiling di applicazioni PHP
Netbeans e Xdebug per debugging e profiling di applicazioni PHP
 

Dernier

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Dernier (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

From LAMP to LNNP

  • 1. From LAMP to LNNP A Transition from Linux Apache Mysql (mod_)PHP to Linux (what else?) Nginx Nosql PHP(-FPM) Giorgio Cefaro http://giorgiocefaro.com @giorrrgio
  • 5. Vs From Wikipedia: Nginx uses an asynchronous event-driven approach to handling requests which can provide more predictable performance under high loads, in contrast to the Apache HTTP server model that defaults to a threaded or process-oriented approach to handling requests
  • 6.
  • 7. PHP Hello world benchmarks Ab -k -n 50000 -c 10 http://10.0.0.3/test.php Concurrency Level: 10 Concurrency Level: 10 Time taken for tests: 31.796 seconds Time taken for tests: 18.646 seconds Complete requests: 50000 Complete requests: 50000 Failed requests: 0 Failed requests: 0 Write errors: 0 Write errors: 0 Keep-Alive requests: 0 Keep-Alive requests: 49509 Total transferred: 8450000 bytes Total transferred: 12928406 bytes HTML transferred: 550000 bytes HTML transferred: 550000 bytes Requests per second: 1572.54 Requests per second: 2681.54 [#/sec] (mean) [#/sec] (mean) Time per request: 6.359 [ms] Time per request: 3.729 [ms] (mean) (mean) Time per request: 0.636 [ms] Time per request: 0.373 [ms] (mean, across all concurrent requests) (mean, across all concurrent requests) Transfer rate: 259.53 Transfer rate: 677.11 [Kbytes/sec] received [Kbytes/sec] received Load average: 4.38, 1.29, 0.46 Load average: 3.00, 0.89, 0.32
  • 8. PHP Hello world benchmarks Ab -k -n 50000 -c 100 http://10.0.0.3/test.php Concurrency Level: 100 Concurrency Level: 100 Time taken for tests: 28.143 seconds Time taken for tests: 18.398 seconds Complete requests: 50000 Complete requests: 50000 Failed requests: 0 Failed requests: 0 Write errors: 0 Write errors: 0 Keep-Alive requests: 0 Keep-Alive requests: 49573 Total transferred: 8450000 bytes Total transferred: 12931199 bytes HTML transferred: 550000 bytes HTML transferred: 550000 bytes Requests per second: 1776.66 Requests per second: 2717.69 [#/sec] (mean) [#/sec] (mean) Time per request: 56.285 [ms] Time per request: 36.796 [ms] (mean) (mean) Time per request: 0.563 [ms] Time per request: 0.368 [ms] (mean, across all concurrent requests) (mean, across all concurrent requests) Transfer rate: 293.22 Transfer rate: 686.39 [Kbytes/sec] received [Kbytes/sec] received Load average: 13.70, 3.54, 1.20 Load average: 38.49, 10.07, 3.41
  • 9. PHP Hello world benchmarks Ab -k -n 50000 -c 1000 http://10.0.0.3/test.php Concurrency Level: 1000 Completed 5000 requests Time taken for tests: 64.339 seconds Completed 10000 requests Complete requests: 50000 Completed 15000 requests Failed requests: 474 apr_socket_recv: Connection reset by (Connect: 0, Receive: 0, Length: peer (104) 474, Exceptions: 0) Total of 17522 requests completed Write errors: 0 Non-2xx responses: 474 Total transferred: 8522996 bytes HTML transferred: 626314 bytes Requests per second: 777.13 [#/sec] (mean) Time per request: 1286.778 [ms] (mean) Time per request: 1.287 [ms] (mean, across all concurrent requests) Transfer rate: 129.37 [Kbytes/sec] received Load average: 20.50, 7.13, 2.64 Load average: 36.86, 9.02, 3.03
  • 10. Static HTML benchmarks ab -n 50000 -c 10 http://10.0.0.3/test.html Concurrency Level: 10 Concurrency Level: 10 Time taken for tests: 14.023 seconds Time taken for tests: 11.887 seconds Complete requests: 50000 Complete requests: 50000 Failed requests: 0 Failed requests: 0 Write errors: 0 Write errors: 0 Total transferred: 10650000 bytes Total transferred: 13950000 bytes HTML transferred: 250000 bytes HTML transferred: 250000 bytes Requests per second: 3565.47 Requests per second: 4206.43 [#/sec] (mean) [#/sec] (mean) Time per request: 2.805 [ms] Time per request: 2.377 [ms] (mean) (mean) Time per request: 0.280 [ms] Time per request: 0.238 [ms] (mean, across all concurrent requests) (mean, across all concurrent requests) Transfer rate: 741.65 Transfer rate: 1146.09 [Kbytes/sec] received [Kbytes/sec] received
  • 11. Static HTML benchmarks ab -n 50000 -c 100 http://10.0.0.3/test.html Concurrency Level: 100 Concurrency Level: 100 Time taken for tests: 12.785 seconds Time taken for tests: 11.875 seconds Complete requests: 50000 Complete requests: 50000 Failed requests: 0 Failed requests: 0 Write errors: 0 Write errors: 0 Total transferred: 10650000 bytes Total transferred: 13950000 bytes HTML transferred: 250000 bytes HTML transferred: 250000 bytes Requests per second: 3910.97 Requests per second: 4210.42 [#/sec] (mean) [#/sec] (mean) Time per request: 25.569 [ms] Time per request: 23.751 [ms] (mean) (mean) Time per request: 0.256 [ms] Time per request: 0.238 [ms] (mean, across all concurrent requests) (mean, across all concurrent requests) Transfer rate: 813.51 Transfer rate: 1147.17 [Kbytes/sec] received [Kbytes/sec] received
  • 12. Static HTML benchmarks ab -n 50000 -c 100 http://10.0.0.3/test.html Concurrency Level: 100 Concurrency Level: 100 Time taken for tests: 12.785 seconds Time taken for tests: 11.875 seconds Complete requests: 50000 Complete requests: 50000 Failed requests: 0 Failed requests: 0 Write errors: 0 Write errors: 0 Total transferred: 10650000 bytes Total transferred: 13950000 bytes HTML transferred: 250000 bytes HTML transferred: 250000 bytes Requests per second: 3910.97 Requests per second: 4210.42 [#/sec] (mean) [#/sec] (mean) Time per request: 25.569 [ms] Time per request: 23.751 [ms] (mean) (mean) Time per request: 0.256 [ms] Time per request: 0.238 [ms] (mean, across all concurrent requests) (mean, across all concurrent requests) Transfer rate: 813.51 Transfer rate: 1147.17 [Kbytes/sec] received [Kbytes/sec] received
  • 13. Static HTML benchmarks ab -n 10000 -c 1000 http://10.0.0.3/test.html Concurrency Level: 1000 Completed 1000 requests Time taken for tests: 4.915 seconds Completed 2000 requests Complete requests: 10000 Completed 3000 requests Failed requests: 0 Completed 4000 requests Write errors: 0 Completed 5000 requests Total transferred: 2130000 bytes Completed 6000 requests HTML transferred: 50000 bytes Completed 7000 requests Requests per second: 2034.45 Completed 8000 requests [#/sec] (mean) Completed 9000 requests Time per request: 491.533 [ms] apr_socket_recv: Connection reset by (mean) peer (104) Time per request: 0.492 [ms] Total of 9561 requests completed (mean, across all concurrent requests) Transfer rate: 423.18 [Kbytes/sec] received
  • 14.
  • 16. NoSQL? ● SQL, tables, relations, JOINS... ● Just documents, graphs, key-value pairs. ● Really useful when working with a huge quantity of data ● Really useful when working with data that you want not staticly structured ● Really useful for statistical or real-time analyses for growing list of elements
  • 17. My NoSql choice: MongoDB ● Data in MongoDB is stored in JSON-like documents ● horizontal scalability, auto-sharding to distribute data across many nodes (auto balancing, easy scaling) ● full consistency and transactional updates ● Data integrity is guaranteed through journalling and replication ● Supported by Doctrine2 through Mongo ● Warning: not fully ACID* compliant (missing some transactional use cases) * atomicity, consistency, isolation, durability
  • 19. Apache with modphp works but... ● Every apache forked process is fat with all its modules loaded, though before-fork code is shared among processes ● PHP is part of the apache process itself ● You have to load PHP even when you serve static files (server memory footprint) ● You have to rely on a unique PHP version for all you apps
  • 20. ...we can do better: FastCGI PHP ● Multiple versions of PHP, each executed by a different user ● Reduces the memory footprint of your web server for static files ● PHP can be executed on a separate machine
  • 21. We can do even better! PHP- FPM ● FastCGI Process Manager ● PHP daemonization pid file, log file, setsid(), setuid(), setgid(), chroot() ● Adaptive process spawning Dynamic number of processes, depending on the load ● Worker level configuration uid/gid/chroot/environment and different php.ini for each worker ● Logging stdout and stderr ● Forcing the completion of process if set_time_limit() fails
  • 22. Workers, Daemons, WTF? ● At startup a configurable number of workers ar launched, waiting for requests ● Once requests arrive if needed workers are spawned ● Each worker serves a request ● You can fine tune the behaviour to adapt it to your machine
  • 23. Wanna try? Let's get our hands dirty
  • 24. Hot to install Nginx + PHP-FPM on Ubuntu ● Version 1.1.19 of nginx is included in the standard ubuntu 12.04 repo ● Unofficial PPA for current stable and development versions sudo add-apt-repository ppa:nginx/stable sudo apt-get update sudo apt-get install nginx sudo apt-get install php5-fpm php5-cgi
  • 25. A simple nginx host configuration #/etc/nginx/sites-available/default server { listen 80; server_name localhost; index index.php; root /var/www; location ~* .php$ { #prevent cgi.fix_pathinfo=1 security hole if (!-f $request_filename) { return 404; } fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SERVER_NAME $host; } }
  • 26. Installing MongoDB ● Available through the standard Ubuntu repo ● 10gen repositories have fresher stable versions sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 #add to /etc/apt/sources.list deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen sudo apt-get update sudo apt-get install mongodb-10gen sudo apt-get install php5-mongo ● Mongo is the 10gen-supported PHP driver for MongoDB ● Missing phpMyAdmin? Try phpMoAdmin :-)
  • 27. Using Mongo: a simple example Source: http://www.php.net/manual/en/mongo.tutorial.php
  • 28. Useful links Nginx: http://wiki.nginx.org/ Apache vs Nginx – deathmatch http://www.discusswire.com/apache-vs-nginx-deathmatch/ PHP-FPM http://php-fpm.org/about/#why http://www.if-not-true-then-false.com/2011/nginx-and-php-fpm-configuration-and-optimizing-tips-and-tricks/ MongoDB http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages PhpMoAdmin http://www.phpmoadmin.com/ Mongo http://php.net/manual/en/book.mongo.php