LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1409|回复: 13

大流量的网站的配置问题。

[复制链接]
发表于 2006-9-1 14:25:27 | 显示全部楼层 |阅读模式
此服务器主要用于图片文件的发送

APACHE2 中这样配置。
<IfModule prefork.c>
   StartServers         10
   MinSpareServers      10
   MaxSpareServers      20
   ServerLimit          20000
   MaxClients           4000
   MaxRequestsPerChild  0
</IfModule>

在实际应用中 MaxClients 达到 1220 就上不去了。 这时图片显示就会很慢。

主机配置 Intel 志强 2.8G * 2
内存 2GB
硬盘 SCSI 146GB

我观察了 硬盘不是很繁忙。 0.5秒闪一次。
CPU占用不高 0.6% 左右。
内存使用 MB为单位
             total       used       free     shared    buffers     cached
Mem:          2026       1312        713          0         89        850
-/+ buffers/cache:        372       1653
Swap:         4095          0       4095
交换分区 没有派上用场。


网络带宽 光纤100MB  但服务器只用到 20MB左右。

请高人指点 那里会有问题?~
发表于 2006-9-1 16:06:04 | 显示全部楼层
什么系统 ? 交换分区没用到 ?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-9-1 18:49:44 | 显示全部楼层
RHEL AS4 x86  版.

交换分区:我是说有交换分区 但好像没有派上用场。 使用一直是0
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-9-1 18:55:41 | 显示全部楼层
还有。 我曾试过 mpm_worker 但没有一点长进~~
<IfModule worker.c>
    ServerLimit          25
    ThreadLimit         200
    StartServers          3
    MaxClients         2000
    MinSpareThreads      25
    MaxSpareThreads     200
    ThreadsPerChild     100
    MaxRequestsPerChild   0
</IfModule>

这里可以肯定的是网络没有问题. 曾用过 视频服务. 带宽可以占用到 85MB左右.
但就是图片文件不行.

硬盘文件系统是 ext3

求高手救命!
回复 支持 反对

使用道具 举报

发表于 2006-9-1 20:56:03 | 显示全部楼层
###编译apache在configure之前修改这个
./src/include/httpd.h = APACHE_HARD_SERVER_LIMIT=2560###(差不多了)
###httpd.conf
Timeout 180
KeepAlive On
KeepAliveTimeout 3
MinSpareServers 20
MaxSpareServers 50
StartServers 128
MaxClients 2560
MaxRequestsPerChild 4096
###配置/etc/sysctl.conf
回复 支持 反对

使用道具 举报

发表于 2006-9-2 06:13:53 | 显示全部楼层
通过top命令计算出每个Apache进程平均消耗的内存,然后 分配给 apache

用apache 2.2 的 缓存 命令
CacheDefaultExpire 86400
MCacheSize 11111
MCacheMinObjectSize 2222
MCacheMaxObjectSize 333
MCacheMaxObjectCount 444
注意 值是我乱写的 ,真正的值根据实际情况调整。

或者 用 squid 作 服务器缓存

手册上还说,这两个只要设置成1样
ServerLimit 20000
MaxClients 4000

ServerLimit 指令
对于preforkMPM,只有在你需要将MaxClients设置成高于默认值256的时候才需要使用这个指令。要将此指令的值保持和MaxClients一样
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-9-2 16:55:31 | 显示全部楼层
首先感谢两位。

两位所说的方法我也试过了 不过似乎没有什么好转,
我检查了服务器的网络方面。问题应该出在网络方面。 之前出了一个问题 就是 httpd 一开启 vsftpd 就无法建立连接。 后来换了 ProFTPD 可以连接。 之后我又测试网络的响应时间 只要 httpd 一开启 网络响应就会有 50倍左右的差距~!
回复 支持 反对

使用道具 举报

