歡迎您光臨本站 註冊首頁

請問這樣的是否正常?apache吃內存那麼大

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

請問這樣的是否正常?apache吃內存那麼大

PID       USER        PR   NI   VIRT     RES    SHR  S %     CPU %MEM    TIME+     COMMAND                                                               
27211    daemon    16   0   117m    14m   8884  S         1.3      0.7    0:00.14    httpd                                                                  

這樣的值正常嗎?

有時候更誇張的是:
  PID       USER        PR   NI   VIRT     RES    SHR  S %     CPU %MEM    TIME+     COMMAND                                                               
27211    daemon    16   0   117m    14m   11m  S         1.3      0.7    0:00.14    httpd        
                    
squid 2.6  ---- apache 2.2.4 ----- php5.2x ---- mysql 5.x

只運行了一個 Discuz! 5.5.0 做為測試。

沒多少訪問量,因為一切都在測試中。

其他資料:

# uname -a
Linux host.abc.net 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:00:54 EDT 2005 x86_64 x86_64 x86_64 GNU/Linux
# ./httpd -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c

還加裝了mod_security.

#LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
#LoadModule authz_user_module modules/mod_authz_user.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
#LoadModule authz_owner_module modules/mod_authz_owner.so
#LoadModule authz_default_module modules/mod_authz_default.so
#LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule cache_module modules/mod_cache.so
#LoadModule disk_cache_module modules/mod_disk_cache.so
#LoadModule mem_cache_module modules/mod_mem_cache.so
#LoadModule dbd_module modules/mod_dbd.so
#LoadModule dumpio_module modules/mod_dumpio.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
#LoadModule include_module modules/mod_include.so
#LoadModule filter_module modules/mod_filter.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule logio_module modules/mod_logio.so
#LoadModule env_module modules/mod_env.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule headers_module modules/mod_headers.so
#LoadModule ident_module modules/mod_ident.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule ssl_module modules/mod_ssl.so
LoadModule mime_module modules/mod_mime.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule status_module modules/mod_status.so
#LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule asis_module modules/mod_asis.so
#LoadModule info_module modules/mod_info.so
#LoadModule cgi_module modules/mod_cgi.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
#LoadModule imagemap_module modules/mod_imagemap.so
#LoadModule actions_module modules/mod_actions.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule userdir_module modules/mod_userdir.so
#LoadModule alias_module modules/mod_alias.so
#LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
#LoadModule imagemap_module modules/mod_imagemap.so
#LoadModule actions_module modules/mod_actions.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule userdir_module modules/mod_userdir.so
#LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module        modules/libphp5.so
#LoadModule security2_module modules/mod_security2.so
LoadModule security_module    modules/mod_security.so



Timeout 120
KeepAlive On
MaxKeepAliveRequests 50
KeepAliveTimeout 5
UseCanonicalName Off


<IfModule mpm_prefork_module>
#   StartServers          5
#   MinSpareServers       5
#   MaxSpareServers      10
#   MaxClients          150
#   MaxRequestsPerChild   0
StartServers 10
MinSpareServers 10
MaxSpareServers 15
ServerLimit 2000
MaxClients 1000
MaxRequestsPerChild 10000
</IfModule>

機器配置也不算太差:

雙至強 3.2 64位 2G內存 SCSI硬碟 1萬5千轉的

我再補充一下mysql的,我一直也認為我的MYSQL有點問題。有時候會出現2003錯誤。

我編譯的使用:

./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --localstatedir=/myszeki/newmysql --with-unix-socket-path=/tmp/mysql.sock --enable-assembler --with-charset=utf8 --with-mit-threads --enable-thread-safe-client

上面是否有問題?特別是紅色部分。my.cnf 如下:

port = 3306
socket = /tmp/mysql.sock
skip-locking
#0627
skip-name-resolve
back_log = 384
key_buffer_size = 192M
#
key_buffer = 16M
#0627
#max_allowed_packet = 1M
max_allowed_packet = 2M
#table_cache = 64
table_cache = 128K
thread_stack = 256K
#sort_buffer_size = 512K
sort_buffer_size = 3M

net_buffer_length = 8K
#read_buffer_size = 256K
read_buffer_size = 2M
join_buffer_size = 4M

