我花了一两个星期研究和设置我的服务器,以使用Worker MPM和FCID运行Apache。我正在尝试对其进行优化,以允许尽可能多的并发连接。在Worker MPM上找到良好的信息一直是一场噩梦。
服务器-具有1GB RAM的VPS(关闭Apache仅使用约150MB RAM)我希望Apache具有约750MB的内存使用率CAP-这样我的服务器将永远不会用完RAM。
我已经运行服务器大约两年了,没有任何问题-但是我们最近开始流式传输MP3,这需要更多的并发连接。该服务器还受到了一些较小的DDOS攻击-因此我将设置减少了一吨,以防止服务器内存不足-我还为速率限制添加了一些防火墙规则。
我现在进行的设置看起来运行良好-但是我遇到了一些Segmentation Fault错误
[Sat Mar 23 03:19:50 2013] [notice] child pid 28351 exit signal Segmentation fault (11)
[Sat Mar 23 03:56:20 2013] [notice] child pid 29740 exit signal Segmentation fault (11)
*** glibc detected *** /usr/sbin/httpd.worker: malloc(): memory corruption: 0xb83abdd8 ***
还有一些内存不足错误
Out of memory during array extend.
这是我目前的设置,非常感谢您提供一些建议。
Apache设置:
Timeout 30
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 2
#####################
# Spawn 2 child processes, spawning 25 threads for each child process.
# So, a pool of 50 threads is left up and sleeping, ready to serve incoming requests.
# If more requests will come in, apache will spawn new child processes, each one spawning 25 threads,
# enlarging the thread pool until the total number of threads become 50. In that case, apache begin
# to cleanly drop processes, trying to reach 25 threads.
# New processes and its threads are spawned in case of a large spike of requests, until 200 parallel
# client requests are reached, then apache will no longer accept new incoming connections.
# When the load calm down, and requests come back under 200 parallel connections, apache will continue
# to accept connections. After 25, 000 requests served by a child, q. 1000 per thread, the process
# get closed by the father to ensure no memory leak is fired.
<IfModule worker.c>
ServerLimit 16
StartServers 2
MaxClients 400
MinSpareThreads 25
MaxSpareThreads 50
ThreadsPerChild 25
MaxRequestsPerChild 1000
ThreadLimit 64
ThreadStackSize 1048576
</IfModule>
#####################
然后在fcgid.conf中进行一些设置
FcgidMinProcessesPerClass 0
FcgidMaxProcessesPerClass 8
FcgidMaxProcesses 25
FcgidIdleTimeout 60
FcgidProcessLifeTime 120
FcgidIdleScanInterval 30
根据要求,我的输出为/etc/my.cnf
[mysqld] datadir = / var / lib / mysql 套接字= / var / lib / mysql / mysql.sock 用户= MySQL #skip-innodb connect_timeout = 10 max_connections = 300 symbolic-links = 0 innodb_file_per_table = 1 myisam_sort_buffer_size = 8M read_rnd_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K sort_buffer_size = 512K table_cache = 32 max_allowed_packet = 1M key_buffer = 16k query_cache_type = 1 查询缓存大小= 32M thread_cache_size = 16 net_buffer_length = 2K thread_stack = 256K wait_timeout = 300 slow_query_log #log-slow-queries = / var / log / mysql / slow-queries.log slow_query_log = / var / log / mysql / slow-queries.log long_query_time = 1 [mysqld_safe] 日志错误= / var / log / mysqld.log pid文件= / var / run / mysqld / mysqld.pid
和PHP memory_limit = 64M