避免不完全的云原生(六):为什么你可能不需要弹性伸缩?

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic"},{"type":"color","attrs":{"color":"#333333","name":"user"}},{"type":"strong"}],"text":"本文最初发布于The Startup博客,经原作者授权由InfoQ中文站翻译并分享。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"云原生开发最常见的其中一个特性是弹性伸缩。许多公司告诉我们,他们认为弹性伸缩是他们的团队评估云平台的关键需求。然而,我们很少听到这些团队告诉我们,他们为什么需要弹性伸缩。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"事实上,我们甚至可以说弹性伸缩是“在云上”的标志之一。所有云平台都提供某种弹性伸缩支持。不管是Kubernetes中的"},{"type":"link","attrs":{"href":"https:\/\/kubernetes.io\/docs\/tasks\/run-application\/horizontal-pod-autoscale\/","title":null,"type":null},"content":[{"type":"text","text":"Horizontal Pod Autoscalers"}]},{"type":"text","text":"(根据观察到的CPU利用率自动扩展Pods的数量),还是像"},{"type":"link","attrs":{"href":"https:\/\/aws.amazon.com\/autoscaling\/","title":null,"type":null},"content":[{"type":"text","text":"AWS Autoscaling"}]},{"type":"text","text":"(它会自动缩放EC2实例、Dynamo DB表和许多其他资源类型)这样的供应商特性,通常,弹性伸缩都被视为最想要的云特性。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果你是一家全新的初创公司,正在构建一个新的B2C应用程序,那么弹性伸缩可能至关重要,因为你无法预测你的业务何时会突然腾飞。但大型企业不是初创公司。它们有现有的客户群,而且它们的使用模式在很大程度上是已知的。相反,在大多数企业中,我们看到,公司是将所有不同的工作负载作为一个整体来运行,这些工作负载大致可以分为以下几类:"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"最大的一类是"},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}},{"type":"strong"}],"text":"静态负载"},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":",它是可预测的、不变的负载;这可能占所有应用程序的65%。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"第二大类是"},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}},{"type":"strong"}],"text":"计划内的伸缩"},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"(季节性、批量处理或计划内的活动)——可能占所有应用程序的35%。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"剩下的就是"},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}},{"type":"strong"}],"text":"计划外的伸缩"},{"type":"text","marks":[{"type":"color","attrs":{"color":"#494949","name":"user"}}],"text":"(不可预测的负载);剩下的可能非常少——在许多企业,这样的应用程序可能只有5%。"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"下图展示了这个划分(取自一个真实的客户,仅用于说明这种情况):"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/3f\/3f1c2eceea7fbf6da09363eb0a4e6079.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":"各种伸缩情况的占比"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"问题是,许多团队在构建他们的应用程序时,都将其当成是这5%的一部分,而实际上,只有很少的应用程序属于这5%,这5%总是受到计划外负载的影响。现在,这并不是一个新问题。在相对更传统的应用程序环境中,常见的方法是准备远超需要的基础设施,“以防万一”。显然,这是一种浪费,也是团队想要迁移到云的原因之一。然而,理想的云原生方法假定每个功能都部署成可无限扩展的。然而,对于我们与之合作的那类大型企业,更好的方法是设法识别这5%的功能,将它们从庞大的单体中分离出来,并以云原生的方式构建它们(例如,它们可能是Strangler模式的早期候选对象)。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"因此,假设所有的云原生程序都必须具有弹性和无限的可伸缩性,通常是一种误导——相反,对于95%的企业应用程序来说,更重要的是"},{"type":"text","marks":[{"type":"italic"}],"text":"弹性"},{"type":"text","text":"而不是弹性伸缩。反之,如果我们需要的是"},{"type":"text","marks":[{"type":"strong"}],"text":"横向稳定性"},{"type":"text","text":"(这是实现横向伸缩的必要条件),那么,这些程序就是那5%确实需要横向稳定性的。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"因此,换句话说,如果一个节点或实例丢失、替换或重启,程序应该可以继续稳定地运行,而服务不会中断——与突然需要额外增加节点的扩展相比,这要常见得多。现在我们发现,关键的云原生要素(如松耦合、不使用共享数据库以及仅通过HTTP和消息传递系统等标准的、可伸缩的协议进行进程间通信)是实现这一目标的好方法。因此,以"},{"type":"link","attrs":{"href":"https:\/\/medium.com\/swlh\/what-does-cloud-native-really-mean-1b10ed003aa9","title":null,"type":null},"content":[{"type":"text","text":"云原生方式"}]},{"type":"text","text":"编写应用程序仍然是正确的做法,但原因可能和你想的不同。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"而且,对于许多企业来说,弹性伸缩都是一种反模式。例如,当我们与一家银行谈论弹性软件许可模型时,我们被告知,鉴于他们进行应用程序成本规划的方式,对于新项目的业务案例,他们实际上需要预先确定软件成本。遗憾的是,我们合作的很多企业都是如此。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"一个我们会反复听说的可怕的故事(太经常了,我们都希望它是虚构的,但不幸的是我们见证了不只一个这样的例子)是,一个团队新部署了一个具备自动伸缩能力的云原生应用程序,第一个月因为自动伸缩而产生了一个巨额的云提供商账单,这不是因为客户使用率高,而是因为在测试中未遇到的意外错误导致在正常负载下CPU利用率反常升高。在成本模型和财务规划赶上技术发展的步伐之前,你最好以云原生的方式构建应用程序,但部署的时候要么固定资源数量,要么采用有资源限制的自动伸缩设置。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"查看英文原文:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/medium.com\/swlh\/a-cloud-native-coda-why-you-probably-dont-need-elastic-scaling-46b9315df635","title":null,"type":null},"content":[{"type":"text","text":"A Cloud-Native Coda: Why You (probably) Don’t Need Elastic Scaling"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"延伸阅读:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/www.infoq.cn\/article\/qff32QZ7iTN5N0MGhq5M","title":"xxx","type":null},"content":[{"type":"text","text":"避免不完全的云原生(五):目标和收益"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/www.infoq.cn\/article\/Yc8fCIyvIwmBahZ1TPwy","title":"xxx","type":null},"content":[{"type":"text","text":"避免不完全的云原生(四):技术和基础设施角度"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/www.infoq.cn\/article\/LmUVC2HHNPD5lHSzETUa","title":"xxx","type":null},"content":[{"type":"text","text":"避免不完全的云原生(三):架构和设计角度"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/www.infoq.cn\/article\/Qj0SqAEDZZyVOPyhyTXY","title":"","type":null},"content":[{"type":"text","text":"避免不完全的云原生(二):人员和流程要素"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/www.infoq.cn\/article\/PfHdeTgybyC47SpAB2fo","title":"","type":null},"content":[{"type":"text","text":"避免不完全的云原生(一):云原生到底意味着什么?"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/www.infoq.cn\/article\/LIRjAI0mhsClCooPtzLw","title":"","type":null},"content":[{"type":"text","text":"避免不完全的云原生"}]}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章