背景

背景

背景

我在负载均衡器后面的 nginx 服务器上有两个运行 laravel 应用程序的 ec2 实例。我们想出了一个绝妙的主意,使用 apache ab 对实例进行压力测试,如下所示:

 ab -c 350 -n 20000  -H "Accept:application/x.toters.v1+json" http://staging-load-balancer-2088007710.eu-west-1.elb.amazonaws.com/api?store_ids[]=223%26lat=33.883666%26lon=35.533966
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking staging-load-balancer-2088007710.eu-west-1.elb.amazonaws.com (be patient)
Completed 2000 requests
Completed 4000 requests
Completed 6000 requests
Completed 8000 requests
Completed 10000 requests
Completed 12000 requests
Completed 14000 requests
apr_socket_recv: Connection reset by peer (104)
Total of 15912 requests completed

因此,看起来它就像是在最后放弃了,再次运行压力测试就立即失败了。

问题

问题是,现在如果我们尝试访问实例(绕过负载均衡器来隔离问题),它就会失败,请参阅邮递员输出:

在此处输入图片描述

nginx 错误日志显示:

2017/11/28 13:27:41 [alert] 321#321: *120606 open socket #16 left in connection 163
2017/11/28 13:27:41 [alert] 321#321: *120629 open socket #34 left in connection 188
2017/11/28 13:27:41 [alert] 321#321: *120622 open socket #9 left in connection 213
2017/11/28 13:27:41 [alert] 321#321: *120628 open socket #25 left in connection 217
2017/11/28 13:27:41 [alert] 321#321: *120605 open socket #15 left in connection 244
2017/11/28 13:27:41 [alert] 321#321: *120614 open socket #41 left in connection 245
2017/11/28 13:27:41 [alert] 321#321: *120631 open socket #24 left in connection 255
2017/11/28 13:27:41 [alert] 321#321: *120616 open socket #23 left in connection 258
2017/11/28 13:27:41 [alert] 321#321: *120615 open socket #42 left in connection 269
2017/11/28 13:27:41 [alert] 321#321: aborting

重新启动 nginx 无法解决问题,关闭然后打开 nginx 也无法解决问题。有什么想法吗?

答案1

在收集到您想要保留的测试数据后,耗尽并销毁实例并创建新的实例。

有了已知的适用于横向扩展应用的良好模板,几乎不需要修复单个主机。除非你认为其配置存在问题,或者你想花时间学习。

相关内容