はじめに
タイトルで、「Laravel10 VS Laravel12」と言っていますがパフォーマンス向上の大きなアップデートが行われたのは実際にはLaravel11です。
とはいえ、検証するなら大型アップデート前のver10と最新のver12で比較したかった為、10 vs 12で比較する事にしております。
検証内容が不適切だった場合には都度、再試行し記事も更新します。
不備がある場合は温かいご指摘をいただけると幸いです。
検証環境
【フレームワーク】
- Laravel Framework 12.19.3
- Laravel Framework 10.48.29
【実行環境】
- Docker Desktop
- PHP 8.2 (両環境で統一)
- Nginx
- MySQL 8.0
【コンセプト】
それぞれクリーンなLaravelプロジェクトを用意し、同一のDocker構成、PHPバージョンで比較する。
負荷検証にあたって、memory_limitやrate limitの制限は解放しています。
Laravel11でのパフォーマンス向上項目(今回の検証観点)
※他にもupdateされていますが、今回の検証観点として捉えてください。
-
HTTPリクエストの受付: フレームワークの起動プロセスの速度向上
-
Eloquentの読み取り性能: Post::chunk() でデータベースから効率的にデータを読み出す性能の検証
-
PHPの計算処理: ループや文字列処理など、CPUを使った計算性能の検証
- これに関してはアップデートによる物ではなく単に検証の為、負荷をかける処理として含めています。
検証前準備
検証用DBスキーマ
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->string('title');
$table->text('body');
$table->timestamps();
});
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
データの準備
- 10000ユーザーレコードを準備
- 1ユーザーにつきpostsへ50レコード準備
- 合計50,000レコード
public function run(): void
{
User::factory(10000) // 10000ユーザーを生成
->has(Post::factory()->count(50)) // 1ユーザーあたり50投稿
->create();
}
php artisan migrate:fresh --seed
検証1: 高負荷な単一リクエストの比較
1回のリクエストで大量のデータを処理する、CPUとデータベースI/Oに負荷がかかるシナリオを比較してみます。
いずれも各ver毎に3回ずつ検証していきます。
Route::get('/posts-aggregate', function () {
ini_set('memory_limit', '-1');
$startTime = microtime(true);
$totalCharacters = 0;
$postCount = 0;
Post::chunk(200, function ($posts) use (&$totalCharacters, &$postCount) {
foreach ($posts as $post) {
$totalCharacters += strlen($post->body);
$postCount++;
}
});
$endTime = microtime(true);
$duration = ($endTime - $startTime) * 1000;
$average = ($postCount > 0) ? $totalCharacters / $postCount : 0;
return response()->json([
'total_posts_processed' => $postCount,
'average_body_length' => round($average, 2),
'duration_ms' => round($duration, 2),
]);
});
Laravel12:検証結果
準備したエンドポイントを叩いてみる
curl http://localhost:8012/api/posts-aggregate
{
# postsテーブルの総レコード数
"total_posts_processed": 500000,
# 投稿本文(body)1件あたりの平均文字数
"average_body_length": 156.8,
# 処理全体にかかった時間(ミリ秒)
"duration_ms": 116702.71,
# 処理中にPHPスクリプトが使用したメモリの最大量(メガバイト)
"peak_memory_mb": 10,
# 実行されたデータベースクエリの総数。50万件のデータを200件ずつ取得したため、500000 / 200 = 2500回のSELECTQueryが発行されたのが分かる
"query_count": 2501,
# 全クエリ(2501回)の実行にかかった合計時間(ミリ秒)
"query_duration_ms": 4744.32
}
{
"total_posts_processed": 500000,
"average_body_length": 156.8,
"duration_ms": 118228.05,
"peak_memory_mb": 4,
"query_count": 2501,
"query_duration_ms": 4968.35
}
{
"total_posts_processed": 500000,
"average_body_length": 156.8,
"duration_ms": 117315,
"peak_memory_mb": 4,
"query_count": 2501,
"query_duration_ms": 4973.58
}
Laravel10検証
今度はLaravel10で実行。
curl http://localhost:8010/api/posts-aggregate
{
"total_posts_processed": 500000,
"average_body_length": 156.86,
"duration_ms": 116685.59,
"peak_memory_mb": 10,
"query_count": 2501,
"query_duration_ms": 4789.17
}
{
"total_posts_processed": 500000,
"average_body_length": 156.86,
"duration_ms": 117418.33,
"peak_memory_mb": 4,
"query_count": 2501,
"query_duration_ms": 5083.6
}
{
"total_posts_processed": 500000,
"average_body_length": 156.86,
"duration_ms": 118640.53,
"peak_memory_mb": 4,
"query_count": 2501,
"query_duration_ms": 4975.49
}
検証1の結果
それぞれの内容を比較してみる。
Laravel-ver | 1回目 (ms) | 2回目 (ms) | 3回目 (ms) | 平均 (ms) |
---|---|---|---|---|
10 | 116,685 | 117,418 | 118,640 | 117,581 |
12 | 116,702 | 118,228 | 117,315 | 117,415 |
検証の仕方が悪かったのか、、
結果は互角。
Laravel11のパフォーマンス向上は、アプリケーションの起動(ブートストラップ)プロセスにあり、
設定ファイルやサービスプロバイダがスリム化され、リクエストごとに行われる初期化処理が大幅に高速化されている事です。
その為、1度のrequestにおいての高負荷処理では差がつきにくかったのかもしれません。
断念、、したくはなかったので次のアプローチへ。。
検証2: フレームワーク起動速度の比較(スループットテスト-html response ver)
「検証1」の重い単一処理では大きな差が見られなかったため、次にLaravel 11/12のパフォーマンス改善で最も恩恵が大きいとされるアプリケーションの起動速度に焦点を当てたテストを行います。
仮説と検証方法
Laravel 11以降、フレームワークの起動(ブートストラップ)プロセスが効率化され、リクエストごとに行われる初期化処理が高速化されたと言われています。
この差を計測するため、処理が何もないAPIを大量に呼び出し、サーバーが1秒間に何回のリクエストを捌けるか(スループット)を比較します。
(このテストでは、公平性を期すために両環境のレート制限を無効化しています)
検証用エンドポイント
routes/api.phpに、プレーンテキストを返すシンプルなエンドポイントを用意します。curlのデフォルトContent-Typeはtext/htmlとして扱われるため、これは実質的にHTMLレスポンスのプロセスをテストすることになります。
Route::get('/hello', fn() => 'Hello World');
検証では、abコマンドで「x人が同時に、合計n回アクセスする」状況をシミュレートしてみます。
Laravel12検証
シミュレート内容:50人同時接続、計1000回request
ab -n 1000 -c 50 http://localhost:8012/api/hello
This is ApacheBench, Version 2.3 <$Revision: 1913912 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (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.25.5
Server Hostname: localhost
Server Port: 8012
Document Path: /api/hello
Document Length: 11 bytes
Concurrency Level: 50
Time taken for tests: 4.117 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 278000 bytes
HTML transferred: 11000 bytes
Requests per second: 242.91 [#/sec] (mean)
Time per request: 205.834 [ms] (mean)
Time per request: 4.117 [ms] (mean, across all concurrent requests)
Transfer rate: 65.95 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 1
Processing: 36 197 25.8 196 260
Waiting: 36 197 25.8 196 260
Total: 36 197 25.8 196 261
Percentage of the requests served within a certain time (ms)
50% 196
66% 201
75% 208
80% 213
90% 231
95% 241
98% 247
99% 249
100% 261 (longest request)
Complete requests: 1000
Failed requests: 0
一度も失敗する事なく、50の同時接続、1000回のrequestに成功しています。
シミュレート内容:100人同時接続、計1000回request
ab -n 1000 -c 100 http://localhost:8012/api/hello
This is ApacheBench, Version 2.3 <$Revision: 1913912 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (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.25.5
Server Hostname: localhost
Server Port: 8012
Document Path: /api/hello
Document Length: 11 bytes
Concurrency Level: 100
Time taken for tests: 4.194 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 278000 bytes
HTML transferred: 11000 bytes
Requests per second: 238.45 [#/sec] (mean)
Time per request: 419.383 [ms] (mean)
Time per request: 4.194 [ms] (mean, across all concurrent requests)
Transfer rate: 64.73 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.5 0 2
Processing: 69 379 48.3 381 528
Waiting: 69 379 48.3 381 528
Total: 71 379 48.1 381 530
Percentage of the requests served within a certain time (ms)
50% 381
66% 393
75% 400
80% 405
90% 413
95% 423
98% 457
99% 490
100% 530 (longest request)
Complete requests: 1000
Failed requests: 0
同時接続数を100にしても安定して成功する事が確認できました。
シミュレート内容:1000人同時接続、計1000回request
ab -n 1000 -c 1000 http://localhost:8012/api/hello
This is ApacheBench, Version 2.3 <$Revision: 1913912 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (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.25.5
Server Hostname: localhost
Server Port: 8012
Document Path: /api/hello
Document Length: 11 bytes
Concurrency Level: 1000
Time taken for tests: 4.440 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 278000 bytes
HTML transferred: 11000 bytes
Requests per second: 225.23 [#/sec] (mean)
Time per request: 4439.837 [ms] (mean)
Time per request: 4.440 [ms] (mean, across all concurrent requests)
Transfer rate: 61.15 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 64 60.3 19 186
Processing: 56 2348 1119.5 2431 4238
Waiting: 36 2348 1119.5 2431 4238
Total: 56 2412 1172.6 2437 4396
Percentage of the requests served within a certain time (ms)
50% 2437
66% 3087
75% 3455
80% 3640
90% 4004
95% 4200
98% 4329
99% 4374
100% 4396 (longest request)
Complete requests: 1000
Failed requests: 0
最後に、1000の同時接続、1000回のrequestでも難なく成功する事を確認。
Laravel12での結果
シミュレート内容 | 同時接続数(c) | 失敗リクエスト | 秒間リクエスト数(RPS) |
---|---|---|---|
50人が1000回アクセス | 50 | 0件 | 242.91 |
100人が1000回アクセス | 100 | 0件 | 238.45 |
1000人が1000回アクセス | 1000 | 0件 | 225.23 |
このような結果になりました、非常に安定的かつ高性能です。
同時接続数が1000という極端に高い負荷状態でも、リクエストの失敗は0件でした。
また秒間225リクエスト以上という高いスループットを安定して維持しており、フレームワークの起動が非常に高速であることが証明されました。
Laravel10検証
次に、Laravel10で検証を進めてみます。
シミュレート内容:50人同時接続、計1000回request
ab -n 1000 -c 50 http://localhost:8010/api/hello
This is ApacheBench, Version 2.3 <$Revision: 1913912 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (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.25.5
Server Hostname: localhost
Server Port: 8010
Document Path: /api/hello
Document Length: 28103 bytes
Concurrency Level: 50
Time taken for tests: 7.198 seconds
Complete requests: 1000
Failed requests: 997
(Connect: 0, Receive: 0, Length: 997, Exceptions: 0)
Total transferred: 28392907 bytes
HTML transferred: 28081907 bytes
Requests per second: 138.93 [#/sec] (mean)
Time per request: 359.904 [ms] (mean)
Time per request: 7.198 [ms] (mean, across all concurrent requests)
Transfer rate: 3852.06 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 1
Processing: 34 347 55.9 351 545
Waiting: 34 347 56.0 351 545
Total: 35 347 55.9 351 545
Percentage of the requests served within a certain time (ms)
50% 351
66% 366
75% 379
80% 386
90% 405
95% 433
98% 458
99% 475
100% 545 (longest request)
failed requests: 997
めちゃくちゃ失敗している。
並列数を減らしてみる。
シミュレート内容:10人同時接続、計1000回request
ab -n 1000 -c 10 http://localhost:8010/api/hello
This is ApacheBench, Version 2.3 <$Revision: 1913912 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (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.25.5
Server Hostname: localhost
Server Port: 8010
Document Path: /api/hello
Document Length: 28092 bytes
Concurrency Level: 10
Time taken for tests: 8.794 seconds
Complete requests: 1000
Failed requests: 964
(Connect: 0, Receive: 0, Length: 964, Exceptions: 0)
Total transferred: 28393475 bytes
HTML transferred: 28082475 bytes
Requests per second: 113.71 [#/sec] (mean)
Time per request: 87.941 [ms] (mean)
Time per request: 8.794 [ms] (mean, across all concurrent requests)
Transfer rate: 3153.04 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 2
Processing: 29 87 43.2 67 309
Waiting: 29 87 43.2 67 308
Total: 29 87 43.2 67 309
Percentage of the requests served within a certain time (ms)
50% 67
66% 104
75% 111
80% 116
90% 149
95% 175
98% 216
99% 230
100% 309 (longest request)
さあ、どうなったか...
Failed requests: 964
ちょっと、failed数が減っている...!
レートリミットも解放し、並列数を減らしたら失敗数が減っている為、
高負荷に耐えられていないと判断してもいいんじゃないか...?
次に同時接続数を1にして試してみます。
シミュレート内容:1人接続、計100回request
ab -n 100 -c 1 http://localhost:8010/api/hello
This is ApacheBench, Version 2.3 <$Revision: 1913912 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient).....done
Server Software: nginx/1.25.5
Server Hostname: localhost
Server Port: 8010
Document Path: /api/hello
Document Length: 28099 bytes
Concurrency Level: 1
Time taken for tests: 1.569 seconds
Complete requests: 100
Failed requests: 95
(Connect: 0, Receive: 0, Length: 95, Exceptions: 0)
Total transferred: 2839319 bytes
HTML transferred: 2808219 bytes
Requests per second: 63.75 [#/sec] (mean)
Time per request: 15.685 [ms] (mean)
Time per request: 15.685 [ms] (mean, across all concurrent requests)
Transfer rate: 1767.78 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 10 16 26.6 11 211
Waiting: 10 16 26.6 11 210
Total: 10 16 26.6 11 211
Percentage of the requests served within a certain time (ms)
50% 11
66% 12
75% 12
80% 12
90% 13
95% 15
98% 187
99% 211
100% 211 (longest request)
Failed requests: 95
同時接続「1」でも、全然ダメ
htmlをresする連続request自体が基本的に耐えられていない結果となりました。
(検証内容に誤りがあれば教えてください。)
Laravel10での結果
シミュレート内容 | 同時接続数(c) | リクエスト数(n) | 失敗リクエスト | 失敗率 |
---|---|---|---|---|
50人が1000回アクセス | 50 | 1000 | 997件 | 99.7% |
10人が1000回アクセス | 10 | 1000 | 964件 | 96.4% |
1人が100回アクセス | 1 | 100 | 95件 | 95.0% |
検証結果から、下記が推定されます。
高負荷に耐えられない: 同時接続数50では**99.7%**のリクエストが失敗しており、明らかに高負荷を処理できていません。
ボトルネックは「頻度」: 最も重要なのは、同時接続数を1にしても95%のリクエストが失敗している点です。
これは、問題が「同時に多数のリクエストを処理できない」ことだけでなく、「短時間に連続してリクエストが来ること」自体に対応できていないことが分かります。
結論: レート制限を無効化したにも関わらずこの結果であるため、「Laravel 10環境は高頻度の連続リクエストという負荷に耐えられない」という判断をしました。
検証2の結果
項目 | Laravel 10 | Laravel 12 |
---|---|---|
高負荷テスト (c=50) | 0.3% 成功 | 100% 成功 |
中負荷テスト (c=10) | 3.6% 成功 | (未実施) |
逐次高頻度テスト (c=1) | 5.0% 成功 | (未実施) |
最大スループット | 計測不能 | 約243 req/s |
備考 | Laravel12においては、※c=1000でも成功 |
今回のスループットテストにおいて、Laravel 10と12の間には安定性と性能差がある事が分かりました。
Laravel 12は、高い同時接続数でも安定しており高いスループット性能でした。
Laravel 10は、レート制限を解除してもなお、高頻度のリクエストに耐えられず、ベンチマークが成立しませんでした。
これは、フレームワークの起動プロセスやリクエスト処理のパイプラインに、近年のバージョンアップで解消されたボトルネックが存在する事が分かります。
この結果から、特に軽量なリクエストを大量に処理するAPIサーバーのような用途では、Laravel 12がLaravel 10に比べて著しく優れているという結論になりました。
とはいえ、このままではスループットの成功可否での検証結果になってしまう為、
resの内容をjsonにし、負荷をもう少し軽減させどちらのverでもスループットが成功するようにさせ、
純粋なLaravel10と12におけるスループットの性能差を検証に移ってみます。
検証3: スループット性能の比較 (JSONレスポンスver)
「検証2」では、プレーンテキスト(HTML)を返すテストでLaravel 10が大量のエラーを発生させ、比較が成立しませんでした。
このままでは「成功か否か」の検証で終わってしまうため、Laravel 10でもリクエストが成功するよう条件を調整し、純粋なスループットの性能差を計測する最終検証に移ります。
今回は、responseをJSON形式に変更し、両バージョンを1000同時接続・1000リクエストという高負荷条件で比較してみます。
検証コード
Route::get('/hello', fn() => response()->json('Hello World'));
Laravel12での検証
ab -n 1000 -c 1000 http://localhost:8012/api/hello
This is ApacheBench, Version 2.3 <$Revision: 1913912 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (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.25.5
Server Hostname: localhost
Server Port: 8012
Document Path: /api/hello
Document Length: 11 bytes
Concurrency Level: 1000
Time taken for tests: 4.046 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 278000 bytes
HTML transferred: 11000 bytes
Requests per second: 247.14 [#/sec] (mean)
Time per request: 4046.323 [ms] (mean)
Time per request: 4.046 [ms] (mean, across all concurrent requests)
Transfer rate: 67.09 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 13 6.1 12 31
Processing: 195 2095 998.5 2118 3749
Waiting: 195 2095 998.5 2118 3749
Total: 209 2108 996.8 2132 3779
Percentage of the requests served within a certain time (ms)
50% 2132
66% 2664
75% 2978
80% 3135
90% 3479
95% 3631
98% 3724
99% 3751
100% 3779 (longest request)
Laravel10での検証
ab -n 1000 -c 1000 http://localhost:8010/api/hello
This is ApacheBench, Version 2.3 <$Revision: 1913912 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (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.25.5
Server Hostname: localhost
Server Port: 8010
Document Path: /api/hello
Document Length: 13 bytes
Concurrency Level: 1000
Time taken for tests: 15.518 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 316000 bytes
HTML transferred: 13000 bytes
Requests per second: 64.44 [#/sec] (mean)
Time per request: 15518.387 [ms] (mean)
Time per request: 15.518 [ms] (mean, across all concurrent requests)
Transfer rate: 19.89 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 21 9.3 19 34
Processing: 65 7725 4737.4 7883 15422
Waiting: 45 7725 4737.4 7883 15422
Total: 65 7747 4744.0 7909 15454
Percentage of the requests served within a certain time (ms)
50% 7909
66% 10558
75% 12289
80% 12903
90% 14156
95% 14576
98% 14897
99% 14950
100% 15454 (longest request)
実行結果
項目 | 秒間リクエスト数 (RPS) | 失敗リクエスト |
---|---|---|
Laravel 10 | 64.44 | 0件 |
Laravel 12 | 247.14 | 0件 |
レスポンスをJSON形式に変更したことで、Laravel 10環境でもリクエストが1000件すべて成功しました。
これで、両バージョンの純粋なスループット性能を比較することが可能になりました。
結果は、下記の通り。
- Laravel 12は秒間約247リクエストを処理
- Laravel 10は秒間約64リクエストを処理
これは、Laravel 12がLaravel 10に比べて 約3.8倍 のスループット性能を持つことを意味します。
これは圧倒的な差が生まれたと言って良いかと思います。
この性能差は、Laravel11以降で導入されたアプリケーションの起動(ブートストラップ)プロセスの高速化や、内部的な最適化がいかに効果的である事が分かります。
特に、軽量なリクエストを大量に処理するAPIのようなユースケースにおいて、恩恵を受けやすい結果となりました。
全ての検証を通して
今回の検証では、「高負荷な単一リクエスト」と「高頻度な軽量リクエスト(スループット)」という2つの異なるシナリオでLaravel 10と12のパフォーマンスを比較しました。
その結果、両者の性能差は処理のプロセスによって大きく異なりパフォーマンス向上の観点に気づくことができました。
【高負荷な単一リクエスト(DB・CPU処理中心)の場合】
50万件のレコードを処理するような重いタスクでは、処理時間の大半がDBのI/OやPHPの計算処理に費やされるため、フレームワーク自体の差はほとんど現れず、両者のパフォーマンスはほぼ互角でした。
【高頻度リクエスト(スループット)の場合】
軽量なAPIリクエストを大量に処理するテストでは、決定的かつ圧倒的な差が生まれました。
【スループット:安定差】
プレーンテキスト(HTML)を返すテストでは、Laravel 10は高頻度のリクエストに耐えられず、ほぼ全てのリクエストが失敗しました。
一方、Laravel 12は同時接続1000という極端な負荷でもエラーゼロという高い安定性を示しました。
【スループット:性能差】
両者が正常に動作するJSONレスポンスのテストでは、Laravel12が秒間約247リクエストを処理したのに対し、Laravel 10は秒間約64リクエストに留まりました。
これはLaravel12が約3.8倍高速であることを意味します。
最終結論
Laravel 11で導入されたアプリケーション起動プロセスの高速化は、今回の検証を通じて、特にAPIサーバーのような軽量なリクエストを大量にさばくユースケースにおいて、効果を発揮することが証明されました。
多くのAPIリクエストを高速に処理する必要があるアプリケーションにおいて、Laravel12へのアップデートは安定性とパフォーマンスの両面で、アップデート工数に見合うだけの価値があると言えるかと思います。