cc128
V2EX  ›  问与答

Apache 内存占用高

  •  
  •   cc128 · Aug 16, 2018 · 1943 views
    This topic created in 2850 days ago, the information mentioned may be changed or developed.

    1G 的机器上装了 apache,mysql, 搭了个 wordpress. 跑了个 SS 和 docker 里跑了个 tomcat。可用内存只有 100M 多点

    total       used       free     shared    buffers     cached
    Mem:          990M       966M        23M        47M       3.7M       111M
    -/+ buffers/cache:       851M       138M
    Swap:         1.0G       207M       816M
    

    然后看了下内存占用:

    mysql    32741  0.0  4.7 890540 47988 ?        Ssl  Aug06   9:19 /usr/sbin/mysqld
    www-data 14956  0.0  4.9 295976 50140 ?        S    Aug14   0:10 /usr/sbin/apache2 -k start
    www-data 25174  0.0  5.4 299416 55144 ?        S    Aug15   0:09 /usr/sbin/apache2 -k start
    www-data 28967  0.0  5.9 309676 60332 ?        S    06:39   0:08 /usr/sbin/apache2 -k start
    www-data 24717  0.0  6.4 312228 64972 ?        S    Aug15   0:09 /usr/sbin/apache2 -k start
    www-data 26638  0.0  6.4 311516 65764 ?        S    Aug13   0:25 /usr/sbin/apache2 -k start
    www-data 26659  0.0  6.7 311084 68316 ?        S    Aug13   0:35 /usr/sbin/apache2 -k start
    www-data 26634  0.0  7.5 312184 76440 ?        S    Aug13   0:35 /usr/sbin/apache2 -k start
    www-data 25226  0.0  8.1 331376 82620 ?        S    Aug15   0:11 /usr/sbin/apache2 -k start
    www-data 28281  0.0  8.4 329208 86100 ?        S    Aug13   0:31 /usr/sbin/apache2 -k start
    www-data  1702  0.0  8.7 332624 88292 ?        S    Aug14   0:28 /usr/sbin/apache2 -k start
    root     28117  0.1 22.2 2314732 225540 ?      Ssl  Aug13   8:54 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -server -Xms64m -Xmx256m -XX:MaxMetaspaceSize=128m -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
    

    Apache 的 10 个进程用了 70%多的内存。配置如下。

    <IfModule mpm_prefork_module>
    	StartServers          1
    	MinSpareServers       1
    	MaxSpareServers       3
    	ServerLimit 	 10
    	MaxClients           10
    	MaxRequestsPerChild  500
    </IfModule>
    

    请问要怎么能减少内存占用? 还是换成 nginx ? 另外 tomcat 内存还能设置小吗? 现在就跑了个接口,从数据库查数据,自己用,没什么量

    flynaj
        1
    flynaj  
       Aug 17, 2018 via Android
    你发的不是 free966M 么
    cc128
        2
    cc128  
    OP
       Aug 17, 2018
    @flynaj total 998,used 966,free 23, 贴上来有点歪。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3006 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 08:30 · PVG 16:30 · LAX 01:30 · JFK 04:30
    ♥ Do have faith in what you're doing.