发表于 2006-9-2 17:48:15 | 显示全部楼层
用lighttpd
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-9-2 19:45:35 | 显示全部楼层
用了 lighttpd 感觉比 apache 要好一点。 不过效果并没有达到预期的那样。
个人感觉 lighttpd 优点:不会生成大量的进程 缺点:太占用CPU
谢谢 wsgtrsys
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-9-2 19:52:37 | 显示全部楼层
lighttpd 的问题来了。。。 为什么他会自动关掉?

log 中内容:
2006-09-02 19:26:45: (log.c.75) server started
2006-09-02 19:32:51: (server.c.1126) NOTE: a request for /wy/0701/25.jpg timed out after writing 40656 bytes. We waited 360 seconds. If this a problem increase server.max-write-idle
2006-09-02 19:32:53: (server.c.1126) NOTE: a request for /0801/30.jpg timed out after writing 87120 bytes. We waited 360 seconds. If this a problem increase server.max-write-idle
2006-09-02 19:33:01: (server.c.1126) NOTE: a request for /0326/18.jpg timed out after writing 29040 bytes. We waited 360 seconds. If this a problem increase server.max-write-idle
2006-09-02 19:33:49: (server.c.1126) NOTE: a request for /0722/37.jpg timed out after writing 24480 bytes. We waited 360 seconds. If this a problem increase server.max-write-idle
2006-09-02 19:34:13: (server.c.1126) NOTE: a request for /0902/16.jpg timed out after writing 73216 bytes. We waited 360 seconds. If this a problem increase server.max-write-idle
2006-09-02 19:35:24: (server.c.1126) NOTE: a request for /0526/7.jpg timed out after writing 144540 bytes. We waited 360 seconds. If this a problem increase server.max-write-idle
2006-09-02 19:35:30: (server.c.1126) NOTE: a request for /0723/16.jpg timed out after writing 41760 bytes. We waited 360 seconds. If this a problem increase server.max-write-idle
2006-09-02 19:36:11: (server.c.1126) NOTE: a request for /0825/43.jpg timed out after writing 43560 bytes. We waited 360 seconds. If this a problem increase server.max-write-idle
2006-09-02 19:36:17: (server.c.1126) NOTE: a request for /0326/12.jpg timed out after writing 64800 bytes. We waited 360 seconds. If this a problem increase server.max-write-idle
2006-09-02 19:36:35: (server.c.1126) NOTE: a request for /0322/1.jpg timed out after writing 18980 bytes. We waited 360 seconds. If this a problem increase server.max-write-idle
2006-09-02 19:37:33: (response.c.506) file not found ... or so:  Too many open files /0720/27.jpg ->
2006-09-02 19:37:33: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:33: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:33: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:33: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:33: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:33: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:33: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:33: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:33: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:34: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:34: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:34: (response.c.506) file not found ... or so:  Too many open files /0830/17.jpg ->
2006-09-02 19:37:35: (response.c.506) file not found ... or so:  Too many open files /0529/7.jpg ->
2006-09-02 19:37:35: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:35: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:35: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:35: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:35: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:35: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:35: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:35: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:35: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:35: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:35: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:38: (response.c.506) file not found ... or so:  Too many open files /wy/0624/60.jpg ->
2006-09-02 19:37:38: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:38: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:38: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:38: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:38: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:38: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:38: (response.c.506) file not found ... or so:  Too many open files /wy/0624/5.jpg ->
2006-09-02 19:37:38: (response.c.506) file not found ... or so:  Too many open files /wy/0715/43.jpg ->
2006-09-02 19:37:38: (response.c.506) file not found ... or so:  Too many open files /0322/4.jpg ->
2006-09-02 19:37:38: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:38: (response.c.506) file not found ... or so:  Too many open files /0722/33.jpg ->
2006-09-02 19:37:38: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:38: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:38: (connections.c.1238) accept failed: Too many open files 24
2006-09-02 19:37:38: (response.c.506) file not found ... or so:  Too many open files /0901/25.jpg ->
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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