read_rnd_buffer_size = 512K
#myisam_sort_buffer_size = 8M
myisam_sort_buffer_size = 64M
query_cache_size = 64M
tmp_table_size = 256M
max_connections = 768
thread_concurrency = 4
skip-bdb
skip-innodb


其他內容默認。請問有沒問題?

[ 本帖最後由 powerv 於 2007-7-14 04:16 編輯 ]
《解決方案》

如果只是一個DZ5.5  14M好像稍微是多了一些,我這邊大約10多個DZ,現在的是

PID         USER    PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
22401 nobody    16   0  164m  14m 7304 S    0  1.1   0:02.02 httpd
22400 nobody    16   0  165m  13m 5772 S    0  1.0   0:01.71 httpd
22486 nobody    16   0  165m  13m 5524 S    0  1.0   0:01.89 httpd
22393 nobody    16   0  165m  13m 5588 S    0  1.0   0:01.93 httpd
22490 nobody    16   0  163m  13m 6808 S    0  1.0   0:01.36 httpd
22395 nobody    16   0  163m  13m 6768 S    0  1.0   0:02.32 httpd
22397 nobody    16   0  164m  13m 6296 S    0  1.0   0:01.49 httpd
22454 nobody    16   0  164m  13m 6084 S    0  0.9   0:01.87 httpd

PS:Apache在大約6個小時之前重啟過一次,
我apache 1.37

加了xcache 給了大約128M的內存

Timeout 300
KeepAlive On
MaxKeepAliveRequests 1000
KeepAliveTimeout 15
MinSpareServers 10
MaxSpareServers 20
StartServers 10
MaxClients 5000

AddModule mod_env.c
AddModule mod_log_config.c
AddModule mod_mime.c
AddModule mod_negotiation.c
AddModule mod_status.c
AddModule mod_include.c
AddModule mod_autoindex.c
AddModule mod_dir.c
AddModule mod_cgi.c
AddModule mod_asis.c
AddModule mod_imap.c
AddModule mod_actions.c
AddModule mod_userdir.c
AddModule mod_alias.c
AddModule mod_rewrite.c
AddModule mod_access.c
AddModule mod_auth.c
AddModule mod_expires.c
AddModule mod_so.c
AddModule mod_setenvif.c
<IfDefine SSL>
AddModule mod_ssl.c
</IfDefine>
AddModule mod_frontpage.c
AddModule mod_php4.c
AddModule mod_bwlimited.c
AddModule mod_log_bytes.c
AddModule mod_auth_passthrough.c
AddModule mod_gzip.c


雙E5320  內存上次自己帶錯,有時間再去換,現在只有1.5G

[ 本帖最後由 wigeboy 於 2007-7-14 04:08 編輯 ]
《解決方案》

謝謝樓上的回復。有時候我就是發現 14M,10M。。。
《解決方案》

mysql的話,給大家一個好東西,也許很多人都用過
http://www.day32.com/MySQL/    找第一個script

或者直接http://www.day32.com/MySQL/tuning-primer.sh

他會給你提建議的
《解決方案》

原帖由 wigeboy 於 2007-7-14 04:28 發表 http://bbs.chinaunix.net/images/common/back.gif
mysql的話,給大家一個好東西,也許很多人都用過
http://www.day32.com/MySQL/    找第一個script

或者直接http://www.day32.com/MySQL/tuning-primer.sh

他會給你提建議的
-- MYSQL PERFORMANCE TUNING PRIMER --
             - By: Matthew Montgomery -

MySQL Version 5.0.41-log x86_64

Uptime = 2 days 13 hrs 24 min 23 sec
Avg. qps = 0
Total Questions = 80677
Threads Connected = 11

Server has been running for over 48hrs.
It should be safe to follow these recommendations

To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html

SLOW QUERIES
Current long_query_time = 10 sec.
You have 0 out of 80695 that take longer than 10 sec. to complete
The slow query log is NOT enabled.
Your long_query_time may be too high, I typically set this under 5 sec.

