是不是我的Q2A网站问题?
于是对两个静态页面,z-dns-23与red hat 5测试:
webbench对nginx server 做2048并发测试(2X1024的理论最大值),修改了两个静态页面服务器的httpd.conf,将<prework>下的 StartServers
5
MinSpareServers
MaxSpareServers ServerLimit
MaxClients MaxRequestsPerChild 参数更改 结果:
nginx端:
静态页面服务器:
后台error_log无错误,nginx的error_log出现:upstream time out 110......
解决:nginx.conf内
server {
listen 80;
server_name localhost;
large_client_header_buffers 4 16k;
client_max_body_size 30m;
client_body_buffer_size 128k;
proxy_connect_timeout 300;
proxy_read_timeout 300;
proxy_send_timeout 300;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
.......
}
之后又出现worker_connections not enough 问题,
解决:提高worker_connections ,要先提高最大打开文件数:
http://blog.youkuaiyun.com/ssyan/article/details/6549094
当前设置最大打开文件数可以通过如下命令查看。
ulimit -n
这个数字说明了一个普通用户能够在一个单独会话中所能打开最大的文件数目。
注意。如果是root,以下操作不能使ulimit -n的输出增加。因为用户root用户不受这个ulimit限制。只有普通用户才会受这个限制。
为了提高最大打开文件数到默认值1024以上, 需要在系统上修改2个地方。
在这个案例中, 我们将最大打开文件数增加到2048。 所有的步骤需要root用户操作。 普通用户需要重新登录才能使设置生效。
1. 按照最大打开文件数量的需求设置系统, 并且通过检查/proc/sys/fs/file-max文件来确认最大打开文件数已经被正确设置。
# cat /proc/sys/fs/file-max
如果设置值太小, 修改文件/etc/sysctl.conf的变量到合适的值。 这样会在每次重启之后生效。 如果设置值够大,6553600够了,跳过下步。
# echo 2048 > /proc/sys/fs/file-max编辑文件/etc/sysctl.conf,插入下行。
fs.file-max = 2048#这导致我开不了图形界面,之一有提示audit: audit_backlog=326 > audit_backlog_limit=320。。。。。。。改好错误后赶紧,take snapshot.....
2. 在/etc/security/limits.conf文件中设置最大打开文件数, 下面是一行提示:
#<domain> <type> <item> <value>添加如下这行。
* - nofile 2048
这行设置了每个用户的默认打开文件数为2048。
注意"nofile"项有两个可能的限制措施。就是<type>项下的hard和soft。
要使修改过得最大打开文件数生效,必须对这两种限制进行设定。
如果使用"-"字符设定<type>, 则hard和soft设定会同时被设定。
硬限制表明soft限制中所能设定的最大值。
soft限制指的是当前系统生效的设置值。
hard限制值可以被普通用户降低。但是不能增加。
soft限制不能设置的比hard限制更高。
只有root用户才能够增加hard限制值。
当增加文件限制描述,可以简单的把当前值双倍。
例子如下, 如果你要提高默认值1024, 最好提高到2048, 如果还要继续增加, 就需要设置成4096。
3.Add the following line to the /etc/pam.d/login and /etc/pam.d/xdm file, if it does not already exist:
session required /lib/security/pam_limits.so
4. 重启reboot
然后再event上添加,worker_rlimit_nofile 2048;
将worker_connections 2048;
还是出出现socket() failed ,open too many files
继续改到4096.。。。
出现error: recv() failed connection reset by peer while reading response header from upstream。。。。。。
服务器的并发连接数超过了其承载量,服务器会将其中一些连接Down掉,我觉得这个解释正确,因为我只是静态页面的测试
测试完静态页面,再试试Q2A网站吧。
在csdn上问的问题回答如下:
linux设置最大连接数
[root@localhost ~]# vi /etc/security/limits.conf
加入
* soft nofile 1048576
* hard nofile 1048576
vi /etc/sysctl.conf
加入
fs.file-max = 1048576
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_mem = 786432 2097152 3145728
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
/sbin/sysctl -p /etc/sysctl.conf
更改reboot后就没有(110: Connection timed out) while connecting to upstream 错误了
剩下的事就是Q2A网站的配置了,PHP mysql的配置