apache的httpd.exe占用内存的解决方法

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/th_csdn/article/details/80682465

版本:apache2.4

首先查看apache使用的是哪种MPM模块

linux 直接在服务器上输入 httpd -V (大写的V)  

windows下需要在cmd =>apache的bin目录

一般linux默认使用的是prefork ,windows的是winnt。

然后开启MPM模块,在httpd.conf文件中全文检索 mpm 

启用把 # 号去掉就ok

找到MPM模块的配置文件,windows的是在Apache的安装目录下 conf/extra/httpd-mpm.conf    

linux的用命令自己找  find / -name 'httpd-mpm.conf'

在该文件下查找相对应的模块配置 mpm__你的MPM模块名,比如windows下的是mpm_winnt

ThreadsPerChild:每个子进程的最大并发线程数

MaxConnectionsPerChild:每个子进程允许处理的请求总数,超过该值后会将子进程结束,然后它会自己判断是否还要创建新的子进程, 为0表示不限制请求总数,子进程是不会结束的 (会占用大量内存); 如要设置一个非0值,需要根据服务器内存的大小来设置

设置好了之后重启Apache,运行你的程序,你会发现已经ojbk了




MaxConnectionsPerChild:表示请求多少次后才会将进程结束  为0的话会将
展开阅读全文

apache 内存占用问题

09-29

apache 内存占用很大,有什么方法可以解决吗?php版本是5.5.3,Apache是2.2.14rnrn[code=c]ps -ylC httpd --sort:rss | awk 'sum+=$8; ++n END print "Tot="sum"("n")";print "Avg="sum"/"n"="sum/n/1024"MB"'rnTot=2762932(35)rnAvg=2762932/35=77.0907MB[/code]rn才35个进程,每个要77MB,总共要2.6GB。rnrntop命令查看rn[code=c]Tasks: 96 total, 9 running, 87 sleeping, 0 stopped, 0 zombiernCpu(s): 82.1%us, 9.3%sy, 0.0%ni, 8.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%strnMem: 4194304k total, 4194304k used, 0k free, 0k buffersrnSwap: 0k total, 0k used, 0k free, 0k cachedrnrn PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMANDrn 1852 mysql 15 0 5613m 1.1g 6336 S 63.2 27.7 57:31.20 mysqldrn15508 apache 15 0 377m 91m 36m R 13.1 2.2 0:03.78 httpdrn15608 root 16 0 266m 62m 9676 R 11.8 1.5 0:01.75 phprn13955 apache 15 0 368m 86m 39m S 11.5 2.1 0:22.41 httpdrn12051 apache 16 0 373m 94m 39m R 10.5 2.3 0:58.09 httpdrn13947 apache 15 0 369m 91m 39m S 6.4 2.2 0:26.81 httpdrn13967 apache 16 0 351m 72m 39m S 5.4 1.8 0:23.34 httpdrn15517 apache 15 0 345m 62m 32m S 5.4 1.5 0:03.20 httpdrn13527 apache 15 0 376m 96m 39m S 5.1 2.4 0:48.03 httpdrn15620 root 15 0 218m 19m 8276 S 4.8 0.5 0:00.46 phprn15457 apache 16 0 365m 82m 37m R 4.5 2.0 0:05.21 httpdrn15514 apache 15 0 337m 54m 31m S 4.5 1.3 0:03.59 httpdrn15518 apache 15 0 337m 48m 26m S 4.5 1.2 0:02.45 httpdrn15461 apache 15 0 346m 64m 34m S 3.8 1.6 0:06.47 httpdrn13944 apache 16 0 375m 94m 39m S 2.6 2.3 0:24.36 httpdrn15456 apache 15 0 368m 84m 38m R 2.6 2.1 0:07.29 httpdrn15365 apache 15 0 351m 71m 37m S 2.2 1.7 0:09.78 httpd[/code]rnrnmysql用了1.1GB,别的都让httpd抢光了。rnrnhttpd.conf 设置如下,KeepAlive Off 和 On没什么区别rnrn[code=c]Timeout 45rnKeepAlive OffrnMaxKeepAliveRequests 256rnKeepAliveTimeout 2rnrnrnStartServers 5rnMinSpareServers 5rnMaxSpareServers 20rnServerLimit 192rnMaxClients 192rnMaxRequestsPerChild 3000rn[/code]rnrnMaxClients设置的又是不大,而且php代码里,变量用完后都用$string=NULL; 来清空内存,function()里也在return后面一行添加$string=NULL; 还是没解决内存问题。rnrn此外,测试了一些常用的php文件,重启Apache时脚本运行和满负荷内存时脚本运行相比,内存和运行时间都相差很大。即空闲时php内存只有满负荷时的40%,时间也差不多差40%。(memory_get_usage(true)/1024 ) 论坛

