从10次宕机事件中,我学到5个重要的经验

{"type":"doc","content":[{"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":"从这些反复出现的模式中,我们提取出了一些工程团队准备采纳的经验教训,希望你也能从中学到有用的知识并做好准备。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"第1课:循环依赖会破坏你的运维工具"}]},{"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":"但这种健康的习惯也会产生反作用,因为这种行为会造成依赖循环。所谓依赖循环是说,你依赖自己的系统……来修复你的系统。"}]},{"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":"这些循环也会在停机期间带来严重后果。例如,你可能需要身份验证才能访问操作系统,修复身份验证模块……或者监控本来应该正常运行的数据库以获取指标数据,找出数据库出了什么问题。总之就是这样的死循环。"}]},{"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":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"引文"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/episode-1-slack-vs-tgws\/","title":"","type":null},"content":[{"type":"text","text":"第1集"}]},{"type":"text","text":",Slack与TGW:Slack无法访问控制面板来了解他们的系统出了什么问题,因为AWS Transit Gateway需要处于健康状态才能将http流量传输到控制面板上。不幸的是,这个TGW是不健康的。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/monzos-2019-cassandra-outage\/","title":"","type":null},"content":[{"type":"text","text":"第3集"}]},{"type":"text","text":",Monzo的2019年Cassandra宕机:Monzo的生产数据库出现故障,要验证系统访问权限和部署代码才能解决问题,但前者必须使用这个生产数据库。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/kinesis-hits-the-thread-limit\/","title":"","type":null},"content":[{"type":"text","text":"第10集"}]},{"type":"text","text":",Kinesis达到线程限制:AWS无法更新Kinesis相关中断的状态页面,因为状态页面的更新依赖Kinesis。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/salesforce-publishes-a-controversial-postmortem-and-breaks-their-dns\/","title":"","type":null},"content":[{"type":"text","text":"第11集"}]},{"type":"text","text":",Salesforce发布了有争议的事后分析:Salesforce无法更新他们的状态页面,因为他们将其托管在基于Heroku的服务上,并且由于Heroku就是他们所有的,还集成到了他们的基础设施中,所以Heroku的运行状态取决于他们的系统健康状况。"}]}]}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"第2课:愚蠢的自动化"}]},{"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":"大家都对现代公有云及其提供的无数API感到非常兴奋。弹性!编排!所有运维都可以自动化,这样人类就不会被吵醒了!"}]},{"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":"但即使自动化确实是明智的(因为系统需要经常调整,和\/或调整所涉及的经济成本较大),自动化有时也缺乏必要的“恐慌模式”,无法识别参数何时超出正常范围。在这些情况下,自动化应该停止自动化操作并通知运维人员,因为它即将开始做出一些非常不合逻辑的决定了。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"引文"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/episode-1-slack-vs-tgws\/","title":"","type":null},"content":[{"type":"text","text":"第1集"}]},{"type":"text","text":",Slack与TGW:由于出现一个网络问题期间CPU闲置,Slack的自动化操作丢弃了一堆他们“不需要”(旁白:可他们确实需要)的服务器,然后在流量激增时启动了过多的服务器,超出了系统上的文件描述符限制。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/githubs-43-second-network-partition\/","title":"","type":null},"content":[{"type":"text","text":"第6集"}]},{"type":"text","text":",GitHub的43秒网络分区:GitHub的数据库自动化在一次为时43秒的网络分区期间,对一个主数据库进行了记录不完整的跨国提升。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/auth0s-seriously-congested-database\/","title":"","type":null},"content":[{"type":"text","text":"第8集"}]},{"type":"text","text":",Auth0的严重拥塞的数据库:当请求因数据库瓶颈而变慢时,Auth0启动了两倍的前端,结果带来了更大流量,让问题更严重了。"}]}]}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"第3课:现在是2021年,数据库仍然很棘手"}]},{"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":"这个主题的素材非常丰富,我们把它分解成三个子课程:"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"第3a课:生产数据库应该主要是点查询或严格限制的范围"}]},{"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":"为确保这一点,请将你的任意批量查询放在专用的辅助服务器中,或者放在一些OLAP系统(如BigQuery或Snowflake)中。或者转储到CSV和并行grep都可以。不管这些批量查询复杂程度如何,是不是符合你的数据集大小和流程,都请这样做。"}]},{"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":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"引文"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/gitlabs-2017-postgres-outage\/","title":"","type":null},"content":[{"type":"text","text":"第2集"}]},{"type":"text","text":",Gitlab的2017年Postgres停机:非常昂贵的、长时间运行的帐户删除操作被放在了他们的生产数据库上实时运行,导致拥塞和故障。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/auth0-silently-loses-some-indexes\/","title":"","type":null},"content":[{"type":"text","text":"第5集"}]},{"type":"text","text":",Auth0悄悄丢失了一些索引:创建索引时未受监控的失败导致一些查询突然变成扫描,从而大大增加了数据库的负载并最终导致停机。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/auth0s-seriously-congested-database\/","title":"","type":null},"content":[{"type":"text","text":"第8集"}]},{"type":"text","text":",Auth0的严重拥塞的数据库:生产系统上发生的一些特别昂贵的扫描加剧了数据库问题。"}]}]}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"第3b课:避免数据库中的“中间魔法”"}]},{"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":"好选项:使用像MySQL这样的无聊事物并自己处理分片。这会很麻烦,因为你必须在应用层做很多额外工作,但当它崩溃时你可能会知道它是如何运作的。这在10年前可能是正确的想法,但现在看来也不错。"}]},{"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":"更好的选项:只需购买一个更大的服务器并使用一个未分片的MySQL\/PostgreSQL服务器和一个或两个副本。这种办法一直都是好方案,尽可能选择它。"}]},{"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":"可能是2021年后最好的选项:花钱找云服务提供商为你运行数据库,包括所有备份和故障转移等业务。如果你真的喜欢,你甚至可以使用很帅气的数据库,例如CloudSpanner、DynamoDB之类。完全、不透明地依赖第三方在过去是不可想象的,但这可能是2021年最好的办法。这些大公司在这方面做得非常好,毕竟他们做得不好的话,因为你的公司就是依赖他们运营的,估计你们已经完蛋了。缺点是它会让你破费多多,因为这些服务的定价很高。"}]},{"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":"玩火选项:使用一些声称可以自动解决所有扩展和故障转移问题的东西,但你仍然需要做运维工作,而且它的生产环境历史比MySQL之类的东西少得多。当它出错时,很少有人知道如何操作,或充分了解其内部结构以诊断其编排流程的复杂故障模式。我们在这些停机事件中遇到的可能嫌疑人包括MongoDB和Cassandra。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"引文"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/monzos-2019-cassandra-outage\/","title":"","type":null},"content":[{"type":"text","text":"第3集"}]},{"type":"text","text":",Monzo的2019年Cassandra停机:扩展的Cassandra集群有很多难以理解的配置麻烦。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/auth0-silently-loses-some-indexes\/","title":"","type":null},"content":[{"type":"text","text":"第5集"}]},{"type":"text","text":",Auth0悄悄丢失了一些索引:在不降低实时流量的情况下,在mongo中重新同步副本是很难实现的。"}]}]}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"第3c课:重点在于恢复而不是备份,还要注意它们需要多长时间"}]},{"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":"让我们来看看有哪些情况:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"备份没有运行……这怎么可能,我明明正在监控它啊!"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"备份在S3中运行并生成了一个文件。这可能要看你的备份验证到了什么地步。可能的情况是该文件为空,或者它包含的唯一有用的字符串是:"},{"type":"codeinline","content":[{"type":"text","text":"Error: permission denied on directory \/data"}]},{"type":"text","text":"。你的公司完蛋了。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"备份表面上包含大量重要数据,但在上传时已损坏。你的公司完蛋了。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"备份包含有效的数据库!但是由于备份脚本中的循环错误,每个分片都是分片0。你公司的87.5%已经消失了。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"每个备份都包含正确、有效的数据库!但是你只能通过一个85毫秒的链接从廉价的存储类下载它,意味着恢复需要2周时间。你的公司还是没了。"}]}]}]},{"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":"因此,请一定要证明你的恢复是有效的——自动化并监控这一步骤,不要只是偶尔做一次验证——并确保它们会在可接受的时间内恢复完成。4小时的宕机会是糟糕的一天,但4天的宕机后,你的公司就完蛋了。确保你的公司政策可以容忍这样的恢复时间,并让你的领导签字,这样当工程团队在灾难期间需要7小时才能恢复数据库时,他们也不会抓狂。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"引文"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/gitlabs-2017-postgres-outage\/","title":"","type":null},"content":[{"type":"text","text":"第2集"}]},{"type":"text","text":",Gitlab的2017年Postgres停机:备份脚本每天都在运行,将内容放到S3中……直到软件更新破坏了备份脚本。对应的修复还没有真正经过测试。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/githubs-43-second-network-partition\/","title":"","type":null},"content":[{"type":"text","text":"第6集"}]},{"type":"text","text":",GitHub的43秒网络分区:恢复需要很长时间(10小时以上),尤其是在流量高峰期间,导致站点退化了很长时间。"}]}]}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"第4课:分阶段慢慢部署"}]},{"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":"但分阶段部署可以把问题锁定在确定的范围内,因此你可以在火势蔓延并烧毁整个站点之前先看到哪里在冒烟。"}]},{"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":"下面是一个具体的例子:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"部署到你的"},{"type":"text","marks":[{"type":"strong"}],"text":"Dogfooding"},{"type":"text","text":"(自家用)集群——每小时或每个更改集,当前的HEAD版本都会部署给你的员工。这可以让你自己的团队在客户发现问题之前未雨绸缪。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"金丝雀"},{"type":"text","text":"集群——按照你的发布节奏(也许每天一次?),发布候选被推送到一个小型部署,将它暴露给你的一小部分用户。一些公司会从几十个数据中心里挑一个来做金丝雀;其他公司根据他们的user_id或类似的东西挑出用户群的一部分来部署。发布经理可能会仔细监控金丝雀受众中这个新版本的对应指标,然后再继续……"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"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":"而在公司没有使用分阶段部署的情况下,事情显然不太顺利……编写事后分析的团队往往是第一个指出分阶段部署会有多大影响的团队。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"引文"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/one-subtle-regex-takes-down-cloudflare\/","title":"","type":null},"content":[{"type":"text","text":"第4集"}]},{"type":"text","text":",一个微妙的正则表达式让Cloudflare瘫痪:Cloudflare非常快速地部署了一种更昂贵的基于正则表达式的规则,结果由于CPU耗尽而导致整个站点瘫痪"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/salesforce-publishes-a-controversial-postmortem-and-breaks-their-dns\/","title":"","type":null},"content":[{"type":"text","text":"第11集"}]},{"type":"text","text":",Salesforce发布了一个有争议的事后分析:一个DNS配置更改的快速部署让他们的所有名称服务器都下线了。"}]}]}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"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":"最后,虽然我们都愿意相信,如果测试非常彻底,并且周到地安排了所有事情,我们将不会再遇到大规模宕机事故……可我们都知道它们仍然会迟早发生。"}]},{"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":"策略意味着经过深思熟虑并做出决定,例如:如果整个站点因超载而停机,我们首先要减少哪些流量来恢复正常?这些流量涉及什么类型或什么类别的客户?如果这些决定是提前做出的,并由领导签字,甚至可能得到律师的验证,工程团队就更容易把压力减到阈值以下。"}]},{"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":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"引文"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/episode-1-slack-vs-tgws\/","title":"","type":null},"content":[{"type":"text","text":"第1集"}]},{"type":"text","text":",Slack与TGW:Slack使用了特使代理的恐慌模式,让负载平衡算法在过载时找到健康主机的机会大大增加。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/one-subtle-regex-takes-down-cloudflare\/","title":"","type":null},"content":[{"type":"text","text":"第4集"}]},{"type":"text","text":",一个微妙的正则表达式摧毁了Cloudflare:Cloudflare已经制定了政策和支持使用条款,允许他们在服务出现故障时关闭全球Web应用程序防火墙。此外,他们有一个运行时参数,允许他们无需部署代码就能立即禁用它。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/githubs-43-second-network-partition\/","title":"","type":null},"content":[{"type":"text","text":"第6集"}]},{"type":"text","text":",GitHub的43秒网络分区:GitHub在从过载中恢复时关闭了Webhook调用和GitHubPages构建。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/downtimeproject.com\/podcast\/how-coinbase-unleashed-a-thundering-herd\/","title":"","type":null},"content":[{"type":"text","text":"第9集"}]},{"type":"text","text":",Coinbase惊动了大批客户:在Coinbase需要配置自己的一个集群,结果在关闭\/打开所有流量后惊动了大批客户,他们本应该缓慢恢复流量的。"}]}]}]},{"type":"heading","attrs":{"align":null,"level":2},"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":"在回顾了所有这些压力巨大的宕机事件后,我们得出了一个非常令人鼓舞的结论:包括我们在上面列举的许多实践在内,一些常见实践可以预防或显著减轻各种站点停机问题带来的严重影响。"}]},{"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":"https:\/\/downtimeproject.com\/podcast\/7-lessons-from-10-outages\/"}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章