me
Published on

Laravel octane roadrunner benchmark

Authors
  • avatar
    Name
    Omer ATAGUN
    Twitter

Previously i have explained the reason of using kubernetes clusters. While all the work going on, with my spared time i got myself into testing PHP-FPM and Octane with roadrunner(GO one)

Problem ?

  • I have 6 VPS servers 1 as control plane/etcd and 5 worker nodes in k3s/rancher cluster. I have prepared a new version of eDominations into my DockerFile. Surely started with PHP-FPM as like all other standart php servers. Image has been built, pushed to dockerhub private repository. Using MariaDB and Redis deployment in the cluster, all config assigned now time to run some Apache benchmark tests.

    Layer 4 load balancer with 5 node Laravel deployment ( 5 instances of PHP server has an access to redis server inside the cluster read/write permissions)

Laravel with PHP-FPM

ab -n 1000 -c 250 -k -H "Accept-encoding: gzip, deflate" -rk https://xxx.xxx.com/api/toparticles

 Document Path:          /api/toparticles/
 Document Length:        884 bytes

 Concurrency Level:      250
 Time taken for tests:   34.705 seconds
 Complete requests:      1000
 Failed requests:        457
 (Connect: 0, Receive: 0, Length: 457, Exceptions: 0)
 Non-2xx responses:      457
 Keep-Alive requests:    0
 Total transferred:      4345222 bytes
 HTML transferred:       4026812 bytes
 Requests per second:    28.81 [#/sec] (mean)
 Time per request:       8676.225 [ms] (mean)
 Time per request:       34.705 [ms] (mean, across all concurrent requests)
 Transfer rate:          122.27 [Kbytes/sec] received

  • When this api endpoint called, Laravel with PHP-fpm instance connects to redis-server inside our cluster ( private network so latency is minimal as possible ). As you can see we were able to response 28.81 Requests per second.

This was a bit of disappointment for me. I have started thinking that even if all the nodes are in same datacenter location ( 0.05 ms latency ) cluster somehow kills the entire performance but then i have decided to change the approach. Hence, the problem has been created :)

Different approach!

  • We just said we need to work onto something different. I have not used Laravel's octane in production but since i am building new version of eDominations, why not? i am brave enough to experiment things while thinking any aspect that could go wrong. I found myself building docker image for octane.

Consider that each VPS server of mine has shared 4vCPu 8GB ram and 50GB nvme. It was the same when we were testing with PHP-FPM

Quick look to Octane

  • Once i figured the requirements, rest was to build docker images and see if all going great. Same servers, same cluster, same docker image with additional installations in it. Then the results were amazing. In a way that you would never want to go back using FPM.

Laravel-Octane with Roadrunner

ab -n 1000 -c 250 -k -H "Accept-encoding: gzip, deflate" -rk https://xxx.xxx.com/api/toparticles

Document Path:          /api/toparticles
Document Length:        884 bytes

Concurrency Level:      250
Time taken for tests:   4.159 seconds
Complete requests:      1000
Failed requests:        638
   (Connect: 0, Receive: 0, Length: 638, Exceptions: 0)
Non-2xx responses:      638
Keep-Alive requests:    362
Total transferred:      4857397 bytes
HTML transferred:       4546758 bytes
Requests per second:    240.46 [#/sec] (mean)
Time per request:       1039.667 [ms] (mean)
Time per request:       4.159 [ms] (mean, across all concurrent requests)
Transfer rate:          1140.64 [Kbytes/sec] received

Almost 10x times. We are friends here call it 10 times.

Things to consider

Due to its nature, octane with roadrunner spawns workers based on the cpu cores you have available. You can increase or decrease these with the configuration. If your application did not concerned potential memory leaks, you have option to respawn processes after given amount of requests they serve. This explicitly makes your application to adapt easier to this change.

Until the next post, stay hydrated!