Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/themes/simplicity2/lib/amp.php on line 38
nginx+php-fpmで微調整した話。php-fpmのプロセスはいくつ上げておくべき? | freeSIM.tokyo
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/themes/simplicity2/lib/scripts.php on line 131

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Functions::get_locale is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/class-module-view.php on line 54

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Functions::get_thumbnail is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/class-module-view.php on line 190

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Options::get is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/class-module-view.php on line 192

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Variable::default_options is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-options.php on line 48

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Variable::settings is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 188

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Functions::exists_push7 is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 129

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Functions::hex_to_rgb is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/class-module-view.php on line 193

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Options::get is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/class-module-view.php on line 61

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Variable::default_options is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-options.php on line 48

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Variable::settings is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 188

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Functions::exists_push7 is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 129

nginx+php-fpmで微調整した話。php-fpmのプロセスはいくつ上げておくべき?


Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/themes/simplicity2/lib/customizer.php on line 4923

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/themes/simplicity2/lib/customizer.php on line 4929

シェアする


Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Options::get is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/class-module-view.php on line 131

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Variable::default_options is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-options.php on line 48

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Variable::settings is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 188

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Functions::exists_push7 is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 129

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Variable::sns_list is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/class-module-shortcode.php on line 218

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Variable::default_options is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 206

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Variable::settings is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 188

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Functions::exists_push7 is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 129

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Functions::get_current_url is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/class-module-shortcode.php on line 219

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Variable::notification_list is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/class-module-shortcode.php on line 251

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Variable::default_options is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 232

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Variable::settings is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 188

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Functions::exists_push7 is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 129

Deprecated: Calling static trait method VASOCIALBUZZ\Modules\Functions::exists_push7 is deprecated, it should only be called on a class using the trait in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/plugins/va-social-buzz/incs/trait-variables.php on line 235

運用サイトは基本、nginx+php-fpm+mysql(mariadb)をベースにwordpressで動かしています。これが最近急に遅くなったのでチューニングとは言えないくらいの微調整でなんとか戻しました。


Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/themes/simplicity2/lib/customizer.php on line 4923

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/themes/simplicity2/lib/customizer.php on line 4929

nginx+php-fpmで微調整した話

ちょっと前から徐々にWordpressの管理画面を開くのが遅いなぁ・・・という状況になってきて、投稿をポストしたらエラーが出たりで、こりゃいよいよおかしいな、と思ってチェックしてみました。

便利だったhtop

通常、サイトの挙動が重い、遅いとなると、uptime、free、df、topあたりで調べていくのですが、もひとつ分からないので色々調べて1つ見つけたのがhtop。
topの詳細版なんですが、色分けされててソート順とかもF6押したら選べる感じで便利でした。
yum -y install ftop
くらいでインストールできるので、使える方はどうぞ。

最初はphp-fpmのプロセス数を上げてみた

最初はphp-fpmのプロセスが上限いっぱい(普段staticで使っている)だったので、とりあえず上げてみました。
muninのグラフはこんな感じ。weeklyなので08、09あたりを見て下さい。いっぱいですね。

それ以前からプロセスが足りなくなっているのがわかります。
こうなるとさすがにWordpressの管理画面みたいに全部php側に処理が回るものは待たされる事になるので、プロセス数(pm.max_children)を7から10に上げました。

閑話休題:php-fpmのプロセス数

ちなみに、他の例だとよくここが15とか30とかになっているのを見ますが、よほど毎回phpが走るサイトじゃなければそんなにいらないと思います。

WordPressでnginxでキャッシュしながら・・・という前提で考えると、超超メガサイトでWordpressの検索が色んなワードでガンガン来るならまだしも、普通にサイト運営してると検索する人なんてごく少数なんで、新規投稿と忘れた頃(キャッシュが切れてる頃)に過去ページを見に来られる対応くらいで、まぁ10が最大かと。pm.max_childrenを上げるとメモリも食うので、大体7とかで運用してます。月間数十万PVくらいのサイトでこんな感じ。

さて、話は戻ってこれを10に上げましたが結局また詰まっています。これは多分20にしても同じ事が起こる・・・つまりphp-fpm以外に何かボトルネックがある、ということ。結果待たされた分php-fpm側でプロセスの処理時間が伸びてリミットに達する、というはず。

mysql(mariadb)を疑う

WordPressは4.7だかにアップデートしたばかり、php-fpmの問題じゃないとすれば、あとはnginxかmysql。mysqlのグラフが上がっていたのでこちらを疑います。

一応mysqlと大体互換ですよ、というmariadb、my.cnfの設定も共用なのでmysqlの文献が使えます。久しぶりにmysqltuner.plとかも使いながら見てみると・・・結局tmp_table_sizeとmax_heap_sizeが異様に小さい値を設定していたのが悪いっぽい、という結論に。

デフォルトの126Mの倍の256Mに設定して終わり。
そしてmysql側を見てみると・・・

あー、ちゃんと下がりましたね。

で、今はload averageも0.16とかで動いているのでOKでした。

この記事が気に入ったら
いいね!お願いします


Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/themes/simplicity2/lib/customizer.php on line 4923

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/themes/simplicity2/lib/customizer.php on line 4929

シェアする

フォローする


Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/themes/simplicity2/lib/customizer.php on line 4923

Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/vhosts/freesim.tokyo/httpdocs/wp-content/themes/simplicity2/lib/customizer.php on line 4929

コメント

  1. […] 前回php-fpm周りの設定で「そんなにプロセスいらないよー」的な講釈を垂れてみましたが、その後全然設定が落ち着かず試行錯誤し続けていますw php-fpmがメモリリークしてるのか、ちょ […]