WORKER THREADS
Current thread_cache_size = 0
Current threads_cached = 0
Current threads_per_sec = 1
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 768
Current threads_connected = 11
Historic max_used_connections = 13
The number of used connections is 1% of the configured maximum.
You are using less than 10% of your configured max_connections.
Lowering max_connections could help to avoid an over-allocation of memory
See "MEMORY USAGE" section to make sure you are not over-allocating

MEMORY USAGE
Max Memory Ever Allocated : 217 M
Configured Max Per-thread Buffers : 7 G
Configured Max Global Buffers : 90 M
Configured Max Memory Limit : 7 G
Total System Memory : 3.96 G

Max memory limit exceeds 85% of total system memory

KEY BUFFER
Current MyISAM index space = 1 M
Current key_buffer_size = 16 M
Key cache miss rate is 1 : 2571
Key buffer fill ratio = 3.00 %
Your key_buffer_size seems to be too high.
Perhaps you can use these resources elsewhere

QUERY CACHE
Query cache is enabled
Current query_cache_size = 64 M
Current query_cache_used = 6 M
Current query_cach_limit = 1 M
Current Query cache fill ratio = 9.84 %
Your query_cache_size seems to be too high.
Perhaps you can use these resources elsewhere
MySQL won't cache query results that are larger than query_cache_limit in size

SORT OPERATIONS
Current sort_buffer_size = 3 M
Current record/read_rnd_buffer_size = 508 K
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 4.00 M
You have had 0 queries where a join could not use an index properly
Your joins seem to be using indexes properly
join_buffer_size >= 4 M
This is not advised

OPEN FILES LIMIT
Current open_files_limit = 65535 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine

TABLE CACHE
Current table_cache value = 32378 tables
You have a total of 230 tables
You have 278 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 256 M
Of 1092 temp tables, 37% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your
ratio of on disk temp tables.

TABLE SCANS
Current read_buffer_size = 1 M
Current table scan ratio = 28 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 57236
Your table locking seems to be fine

英文看不大懂。先貼出來。大家研究。
《解決方案》

厄。。。。其實你如果系統資源不緊缺這玩意根本不必去管他

等待其他大大來研究,反正我的習慣就是12小時重啟所有服務一次,其他不管。

其他的監控交給數據中心,出了downtime5分鐘內他們會給我重啟相關的服務,然後發SMS給我。

目前國內數據中心還沒聽過這種服務,nice:mrgreen:






國內的破爛數據中心連SLA都不肯給,想知道哪家數據中心肯簽SLA的。

KVM啊KVM,你是我心中的痛,APC也滅有聽過有附帶的。

[ 本帖最後由 wigeboy 於 2007-7-14 15:05 編輯 ]
《解決方案》

我現在最吐血是這樣的情況:
PID       USER        PR    NI  VIRT    RES     SHR   S    %CPU   %MEM    TIME+  COMMAND                                                               
27213  daemon    16     0  121m   18m    12m    S      0.3     0.9       0:01.33    httpd                                                                  
30698   squid       15     0  6940    5192   1484   S      0.3    0.3       0:00.33    squid   

看到apache占的內存了嗎?誇張吧。極慢。很不穩定。
《解決方案》

原帖由 wigeboy 於 2007-7-14 14:52 發表 http://bbs.chinaunix.net/images/common/back.gif
厄。。。。其實你如果系統資源不緊缺這玩意根本不必去管他

等待其他大大來研究,反正我的習慣就是12小時重啟所有服務一次,其他不管。

其他的監控交給數據中心,出了downtime5分鐘內他們會給我重啟相關的 ...


我看了你的數據,感覺比我好不了多少。能給我看看你的站,讓我感受一下實際的速度嗎?謝謝。
《解決方案》

幾個站點都是客戶的,有協議,所以嘛,給你一個測試用的
http://lolo.ipegg.com/index.php

伺服器在德州「大拉屎」SL數據中心
敬上~



PS.網監叔叔別GFW我的這個,叩首無限中,我是良民

[ 本帖最後由 wigeboy 於 2007-7-14 21:06 編輯 ]
《解決方案》

挖。美國站點都比我快。。。我真可憐啊。

[火星人 ] 請問這樣的是否正常?apache吃內存那麼大已經有794次圍觀

http://coctec.com/docs/service/show-post-37440.html