GNU/Linux >> Belajar Linux >  >> Linux

Menggunakan skrip Apache2Buddy untuk kinerja dan stabilitas

Apa itu Apache2Buddy?

Gunakan skrip Apache2Buddy untuk membantu membuat rekomendasi perubahan pada konfigurasi server web Apache® yang membantu kinerja dan stabilitas. Apache2Buddy tidak berdampak pada server itu sendiri dan tidak membuat perubahan. Setelah skrip berjalan, skrip ini menyarankan perbaikan Apache yang dapat Anda periksa dan pertimbangkan untuk diterapkan.

Apache2Buddy memeriksa setidaknya area yang menjadi perhatian berikut:

  • Batas memori PHP®
  • Memcache
  • MaxClients
  • Penggunaan memori
  • Penggunaan memori potensial maksimal
  • Persentase total RAM yang dialokasikan untuk Apache
  • MaxRequestWorkers

Jalankan Apache2Buddy

Jalankan perintah berikut untuk meluncurkan skrip dari baris perintah Linux®:

curl -sL https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl | perl

Setelah skrip Apache2Buddy selesai, ia mengembalikan sesuatu yang mirip dengan output berikut:

Apache Tuning with Respect to RAM Footprint of Web Applications
--------------------------------------------------------------

The MaxClients setting in your Apache configuration allows your web application child processes 
to consume more RAM than is available on the server.
---
[ -- ] Distro: CentOS
[ -- ] Version: 6.9
[ -- ] Codename: Final
[ OK ] This distro is supported by apache2buddy.pl.
[ -- ] Hostname: Server-01
[ -- ] Primary IP: 123.45.67.890
[ -- ] Apache is using prefork model.
[ OK ] Memory usage of parent PID is less than 50MB: 8368 Kilobytes.
[ -- ] Apache has been running 21d 06h 49m 32s.
[ -- ] Your server has 5834 MB of PHYSICAL memory.
[ -- ] Your ServerLimit setting is 60.
[ -- ] Your MaxClients setting is 60.
[ OK ] Current Apache Process Count is 22, including the parent PID.
[ -- ] Number of vhosts detected: 17.
[ -- ]             |________ of which 13 are HTTP (specifically, port 80).
[ -- ]             |________ of which 4 are HTTPS (specifically, port 443).
[ OK ] Current Apache vHost Count is less than maxclients.
[ -- ] Your MaxRequestsPerChild setting is 2000.
[ -- ] Your PHP Memory Limit (Per-Process) is 128 MB.
[ -- ] MySQL Detected => Using 134.74 MB of memory.
[ OK ] No large logs files were found in /var/log/httpd.
[ OK ] MaxClients has not been hit recently.
[ !! ] PHP Fatal errors were found, see summaries below.
[ @@ ] Check the logs manually.
[ @@ ]  - /var/log/httpd/example.com-error.log-20200203: 3
[ @@ ]  - /var/log/httpd/example.com-error.log: 5
[ @@ ]  - /var/log/httpd/example2.com-error.log-20200203: 1
[ -- ] httpd is currently using 2384.92 MB of memory.
[ -- ] The smallest apache process is using 83.18 MB of memory
[ -- ] The average apache process is using 107.48 MB of memory
[ -- ] The largest apache process is using 133.83 MB of memory
[ !! ] Going by the average Apache process, Apache can potentially use 6448.81 MB RAM: 
Without considering services: 110.54 % of total installed RAM 
Considering extra services: 113.16 % of remaining RAM 
[ !! ] Going by the largest Apache process, Apache can potentially use 8029.81 MB RAM: 
Without considering services: 137.64 % of total installed RAM 
Considering extra services: 140.90 % of remaining RAM

--------------------------------------------------------------------------------
### GENERAL FINDINGS & RECOMMENDATIONS ###
--------------------------------------------------------------------------------

Apache2buddy.pl report for server: Server-01 (123.45.67.890):
Settings considered for this report:
  Your server's physical RAM:                                   5834 MB
  Remaining Memory after other services considered:             5699 MB
  Apache's MaxClients directive:                                60       <---- Current Setting    
  Apache MPM Model:                                             prefork
  Largest Apache process (by memory):                           133 MB
[ !! ]  Your MaxClients setting is too high.
Your recommended MaxClients setting is between 37 and 42.              <---- Acceptable Range (10% of MAX)
Max potential memory usage:                                   8029 MB
Percentage of TOTAL RAM allocated to Apache:                  137.64  %
Percentage of REMAINING RAM allocated to Apache:              140.90  %
--------------------------------------------------------------------------------

Tinjau hasilnya

Anda mungkin juga melihat output dari skrip Apache2Buddy yang mirip dengan contoh berikut:

 [ !! ] Going by the average Apache process, Apache can potentially use 6448.81 MB RAM: 
 Without considering services:    110.54 % of total installed RAM 
 Considering extra services: 113.16 % of remaining RAM 
 [ !! ] Going by the largest Apache process, Apache can potentially use 8029.81 MB RAM: 
 Without considering services: 137.64 % of total installed RAM             
 Considering extra services: 140.90 % of remaining RAM

Anda harus tahu bahwa pernyataan ini membuat asumsi berikut:

  • Mengikuti proses Apache rata-rata :Tidak semua proses Apache berukuran rata-rata. Beberapa proses mungkin lebih besar atau lebih kecil.
  • Tanpa mempertimbangkan layanan :Apache2Buddyy mencoba menghitung kemungkinan penggunaan memori dari server web Apache. Tidak memperhitungkan bahwa memori yang tersedia juga digunakan untuk aplikasi lain seperti PHP, MariaDB®, dan sistem operasi itu sendiri.
  • Mempertimbangkan layanan tambahan :Apache2Buddy mencoba menghitung kemungkinan penggunaan memori server web Apache sambil membuat asumsi penggunaan memori aplikasi lain yang tersedia, yang mungkin tidak benar.

Catatan :Anda harus mempertimbangkan pernyataan yang diberikan oleh Apache2Buddy ini sebagai informasi mengenai skenario terburuk. Anda mungkin perlu menyelidiki lebih lanjut untuk mendapatkan kejelasan. Untuk informasi lebih lanjut, lihat tautan berikut:https://richardforth.github.io/Apache2buddy_ag/.


Linux
  1. konvensi penamaan untuk skrip shell dan makefile

  2. Apa perbedaan antara menggunakan `sh` dan `source`?

  3. Cakupan variabel untuk skrip bash shell dan fungsi dalam skrip

  1. Apa alasan rmdir(1) dan rm(1) hidup berdampingan?

  2. Menggunakan modem untuk mengirim rekaman suara

  3. Apa perbedaan antara menggunakan hulu dan lokasi untuk php-fpm?

  1. 7 trik praktis untuk menggunakan perintah wget Linux

  2. Apa itu Rolling Release Linux dan Apa Manfaat Nyata Menggunakannya

  3. Menggunakan nfsstat dan nfsiostat untuk memecahkan masalah kinerja NFS di Linux