Apache httpd.exe内存很高导致网站无法访问

03-01

Apache2.2 rnhttpd.exe占内存很高导致网站无法访问 rn每次删掉那个占内存大的httpd.exe 后就正常了 不知道是什么原因啊 有人能告诉我一下吗谢谢啊。rnrnhttpd-mpm.conf 配置如下:rnrn[code=C#]#rn# Server-Pool Management (MPM specific)rn# rnrn#rn# PidFile: The file in which the server should record its processrn# identification number when it starts.rn#rn# Note that this is the default PidFile for most MPMs.rn#rnrn PidFile "logs/httpd.pid"rnrnrn#rn# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.rn#rnrnrnLockFile "logs/accept.lock"rnrnrnrn#rn# Only one of the below sections will be relevant on yourrn# installed httpd. Use "apachectl -l" to find out thern# active mpm.rn#rnrn# prefork MPMrn# StartServers: number of server processes to startrn# MinSpareServers: minimum number of server processes which are kept sparern# MaxSpareServers: maximum number of server processes which are kept sparern# MaxClients: maximum number of server processes allowed to startrn# MaxRequestsPerChild: maximum number of requests a server process servesrnrnrn ServerLimit 1000rn StartServers 10rn MinSpareServers 10rn MaxSpareServers 15rn MaxClients 300rn RequestsPerChild 10000rn ListenBacklog 511rnrnrnrn# worker MPMrn# StartServers: initial number of server processes to startrn# MaxClients: maximum number of simultaneous client connectionsrn# MinSpareThreads: minimum number of worker threads which are kept sparern# MaxSpareThreads: maximum number of worker threads which are kept sparern# ThreadsPerChild: constant number of worker threads in each server processrn# MaxRequestsPerChild: maximum number of requests a server process servesrnrn #StartServers 2rn #MaxClients 150rn #MinSpareThreads 50rn #MaxSpareThreads 200 rn #ThreadsPerChild 100rn #MaxRequestsPerChild 0rnrn StartServers 3rn MaxClients 2000rn ServerLimit 25rn MinSpareThreads 50rn MaxSpareThreads 200rn ThreadLimit 200rn ThreadsPerChild 100rn MaxRequestsPerChild 100rn ListenBacklog 511rnrnrn# BeOS MPMrn# StartThreads: how many threads do we initially spawn?rn# MaxClients: max number of threads we can have (1 thread == 1 client)rn# MaxRequestsPerThread: maximum number of requests each thread will processrnrn StartThreads 10rn MaxClients 50rn MaxRequestsPerThread 10000rnrnrn# NetWare MPMrn# ThreadStackSize: Stack size allocated for each worker threadrn# StartThreads: Number of worker threads launched at server startuprn# MinSpareThreads: Minimum number of idle threads, to handle request spikesrn# MaxSpareThreads: Maximum number of idle threadsrn# MaxThreads: Maximum number of worker threads alive at the same timern# MaxRequestsPerChild: Maximum number of requests a thread serves. It is rn# recommended that the default value of 0 be set for thisrn# directive on NetWare. This will allow the thread to rn# continue to service requests indefinitely. rnrn ThreadStackSize 65536rn StartThreads 250rn MinSpareThreads 25rn MaxSpareThreads 250rn MaxThreads 1000rn MaxRequestsPerChild 100rn MaxMemFree 100rnrnrn# OS/2 MPMrn# StartServers: Number of server processes to maintainrn# MinSpareThreads: Minimum number of idle threads per process, rn# to handle request spikesrn# MaxSpareThreads: Maximum number of idle threads per processrn# MaxRequestsPerChild: Maximum number of connections per server processrnrn StartServers 2rn MinSpareThreads 5rn MaxSpareThreads 10rn MaxRequestsPerChild 100rnrnrn# WinNT MPMrn# ThreadsPerChild: constant number of worker threads in the server processrn# MaxRequestsPerChild: maximum number of requests a server process servesrnrn ThreadsPerChild 150rn MaxRequestsPerChild 100rn MaxMemFree 100rnrn rn rnrnrn[/code]rnrn请高手解决一下啊 rnrn网站一到后半夜 就挂了 帮个忙啊 我QQ 1136125980 电话:18943156268 论坛

没有更多推荐了,返回首页