全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2509|回复: 14
打印 上一主题 下一主题

[疑问] 请技术控帮忙看一个内存优化的问题

[复制链接]
跳转到指定楼层
1#
发表于 2011-8-10 12:28:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
之前vps是256的 开3个 nginx进程  8个php-fpm进程(动态模式)
开机占用大概120m左右的内存,运行一段时间后基本上256就满了 然后restart php-fpm能够释放一些内存出来

现在升级到512m的内存,发现512也运行一段时间就满了

请教一些 如何优化一些系统
  1.              total       used       free     shared    buffers     cached
  2. Mem:        524464     485200      39264          0      36760     355320
  3. -/+ buffers/cache:      93120     431344
  4. Swap:       262136          0     262136
复制代码
  1. [root@centos ~]# ps aux
  2. USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
  3. root         1  0.0  0.1   2176   744 ?        Ss   Aug09   0:00 init [3]                              
  4. root         2  0.0  0.0      0     0 ?        S<   Aug09   0:00 [migration/0]
  5. root         3  0.0  0.0      0     0 ?        SN   Aug09   0:00 [ksoftirqd/0]
  6. root         4  0.0  0.0      0     0 ?        S<   Aug09   0:00 [watchdog/0]
  7. root         5  0.0  0.0      0     0 ?        S<   Aug09   0:00 [events/0]
  8. root         6  0.0  0.0      0     0 ?        S<   Aug09   0:00 [khelper]
  9. root         7  0.0  0.0      0     0 ?        S<   Aug09   0:00 [kthread]
  10. root         9  0.0  0.0      0     0 ?        S<   Aug09   0:00 [xenwatch]
  11. root        10  0.0  0.0      0     0 ?        S<   Aug09   0:00 [xenbus]
  12. root        17  0.0  0.0      0     0 ?        S<   Aug09   0:00 [kblockd/0]
  13. root        18  0.0  0.0      0     0 ?        S<   Aug09   0:00 [cqueue/0]
  14. root        22  0.0  0.0      0     0 ?        S<   Aug09   0:00 [khubd]
  15. root        24  0.0  0.0      0     0 ?        S<   Aug09   0:00 [kseriod]
  16. root        84  0.0  0.0      0     0 ?        S    Aug09   0:00 [khungtaskd]
  17. root        85  0.0  0.0      0     0 ?        S    Aug09   0:00 [pdflush]
  18. root        86  0.0  0.0      0     0 ?        S    Aug09   0:00 [pdflush]
  19. root        87  0.0  0.0      0     0 ?        S<   Aug09   0:00 [kswapd0]
  20. root        88  0.0  0.0      0     0 ?        S<   Aug09   0:00 [aio/0]
  21. root       229  0.0  0.0      0     0 ?        S<   Aug09   0:00 [kpsmoused]
  22. root       248  0.0  0.0      0     0 ?        S<   Aug09   0:00 [kstriped]
  23. root       259  0.0  0.0      0     0 ?        S<   Aug09   0:00 [kjournald]
  24. root       280  0.0  0.0      0     0 ?        S<   Aug09   0:00 [kauditd]
  25. root       308  0.0  0.1   2268   572 ?        S<s  Aug09   0:00 /sbin/udevd -d
  26. root       603  0.0  0.0      0     0 ?        S<   Aug09   0:00 [kmpathd/0]
  27. root       604  0.0  0.0      0     0 ?        S<   Aug09   0:00 [kmpath_handlerd]
  28. root       807  0.0  0.1   1828   624 ?        Ss   Aug09   0:00 syslogd -m 0
  29. root       810  0.0  0.0   1776   412 ?        Ss   Aug09   0:00 klogd -x
  30. root       824  0.0  0.2   7220  1064 ?        Ss   Aug09   0:00 /usr/sbin/sshd
  31. root       835  0.0  0.2   2564  1196 ?        S    Aug09   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe
  32. mysql      912  0.6  8.5 328588 44856 ?        Sl   Aug09   1:37 /usr/local/mysql/bin/mysqld --basedir=/u
  33. root       950  0.0  0.0   2008   472 ?        Ss   Aug09   0:00 gpm -m /dev/input/mice -t exps2
  34. root       974  0.0  0.2   3348  1128 ?        Ss   Aug09   0:00 crond
  35. root       980  0.0  0.1   5984   712 ?        Ss   Aug09   0:00 nginx: master process /usr/local/nginx/s
  36. www        981  0.0  0.3   6312  1676 ?        S    Aug09   0:01 nginx: worker process      
  37. www        982  0.0  0.2   6280  1572 ?        S    Aug09   0:01 nginx: worker process      
  38. www        983  0.0  0.3   6232  1628 ?        S    Aug09   0:02 nginx: worker process      
  39. root       991  0.0  0.0   1760   456 tty1     Ss+  Aug09   0:00 /sbin/mingetty tty1
  40. root       992  0.0  0.0   1760   456 tty2     Ss+  Aug09   0:00 /sbin/mingetty tty2
  41. root       993  0.0  0.0   1760   460 tty3     Ss+  Aug09   0:00 /sbin/mingetty tty3
  42. root       994  0.0  0.0   1760   456 tty4     Ss+  Aug09   0:00 /sbin/mingetty tty4
  43. root       995  0.0  0.0   1760   460 tty5     Ss+  Aug09   0:00 /sbin/mingetty tty5
  44. root       996  0.0  0.0   1760   456 tty6     Ss+  Aug09   0:00 /sbin/mingetty tty6
  45. root       997  0.0  0.0   1760   460 xvc0     Ss+  Aug09   0:00 /sbin/mingetty xvc0
  46. root      2161  0.0  0.5  72596  3012 ?        Ss   00:23   0:00 php-fpm: master process (/usr/local/php/
  47. www       2162  0.0  1.1  72996  6076 ?        S    00:23   0:00 php-fpm: pool www         
  48. www       2163  0.0  1.1  72996  5876 ?        S    00:23   0:00 php-fpm: pool www         
  49. www       2164  0.0  1.5  73288  8012 ?        S    00:23   0:00 php-fpm: pool www         
  50. www       2165  0.0  1.5  73588  7972 ?        S    00:23   0:00 php-fpm: pool www         
  51. www       2166  0.0  1.5  73596  8052 ?        S    00:23   0:00 php-fpm: pool www         
  52. www       2167  0.0  1.4  73584  7600 ?        S    00:23   0:00 php-fpm: pool www         
  53. www       2168  0.0  1.7  77600  9068 ?        S    00:23   0:00 php-fpm: pool www         
  54. www       2169  0.0  1.7  77600  9376 ?        S    00:23   0:00 php-fpm: pool www         
  55. root      2255  0.2  0.5  10048  2884 ?        Ss   00:27   0:00 sshd: root@pts/0
  56. root      2259  0.2  0.2   5020  1528 pts/0    Ss   00:27   0:00 -bash
  57. root      2282  0.0  0.1   4608   992 pts/0    R+   00:27   0:00 ps aux
复制代码
  1. top - 00:29:21 up  4:09,  1 user,  load average: 0.12, 0.05, 0.01
  2. Tasks:  55 total,   2 running,  53 sleeping,   0 stopped,   0 zombie
  3. Cpu(s):  1.0%us,  0.0%sy,  0.0%ni, 96.3%id,  0.3%wa,  0.0%hi,  0.0%si,  2.3%st
  4. Mem:    524464k total,   497876k used,    26588k free,    37116k buffers
  5. Swap:   262136k total,        0k used,   262136k free,   356692k cached

  6.   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                    
  7.   982 www       15   0  6280 1648  860 S  0.7  0.3   0:01.72 nginx                                       
  8.     1 root      15   0  2176  744  644 S  0.0  0.1   0:00.08 init                                       
  9.     2 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 migration/0                                 
  10.     3 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0                                 
  11.     4 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/0                                 
  12.     5 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 events/0                                    
  13.     6 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khelper                                    
  14.     7 root      12  -5     0    0    0 S  0.0  0.0   0:00.00 kthread                                    
  15.     9 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 xenwatch                                    
  16.    10 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 xenbus                                      
  17.    17 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kblockd/0                                   
  18.    18 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 cqueue/0                                    
  19.    22 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 khubd                                       
  20.    24 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kseriod                                    
  21.    84 root      21   0     0    0    0 S  0.0  0.0   0:00.00 khungtaskd                                 
  22.    85 root      15   0     0    0    0 S  0.0  0.0   0:00.02 pdflush                                    
  23.    86 root      15   0     0    0    0 S  0.0  0.0   0:00.00 pdflush                                    
  24.    87 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kswapd0                                    
  25.    88 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 aio/0                                       
  26.   229 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 kpsmoused                                   
  27.   248 root      18  -5     0    0    0 S  0.0  0.0   0:00.00 kstriped                                    
  28.   259 root      10  -5     0    0    0 S  0.0  0.0   0:00.01 kjournald                                   
  29.   280 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 kauditd                                    
  30.   280 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 kauditd                                    
  31.   308 root      21  -4  2268  572  376 S  0.0  0.1   0:00.05 udevd                                       
  32.    86 root      15   0     0    0    0 S  0.0  0.0   0:00.00 pdflush                                    
  33.    87 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kswapd0                                    
  34.    88 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 aio/0                                       
  35.   229 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 kpsmoused                                   
  36.   248 root      18  -5     0    0    0 S  0.0  0.0   0:00.00 kstriped                                    
  37.   259 root      10  -5     0    0    0 S  0.0  0.0   0:00.01 kjournald   
复制代码

[ 本帖最后由 richie 于 2011-8-10 12:29 编辑 ]
2#
发表于 2011-8-10 12:28:53 | 只看该作者
继续升级到1G
3#
发表于 2011-8-10 12:29:54 | 只看该作者
原帖由 qiqibian 于 2011-8-10 12:28 发表
继续升级到1G

4#
 楼主| 发表于 2011-8-10 12:30:04 | 只看该作者
原帖由 qiqibian 于 2011-8-10 12:28 发表
继续升级到1G

老大 别玩我了。。
5#
发表于 2011-8-10 12:32:49 | 只看该作者
-/+ buffers/cache:      93120     431344

要看这个的,才用了90多m
怕什么啊..
6#
发表于 2011-8-10 12:34:05 | 只看该作者
xen
7#
发表于 2011-8-10 12:35:46 | 只看该作者
敢不敢先学一点linux再玩vps?
8#
发表于 2011-8-10 12:36:54 | 只看该作者
内存还那么多

xen看内存不一样滴
9#
发表于 2011-8-10 12:37:41 | 只看该作者
VPS给几核就开几个NGINX进程,访问量不够不用开那么多PHP-FPM进程,出现502了再加
10#
发表于 2011-8-10 12:38:22 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-6-7 01:57 , Processed in 0.064447 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表