我正在尝试测试,为此,我需要将一个EC2实例推到一个触发点(例如,80%以上的CPU数分钟以上)将导致另一个实例被引导。
我发现的问题是CPU不能超过50%。
我使用的是Nginx,我已经将worker_connections的数量从1024调整到了更大的数字。我把worker_processes设置为auto。另外,fastcgi_params被设置为:
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_max_temp_file_size 0;
fastcgi_intercept_errors off;我使用dynamic an设置了php-fpm,但我也将这些数字调整得更多,没有任何实际差别:
pm.max_children = 50
pm.start_servers = 3
pm.min_spare_servers = 3
pm.max_spare_servers = 50我正在进行围攻,我可以在30秒内持续获得1000个并发连接,有大约3500个回复,100% (没有辍学),也没有显示错误。我还运行了3个攻城ec2实例,它们都有1000个并发连接,我发现有时会出现一些套接字错误,但是cpu从来没有超过50%的峰值。我经常发现,结果仍然是大约3500个答复,只是分布在3台服务器上(这样每个服务器的回复就少了)。
我的php慢登录时间为10秒,其中有几个查询,所以我设置了一个更大的数据库(AWS RDS实例--仅为了测试IOPS,这是最大的可能),这一点也没有什么区别。我还安装了一个更大的EC2实例,看看会发生什么,cpu将超过50%。
最后,这是my /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
# Disable netfilter on bridges.
# net.bridge.bridge-nf-call-ip6tables = 0
# net.bridge.bridge-nf-call-iptables = 0
# net.bridge.bridge-nf-call-arptables = 0
# Controls the default maxmimum size of a mesage queue
kernel.msgmnb = 65536
# Controls the maximum size of a message, in bytes
kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296
# Adam Added Below
kernel.pid_max = 262144
net.ipv4.tcp_window_scaling = 1
vm.max_map_count = 262144
# Do less swapping
fs.file-max = 2097152
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
### GENERAL NETWORK SECURITY OPTIONS ###
# Number of times SYNACKs for passive TCP connection.
net.ipv4.tcp_synack_retries = 2
# Allowed local port range
#net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.ip_local_port_range = 2000 65535
# Protect Against TCP Time-Wait
net.ipv4.tcp_rfc1337 = 1
# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 15
# Decrease the time default value for connections to keep alive
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15
### TUNING NETWORK PERFORMANCE ###
# Default Socket Receive Buffer
net.core.rmem_default = 31457280
# Maximum Socket Receive Buffer
net.core.rmem_max = 12582912
# Default Socket Send Buffer
net.core.wmem_default = 31457280
# Maximum Socket Send Buffer
net.core.wmem_max = 12582912
# Maximum Number of Packets
net.core.netdev_max_backlog = 30000
# Increase the maximum total buffer-space allocatable
# This is measured in units of pages (4096 bytes)
net.ipv4.tcp_mem = 65536 131072 262144
net.ipv4.udp_mem = 65536 131072 262144
# Increase the read-buffer space allocatable
net.ipv4.tcp_rmem = 8192 87380 16777216
net.ipv4.udp_rmem_min = 16384
net.core.rmem_default = 131072
net.core.rmem_max = 16777216
# Increase the write-buffer-space allocatable
net.ipv4.tcp_wmem = 8192 65536 16777216
net.ipv4.udp_wmem_min = 16384
net.core.wmem_default = 131072
net.core.wmem_max = 16777216
# Increase number of incoming connections
net.core.somaxconn = 32768
# Increase number of incoming connections backlog
net.core.netdev_max_backlog = 65536
# Increase the maximum amount of option memory buffers
net.core.optmem_max = 25165824
# Increase the tcp-time-wait buckets pool size to prevent simple DOS attacks
net.ipv4.tcp_max_tw_buckets = 1440000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1*是否有可能将服务器的cpu使用率限制在50%左右?(内存仅为25%左右的使用量)。我从来没有把cpu调到55%。
我希望能够将服务器推到90%以上,然后再启动另一个EC2实例。这样我才能从服务器那里得到我的钱。
任何关于为什么我会有这个限制以及我可以尝试什么的建议。
谢谢你
发布于 2014-01-25 04:27:06
如果您只想增加服务器负载以触发自动规模,请运行以下命令:
loadGen() { dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null & }; loadGen; read; killall dd为了产生更多的负载(在多核机器上),只需在管道之间添加更多的表达式:
loadGen() { dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null & }; loadGen; read; killall dd它就能完成任务。
[]s
奥罗
发布于 2015-04-28 07:15:28
使用压力命令
Stress -c 1-c标志用于cpu编号。
https://stackoverflow.com/questions/20931223
复制相似问题