Here are some comparative benchmarks of our API using PHP-FPM vs Laravel Octane (Swoole) endpoints.
Test Hardware - Setup
- Macbook Pro (15-inch, 2018) - 2.6 GHz 6-Core Intel Core i7. 32 GB 2400 Mhz
- MySQL - 8.0
- PHP - 8.0.3
- Laravel - 8.83.5
- Swoole - 4.8.11
- Wrk
PHP-FPM - Via MySQL
❯ wrk -t4 -c50 -d30s http://localhost:8080/sports/types
Running 30s test @ http://localhost:8080/sports/types
4 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 472.72ms 54.67ms 714.01ms 76.17%
Req/Sec 25.54 12.01 60.00 59.12%
3034 requests in 30.09s, 18.93MB read
Requests/sec: 100.84
Transfer/sec: 644.33KB
Octane (Swoole) - Via MySQL
❯ wrk -t4 -c50 -d30s http://localhost:8080/sports/types
Running 30s test @ http://localhost:8080/sports/types
4 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 332.01ms 76.39ms 940.20ms 78.26%
Req/Sec 36.28 15.77 101.00 62.15%
4322 requests in 30.07s, 27.04MB read
Requests/sec: 143.74
Transfer/sec: 0.90MB
Octane (Swoole) - Via Octane Cache
❯ wrk -t4 -c50 -d30s http://localhost:8080/sports/types
Running 30s test @ http://localhost:8080/sports/types
4 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 270.90ms 73.65ms 920.71ms 78.17%
Req/Sec 44.87 18.09 100.00 71.62%
5324 requests in 30.07s, 33.30MB read
Requests/sec: 177.04
Transfer/sec: 1.11MB
The conclusion of these tests is that the Swoole equivelent of the PHP-FPM API calls are considerably faster than their originals without any code level modifications. If we utilize the Octane (Swoole) caching, this becomes marginally faster.
PHP-FPM - Via MySQL
❯ wrk -t4 -c50 -d30s 'http://localhost:8080/schedules/ToEoHjaTTOXsCSpN/stats/byType?groupBy=Division'
Running 30s test @ http://localhost:8080/schedules/ToEoHjaTTOXsCSpN/stats/byType?groupBy=Division
4 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.40s 201.00ms 1.98s 85.70%
Req/Sec 10.00 5.94 40.00 68.30%
1008 requests in 30.10s, 20.77MB read
Socket errors: connect 0, read 0, write 0, timeout 1
Requests/sec: 33.49
Transfer/sec: 706.47KB
Octane(Swoole) - Via MySQL
❯ wrk -t4 -c50 -d30s 'http://localhost:8080/schedules/ToEoHjaTTOXsCSpN/stats/byType?groupBy=Division'
Running 30s test @ http://localhost:8080/schedules/ToEoHjaTTOXsCSpN/stats/byType?groupBy=Division
4 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.06s 163.25ms 1.86s 71.34%
Req/Sec 13.00 7.84 49.00 75.30%
1341 requests in 30.10s, 27.66MB read
Socket errors: connect 0, read 0, write 0, timeout 1
Requests/sec: 44.56
Transfer/sec: 0.92MB
Octane (Swoole) - Via Octane Cache
❯ wrk -t4 -c50 -d30s 'http://localhost:8080/schedules/ToEoHjaTTOXsCSpN/stats/byType?groupBy=Division'
Running 30s test @ http://localhost:8080/schedules/ToEoHjaTTOXsCSpN/stats/byType?groupBy=Division
4 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 472.91ms 91.34ms 1.31s 86.42%
Req/Sec 25.77 12.45 70.00 56.63%
3019 requests in 30.09s, 62.27MB read
Requests/sec: 100.33
Transfer/sec: 2.07MB
Octane (Swoole) - Via Octane Cache w/o Resource De-Serialization
❯ wrk -t4 -c50 -d30s 'http://localhost:8080/schedules/ToEoHjaTTOXsCSpN/stats/byType?groupBy=Division'
Running 30s test @ http://localhost:8080/schedules/ToEoHjaTTOXsCSpN/stats/byType?groupBy=Division
4 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 222.49ms 59.96ms 621.47ms 75.13%
Req/Sec 54.40 22.21 121.00 61.38%
6463 requests in 30.04s, 133.05MB read
Requests/sec: 215.12
Transfer/sec: 4.43MB