Apache APISIX 在 Amazon Graviton3 上的安装和性能测试

亚马逊云科技
0
0
{"value":"亚马逊云科技在 2022 年 5 月底正式推出基于 **Amazon Graviton3** 处理器的计算优化型实例C7g[1]。\n\n与 Amazon Graviton2 处理器相比,基于领先的 **DDR5 内存技术**,Graviton3 处理器可提供高达 **25%** 的性能提升、高达 2 倍的浮点性能以及 50% 的内存访问速度;在性能与同类 EC2 实例相同的情况下,Graviton3 还可减少 60% 的能源。\n\n那么实际数据会怎样呢?让我们以网络 IO 密集型的 API 网关为例,来看看 Graviton3 的表现如何。在这里我们使用 Apache APISIX 在 Graviton2 (C6g) 和 Graviton3 (C7g) 两种服务器环境下进行性能对比测试。\n\n**Apache APISIX 是一个云原生、高性能、可扩展的 API 网关。**基于 **NGNIX+LuaJIT** 和 **etcd** 来实现,和传统 API 网关相比,APISIX 具备**动态路由和插件热加载**的特点,特别适合云原生架构下的 API 管理。\n\n![image.png](https://dev-media.amazoncloud.cn/3bf3844be7d74555a08389c7602085f6_image.png)\n\n#### **准备:安装部署**\n\n在进行测试前,需要准备一台搭载 ARM64 芯片的服务器,这里我们选用了现在只有这个型号才搭载 Amazon Graviton3),操作系统选择了 **Ubuntu 20.04**。\n\n![image.png](https://dev-media.amazoncloud.cn/56365706432e4fa480a737efddb6a016_image.png)\n\n#### **同时安装 Docker。**\n\nsudo apt-get update && sudo apt-get install docker.io\n\n目前,APISIX 已经发布了最新版本的 **ARM64 镜像**,可以使用 **Docker** 方式进行一键部署。具体过程可参考下方:\n**1. 启动 etcd**\n```\\nsudo docker run -d \\\\\\n\\n--name etcd -p 2379:2379 -e ETCD_UNSUPPORTED_ARCH=arm64 \\\\\\n\\n-e ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 \\\\\\n\\n-e ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379 \\\\\\n\\nrancher/coreos-etcd:v3.4.16-arm64\\n```\n**2. 启动 APISIX**\n```\\nsudo docker run --net=host -d apache/apisix:2.14.1-alpine\\n```\n**3. 注册路由**\n```\\ncurl \\"http://127.0.0.1:9080/apisix/admin/routes/1\\" \\\\\\n-H \\"X-API-KEY: edd1c9f034335f136f87ad84b625c8f1\\" -X PUT -d '\\n{\\n \\"uri\\": \\"/anything/*\\",\\n\\"upstream\\": {\\n \\"type\\": \\"roundrobin\\",\\n \\"nodes\\": {\\n\\"httpbin.org:80\\": 1\\n }\\n }\\n\\n}'\\n```\n**4. 访问测试**\n```\\ncurl -i http://127.0.0.1:9080/anything/das\\nHTTP/1.1 200 OK\\n.....\\n```\n ### **Graviton2 和 Graviton3 的性能对比**\n\n根据前文的操作,基于官方脚本 [2] 成功完成了 APISIX 在 Amazon Graviton3 处理器上安装和兼容性测试。下面让我们来看看 APISIX 在 Graviton2 (C6g) 和 Graviton3 (C7g) 上的性能表现。\n\n为了方便测试,本示例中 APISIX 只开启了一个 Worker,下面的性能测试数据都是在**单核 CPU** 上运行的。\n\n#### **场景一:单个上游**\n该场景下使用单个上游(不包含任何插件),主要测试 APISIX 在纯代理回源模式下的性能表现。在本地环境中进行测试:\n```\\n# apisix: 1 worker + 1 upstream + no plugin\\n#注册路由\\ncurl http://127.0.0.1:9080/apisix/admin/routes/1 \\\\\\n-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '\\n{ \\n \\"uri\\": \\"/hello\\",\\n \\"plugins\\": {\\n },\\n \\"upstream\\": {\\n \\"type\\": \\"roundrobin\\",\\n \\"nodes\\": {\\n \\"127.0.0.1:1980\\":1\\n }\\n }\\n}'\\n```\n#### **场景二:单上游+多插件** \n另一场景则使用单上游与多插件配合,在这里使用了两个插件。主要测试 APISIX 在开启 **limit-count** 和 **prometheus** 两个核心消耗性能插件时的性能表现。\n```\\n# apisix: 1 worker + 1 upstream + 2 plugins (limit-count + prometheus)\\n#注册路由\\ncurl http://127.0.0.1:9080/apisix/admin/routes/1 \\\\\\n-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '\\n{\\n \\"uri\\": \\"/hello\\",\\n \\"plugins\\": {\\n \\"limit-count\\": {\\n \\"count\\": 2000000000000,\\n \\"time_window\\": 60,\\n \\"rejected_code\\": 503,\\n \\"key\\": \\"remote_addr\\"\\n },\\n \\"prometheus\\": {}\\n },\\n \\"upstream\\": {\\n \\"type\\": \\"roundrobin\\",\\n \\"nodes\\": {\\n \\"127.0.0.1:1980\\":1\\n }\\n }\\n}'\\n```\n#### **数据对比**\n在上述两种场景下,分别从请求处理和延迟时间两个层面进行了相关测试与对比。结果如下:\n##### **1. QPS 对比**\n![image.png](https://dev-media.amazoncloud.cn/e657045469cf45f3b63a25d166eb3013_image.png)\n##### **2. Latency 对比**\n![image.png](https://dev-media.amazoncloud.cn/d3b7b65574f546119c462db2c67ba9d6_image.png)\n![image.png](https://dev-media.amazoncloud.cn/b4be1e1e4bd24aa3bc047aec012c8b6b_image.png)\n\n从上方数据可以看到,在 API 网关这样 网络 IO 密集型的计算场景下,**Amazon Graviton3 比 Amazon Graviton2 的性能提升了 76%,同时延迟还降低了 38%**。这个数据比开头提到的(25%性能提升)还要优异。\n\n#### **总结**\n本文主要通过使用 Apache APISIX 进行了 Graviton3 与 Graviton2 的性能对比,可以看到在 API 网关 这种**网络 IO 密集型**的计算场景下,**Amazon Graviton3 可谓展示了性能怪兽的属性**。当然,也推荐大家多多进行实践,期待后续更多计算密集型项目的测试数据。\n\n参考资料:\n[1][https://aws.amazon.com/cn/blogs/aws/new-amazon-ec2-c7g-instances-powered-by-aws-graviton3-processors/](https://aws.amazon.com/cn/blogs/aws/new-amazon-ec2-c7g-instances-powered-by-aws-graviton3-processors/)\n[2][https://github.com/apache/apisix/blob/master/benchmark/run.sh](https://github.com/apache/apisix/blob/master/benchmark/run.sh)\n\n#### **关于 Apache APISIX**\nApache APISIX 是一个动态、实时、高性能的开源 API 网关,提供负载均衡、动态上游、灰度发布、服务熔断、身份认证、可观测性等丰富的流量管理功能。\n\n作为 API 网关,Apache APISIX 可以帮助企业快速、安全地处理 API 和微服务流量,可应用于网关、Kubernetes Ingress 和服务网格等场景。目前已被普华永道数据安全团队、腾讯蓝军、平安银河实验室、爱奇艺 SRC 和源堡科技安全团队等专业网络安全机构测试,并得到了高度认可","render":"<p>亚马逊云科技在 2022 年 5 月底正式推出基于 <strong>Amazon Graviton3</strong> 处理器的计算优化型实例C7g[1]。</p>\\n<p>与 Amazon Graviton2 处理器相比,基于领先的 <strong>DDR5 内存技术</strong>,Graviton3 处理器可提供高达 <strong>25%</strong> 的性能提升、高达 2 倍的浮点性能以及 50% 的内存访问速度;在性能与同类 EC2 实例相同的情况下,Graviton3 还可减少 60% 的能源。</p>\\n<p>那么实际数据会怎样呢?让我们以网络 IO 密集型的 API 网关为例,来看看 Graviton3 的表现如何。在这里我们使用 Apache APISIX 在 Graviton2 (C6g) 和 Graviton3 (C7g) 两种服务器环境下进行性能对比测试。</p>\n<p><strong>Apache APISIX 是一个云原生、高性能、可扩展的 API 网关。<strong>基于 <strong>NGNIX+LuaJIT</strong> 和 <strong>etcd</strong> 来实现,和传统 API 网关相比,APISIX 具备</strong>动态路由和插件热加载</strong>的特点,特别适合云原生架构下的 API 管理。</p>\\n<p><img src=\\"https://dev-media.amazoncloud.cn/3bf3844be7d74555a08389c7602085f6_image.png\\" alt=\\"image.png\\" /></p>\n<h4><a id=\\"_10\\"></a><strong>准备:安装部署</strong></h4>\\n<p>在进行测试前,需要准备一台搭载 ARM64 芯片的服务器,这里我们选用了现在只有这个型号才搭载 Amazon Graviton3),操作系统选择了 <strong>Ubuntu 20.04</strong>。</p>\\n<p><img src=\\"https://dev-media.amazoncloud.cn/56365706432e4fa480a737efddb6a016_image.png\\" alt=\\"image.png\\" /></p>\n<h4><a id=\\"_Docker_16\\"></a><strong>同时安装 Docker。</strong></h4>\\n<p>sudo apt-get update &amp;&amp; sudo apt-get install docker.io</p>\n<p>目前,APISIX 已经发布了最新版本的 <strong>ARM64 镜像</strong>,可以使用 <strong>Docker</strong> 方式进行一键部署。具体过程可参考下方:<br />\\n<strong>1. 启动 etcd</strong></p>\\n<pre><code class=\\"lang-\\">sudo docker run -d \\\\\\n\\n--name etcd -p 2379:2379 -e ETCD_UNSUPPORTED_ARCH=arm64 \\\\\\n\\n-e ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 \\\\\\n\\n-e ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379 \\\\\\n\\nrancher/coreos-etcd:v3.4.16-arm64\\n</code></pre>\\n<p><strong>2. 启动 APISIX</strong></p>\\n<pre><code class=\\"lang-\\">sudo docker run --net=host -d apache/apisix:2.14.1-alpine\\n</code></pre>\\n<p><strong>3. 注册路由</strong></p>\\n<pre><code class=\\"lang-\\">curl &quot;http://127.0.0.1:9080/apisix/admin/routes/1&quot; \\\\\\n-H &quot;X-API-KEY: edd1c9f034335f136f87ad84b625c8f1&quot; -X PUT -d '\\n{\\n &quot;uri&quot;: &quot;/anything/*&quot;,\\n&quot;upstream&quot;: {\\n &quot;type&quot;: &quot;roundrobin&quot;,\\n &quot;nodes&quot;: {\\n&quot;httpbin.org:80&quot;: 1\\n }\\n }\\n\\n}'\\n</code></pre>\\n<p><strong>4. 访问测试</strong></p>\\n<pre><code class=\\"lang-\\">curl -i http://127.0.0.1:9080/anything/das\\nHTTP/1.1 200 OK\\n.....\\n</code></pre>\\n<h3><a id=\\"Graviton2___Graviton3__58\\"></a><strong>Graviton2 和 Graviton3 的性能对比</strong></h3>\\n<p>根据前文的操作,基于官方脚本 [2] 成功完成了 APISIX 在 Amazon Graviton3 处理器上安装和兼容性测试。下面让我们来看看 APISIX 在 Graviton2 (C6g) 和 Graviton3 (C7g) 上的性能表现。</p>\n<p>为了方便测试,本示例中 APISIX 只开启了一个 Worker,下面的性能测试数据都是在<strong>单核 CPU</strong> 上运行的。</p>\\n<h4><a id=\\"_64\\"></a><strong>场景一:单个上游</strong></h4>\\n<p>该场景下使用单个上游(不包含任何插件),主要测试 APISIX 在纯代理回源模式下的性能表现。在本地环境中进行测试:</p>\n<pre><code class=\\"lang-\\"># apisix: 1 worker + 1 upstream + no plugin\\n#注册路由\\ncurl http://127.0.0.1:9080/apisix/admin/routes/1 \\\\\\n-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '\\n{ \\n &quot;uri&quot;: &quot;/hello&quot;,\\n &quot;plugins&quot;: {\\n },\\n &quot;upstream&quot;: {\\n &quot;type&quot;: &quot;roundrobin&quot;,\\n &quot;nodes&quot;: {\\n &quot;127.0.0.1:1980&quot;:1\\n }\\n }\\n}'\\n</code></pre>\\n<h4><a id=\\"_83\\"></a><strong>场景二:单上游+多插件</strong></h4>\\n<p>另一场景则使用单上游与多插件配合,在这里使用了两个插件。主要测试 APISIX 在开启 <strong>limit-count</strong> 和 <strong>prometheus</strong> 两个核心消耗性能插件时的性能表现。</p>\\n<pre><code class=\\"lang-\\"># apisix: 1 worker + 1 upstream + 2 plugins (limit-count + prometheus)\\n#注册路由\\ncurl http://127.0.0.1:9080/apisix/admin/routes/1 \\\\\\n-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '\\n{\\n &quot;uri&quot;: &quot;/hello&quot;,\\n &quot;plugins&quot;: {\\n &quot;limit-count&quot;: {\\n &quot;count&quot;: 2000000000000,\\n &quot;time_window&quot;: 60,\\n &quot;rejected_code&quot;: 503,\\n &quot;key&quot;: &quot;remote_addr&quot;\\n },\\n &quot;prometheus&quot;: {}\\n },\\n &quot;upstream&quot;: {\\n &quot;type&quot;: &quot;roundrobin&quot;,\\n &quot;nodes&quot;: {\\n &quot;127.0.0.1:1980&quot;:1\\n }\\n }\\n}'\\n</code></pre>\\n<h4><a id=\\"_109\\"></a><strong>数据对比</strong></h4>\\n<p>在上述两种场景下,分别从请求处理和延迟时间两个层面进行了相关测试与对比。结果如下:</p>\n<h5><a id=\\"1_QPS__111\\"></a><strong>1. QPS 对比</strong></h5>\\n<p><img src=\\"https://dev-media.amazoncloud.cn/e657045469cf45f3b63a25d166eb3013_image.png\\" alt=\\"image.png\\" /></p>\n<h5><a id=\\"2_Latency__113\\"></a><strong>2. Latency 对比</strong></h5>\\n<p><img src=\\"https://dev-media.amazoncloud.cn/d3b7b65574f546119c462db2c67ba9d6_image.png\\" alt=\\"image.png\\" /><br />\\n<img src=\\"https://dev-media.amazoncloud.cn/b4be1e1e4bd24aa3bc047aec012c8b6b_image.png\\" alt=\\"image.png\\" /></p>\n<p>从上方数据可以看到,在 API 网关这样 网络 IO 密集型的计算场景下,<strong>Amazon Graviton3 比 Amazon Graviton2 的性能提升了 76%,同时延迟还降低了 38%</strong>。这个数据比开头提到的(25%性能提升)还要优异。</p>\\n<h4><a id=\\"_119\\"></a><strong>总结</strong></h4>\\n<p>本文主要通过使用 Apache APISIX 进行了 Graviton3 与 Graviton2 的性能对比,可以看到在 API 网关 这种<strong>网络 IO 密集型</strong>的计算场景下,<strong>Amazon Graviton3 可谓展示了性能怪兽的属性</strong>。当然,也推荐大家多多进行实践,期待后续更多计算密集型项目的测试数据。</p>\\n<p>参考资料:<br />\\n[1]<a href=\\"https://aws.amazon.com/cn/blogs/aws/new-amazon-ec2-c7g-instances-powered-by-aws-graviton3-processors/\\" target=\\"_blank\\">https://aws.amazon.com/cn/blogs/aws/new-amazon-ec2-c7g-instances-powered-by-aws-graviton3-processors/</a><br />\\n[2]<a href=\\"https://github.com/apache/apisix/blob/master/benchmark/run.sh\\" target=\\"_blank\\">https://github.com/apache/apisix/blob/master/benchmark/run.sh</a></p>\\n<h4><a id=\\"_Apache_APISIX_126\\"></a><strong>关于 Apache APISIX</strong></h4>\\n<p>Apache APISIX 是一个动态、实时、高性能的开源 API 网关,提供负载均衡、动态上游、灰度发布、服务熔断、身份认证、可观测性等丰富的流量管理功能。</p>\n<p>作为 API 网关,Apache APISIX 可以帮助企业快速、安全地处理 API 和微服务流量,可应用于网关、Kubernetes Ingress 和服务网格等场景。目前已被普华永道数据安全团队、腾讯蓝军、平安银河实验室、爱奇艺 SRC 和源堡科技安全团队等专业网络安全机构测试,并得到了高度认可</p>\n"}
目录
亚马逊云科技解决方案 基于行业客户应用场景及技术领域的解决方案
联系亚马逊云科技专家
亚马逊云科技解决方案
基于行业客户应用场景及技术领域的解决方案
联系专家
0
目录
关闭