我正在尝试设置一个带有 ELB 和 4 个 EC2 m1.large 的环境,运行 Apache 2 从另一个 EC2 m1.small NFS v3 服务器读取。
我正在使用 Apache Benchmark 来测量每秒请求数的性能,命令如下:
ab -k -n100 -c1 http://localhost/index.html
我正在使用 -o noatime,_netdev 安装 NFS 共享
这些实例发生在北加利福尼亚州。
west-1a 有 2 个 Web 服务器和 NFS 服务器。west-1c 有 2 个 Web 服务器。
每当我运行 ab 并从本地 EBS 卷读取文件时,我都会得到一致的结果,但是当我运行它并从 NFS 共享读取时,当我按顺序执行测试时,结果会相差 100% 以上:
for i in $(seq 100); do ab -k -n 100 -c 1 http://localhost/index.html | grep -i "requests per second" ; done
示例输出:
Requests per second: 0.36 [#/sec] (mean)
Requests per second: 2.39 [#/sec] (mean)
Requests per second: 117.12 [#/sec] (mean)
Requests per second: 128.13 [#/sec] (mean)
Requests per second: 349.67 [#/sec] (mean)
Requests per second: 161.31 [#/sec] (mean)
Requests per second: 87.54 [#/sec] (mean)
Requests per second: 132.84 [#/sec] (mean)
Requests per second: 226.37 [#/sec] (mean)
Requests per second: 258.42 [#/sec] (mean)
Requests per second: 258.02 [#/sec] (mean)
Requests per second: 272.02 [#/sec] (mean)
Requests per second: 211.56 [#/sec] (mean)
Requests per second: 180.66 [#/sec] (mean)
Requests per second: 209.89 [#/sec] (mean)
Requests per second: 0.37 [#/sec] (mean)
Requests per second: 20.62 [#/sec] (mean)
Requests per second: 38.24 [#/sec] (mean)
Requests per second: 37.95 [#/sec] (mean)
Requests per second: 91.70 [#/sec] (mean)
Requests per second: 119.31 [#/sec] (mean)
Requests per second: 112.17 [#/sec] (mean)
Requests per second: 118.26 [#/sec] (mean)
Requests per second: 119.06 [#/sec] (mean)
Requests per second: 69.67 [#/sec] (mean)
Requests per second: 117.91 [#/sec] (mean)
Requests per second: 118.93 [#/sec] (mean)
Requests per second: 119.10 [#/sec] (mean)
Requests per second: 120.92 [#/sec] (mean)
Requests per second: 121.33 [#/sec] (mean)
Requests per second: 1.42 [#/sec] (mean)
Requests per second: 106.74 [#/sec] (mean)
Requests per second: 401.16 [#/sec] (mean)
Requests per second: 404.73 [#/sec] (mean)
Requests per second: 406.82 [#/sec] (mean)
Requests per second: 417.38 [#/sec] (mean)
Requests per second: 412.92 [#/sec] (mean)
Requests per second: 420.86 [#/sec] (mean)
Requests per second: 419.59 [#/sec] (mean)
Requests per second: 415.37 [#/sec] (mean)
Requests per second: 388.77 [#/sec] (mean)
Requests per second: 413.89 [#/sec] (mean)
Requests per second: 409.92 [#/sec] (mean)
Requests per second: 416.84 [#/sec] (mean)
Requests per second: 11.53 [#/sec] (mean)
Requests per second: 38.46 [#/sec] (mean)
Requests per second: 70.85 [#/sec] (mean)
Requests per second: 71.28 [#/sec] (mean)
Requests per second: 60.33 [#/sec] (mean)
Requests per second: 55.83 [#/sec] (mean)
Requests per second: 41.74 [#/sec] (mean)
Requests per second: 46.33 [#/sec] (mean)
Requests per second: 75.05 [#/sec] (mean)
Requests per second: 95.06 [#/sec] (mean)
Requests per second: 96.73 [#/sec] (mean)
Requests per second: 97.15 [#/sec] (mean)
Requests per second: 96.70 [#/sec] (mean)
Requests per second: 57.88 [#/sec] (mean)
我的问题是:这可能与 AWS 网络有关吗?是否可以进行任何调整以获得更一致的结果?我尝试将 NFS 服务器移动到另一个 AZ,但这并没有改变不一致的因素。
PS:所有网络服务器都发生这种情况。
答案1
因此,关于亚马逊的网络存储,有很多事情需要考虑。因此,必须将这个问题分成几个部分。您可能想看看互联网SCSI作为 NFS 的替代方案,因为众所周知它存在此类问题,但我会尽力提供帮助。
因此,首先,如果您为此 NFS 服务器实例使用 elb,那么它已经是网络存储。我再说一遍,换一种说法,您的网络存储具有网络存储。为了使事情变得更加复杂,每个 AWS 都会根据实例的大小划分网络(以及自其网络以来的 ebs 流量),因此使用 M1 small,您会获得非常小的网络性能,他们将其标记为“低的“
现在,您还需要跟踪的下一件事是每台 M1.large 机器上的缓存。由于它不是本地磁盘,服务器不知道驱动器上的文件,因此它不会将文件缓存在本地机器的内存中,因此每个 Web 请求都会发送到 m1.small 并获取数据,这需要时间,您可能需要启用缓存但您的里程可能会因代码部署而有很大差异。
我建议你最后检查一下你的 Apache 设置,看看是否可以做得更好,”25 个 Apache 性能调优技巧“,也许玩MPM 工作者和MPM 预分叉
PS 目前您的 m1.small 有 1.7gb 内存,因此请注意,它会尝试将来自磁盘的项目缓存在内存中,我不确定您的网站有多大,但需要记住这一点。
我猜你将“-c”设置为 1 的原因是因为你在双核服务器上运行它,尝试在另一台机器上运行它,并尝试将其设置为 10 或更大的数字,如果这不起作用,请将其全部放在 ELB 下,然后获取另一台机器并打开大量线程,elb 上有一个预热期,请注意