บน CentOS ใช้ Apache (Httpd) เป็น Web Server หรือเปล่าครับ
ถ้าใช้ ให้รันคำสั่งนี้ก่อนเพื่อเช็คว่า Apache กำลังใช้ MPM แบบไหน ซึ่ง MPM คือเทคนิคการจัดการกับ Concurrent ครับ
- โค้ด: เลือกทั้งหมด
httpd -V
จะเห็นประมาณนี้
- โค้ด: เลือกทั้งหมด
Server version: Apache/2.2.3
Server built: Oct 16 2013 12:18:29
Server's Module Magic Number: 20051115:3
Server loaded: APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
บรรทัด Server MPM: Prefork มันเป็น Prefork จะรับ Concurrent Clients ได้ไม่เท่าไหร่ครับ (แต่ก็เยอะอยู่ครับ แต่ว่าประสิทธิภาพมันจะไม่ค่อยดี) เดี๋ยวมาลองเช็คกัน
ในไฟล์ /etc/httpd/conf/httpd.conf มีบรรทัดที่เกี่ยวข้อง ตามนี้ครับ
- โค้ด: เลือกทั้งหมด
##
## Server-Pool Size Regulation (MPM specific)
##
# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
บรรทัด MaxClients 256 แสดงว่ารับได้ 256 concurrent clients ครับ ถ้าจะเพิ่มก็เพิ่มได้นะครับ แต่ MPM แบบ Prefork มีข้อเสียคือ ถ้าสตาร์ทมากก็กินหน่วยความจำมาก
ถ้า 256 concurent clients ยังไม่พอ ก็ควรเปลี่ยนไปใช้ MPM แบบ Worker ครับ