Installing Roadrunner in laravel octane

Time:2021-9-26

stayLastWe didSwoolestayLaravelThis article will explain the installation and use ofRoadRunnerInstallation and use of.

installRoadRunnerAnd installationSwooleSimilar, the only difference isRoadRunnerNo installation requiredphpExtension of.

Environmental requirements

  1. PHP 8.0+
  2. Larave 8.35+
  3. SwooleandRoadRunnerMust beunixInstallation under the system (MacOS, Linux, window (wsl2))
  4. RoadRunner: please make surecurlzip socketsetc.phpExtension already installed
  5. Virtual machine IP:192.168.2.11

Step1. Installationoctanepackage

composer require laravel/octane

Step 2. Configure nginx agent

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen 8009;            #  Port accessed by browser
    #listen [::]:80;
    server_name 127.0.0.1;
    server_tokens off;
    root /var/www/html/octane/public;

    index index.php;

    charset utf-8;

    location /index.php {
        try_files /not_exists @octane;
    }

    location / {
        try_files $uri $uri/ @octane;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log /var/log/nginx/octane-access.log main;
    error_log  /var/log/nginx/octane-error.log error;

    error_page 404 /index.php;

    location @octane {
        set $suffix "";

        if ($uri = /index.php) {
            set $suffix ?$query_string;
        }

        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header Scheme $scheme;
        proxy_set_header SERVER_PORT $server_port;
        proxy_set_header REMOTE_ADDR $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

        proxy_ pass  http://127.0.0.1:8010 $suffix;            #  Proxy request
    }
}

proxy_passexpresshttp://127.0.0.1:8010Proxy forwarding fromhttp://192.168.2.110:8009Request for

Step3. UseRoadRunner

1. Installationspiral/roadrunner
#Different versions may behave differently. Try to use the latest version
composer require spiral/roadrunner:v2.4.0
2. Publish profile
php artisan octane:install

Output:

 Which application server you would like to use?:
  [0] roadrunner
  [1] swoole
 > 0

Selecting 0 means that we have selectedRoadRunner

3. Get binary files
./vendor/bin/rr get-binary    
4. Operation
php artisan octane:start --server=roadrunner --port=8010

Output:

  INFO  Server running…

  Local: http://127.0.0.1:8010 

  Press Ctrl+C to stop the server

See here, it indicates that the installation is successful.

5. Access in browser

Enter in the browserhttp://192.168.2.11:8009And enter. You can see that a get request will appear on the command interface.
Installing Roadrunner in laravel octane

You can see that only the first two requests take a long time, and the subsequent requests take only a few milliseconds

Step4. AB pressure measurement

FollowSwooleLike the pressure measurement of, the pressure measurement command:

ab -n 1000 -c 8 http://127.0.0.1:8010/  
  • -n 1000: Specifies that the number of requests used by the test session is 1000
  • -c 8: the number of concurrent is 8

useoctanePressure test results

[[email protected] octane]# ab -n 1000 -c 8 http://127.0.0.1:8010/test-mysql
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        
Server Hostname:        127.0.0.1
Server Port:            8010

Document Path:          /test-mysql
Document Length:        0 bytes

Concurrency Level:      8
Time taken for tests:   22.446 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1048000 bytes
HTML transferred:       0 bytes
Requests per second:    44.55 [#/sec] (mean)
Time per request:       179.566 [ms] (mean)
Time per request:       22.446 [ms] (mean, across all concurrent requests)
Transfer rate:          45.60 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:     9  178  43.9    180     360
Waiting:        9  178  43.9    180     360
Total:          9  178  43.9    180     360

Percentage of the requests served within a certain time (ms)
  50%    180
  66%    194
  75%    213
  80%    221
  90%    234
  95%    242
  98%    250
  99%    255
 100%    360 (longest request)

**Let’s see if we don’t use itoctanePressure test results:

[[email protected] octane]# ab -n 1000 -c 8 http://127.0.0.1:8008/test-mysql
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        nginx/1.20.1
Server Hostname:        127.0.0.1
Server Port:            8008

Document Path:          /test-mysql
Document Length:        0 bytes

Concurrency Level:      8
Time taken for tests:   52.588 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1134000 bytes
HTML transferred:       0 bytes
Requests per second:    19.02 [#/sec] (mean)
Time per request:       420.705 [ms] (mean)
Time per request:       52.588 [ms] (mean, across all concurrent requests)
Transfer rate:          21.06 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:    78  419 172.2    396     986
Waiting:       78  419 172.2    396     986
Total:         78  419 172.2    396     986

Percentage of the requests served within a certain time (ms)
  50%    396
  66%    510
  75%    568
  80%    591
  90%    655
  95%    706
  98%    740
  99%    761
 100%    986 (longest request)

As can be seen from the above two results,RoadRunnerIt can also greatly improve the speed.

Recommended Today

Seven Python code review tools recommended

althoughPythonLanguage is one of the most flexible development languages at present, but developers often abuse its flexibility and even violate relevant standards. So PythoncodeThe following common quality problems often occur: Some unused modules have been imported Function is missing arguments in various calls The appropriate format indentation is missing Missing appropriate spaces before and after […]