website/content/zh-cn/case-studies/buffer/index.html

158 lines
26 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: 案例研究Buffer
case_study_styles: true
cid: caseStudies
css: /css/style_buffer.css
---
<!-- <div class="banner1">
<h1>CASE STUDY: <img src="/images/buffer.png" width="18%" style="margin-bottom:-5px;margin-left:10px;"><br>
<div class="subhead">Making Deployments Easy for a Small, Distributed Team</div>
</h1>
</div> -->
<div class="banner1">
<h1>案例研究: <img src="/images/buffer.png" width="18%" style="margin-bottom:-5px;margin-left:10px;"><br>
<div class="subhead">使小型分布式团队轻松部署</div>
</h1>
</div>
<!-- <div class="details">
Company&nbsp;<b>Buffer</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Location &nbsp;<b>Around the World</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Industry &nbsp;<b>Social Media Technology</b>
</div> -->
<div class="details">
公司&nbsp;<b>Buffer</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位置 &nbsp;<b>全球</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;行业 &nbsp;<b>社交媒体技术公司</b>
</div>
<hr>
<section class="section1">
<div class="cols">
<div class="col1">
<!-- <h2>Challenge</h2>
With a small but fully distributed team of 80 working across almost a dozen time zones, Buffer—which offers social media management to agencies and marketers—was looking to solve its "classic monolithic code base problem," says Architect Dan Farrelly. "We wanted to have the kind of liquid infrastructure where a developer could create an app and deploy it and scale it horizontally as&nbsp;necessary." -->
<h2>挑战</h2>
Buffer 拥有一支80人的分布式团队他们遍布全球近十几个时区。这样一个为代理商和营销人员提供社交媒体管理的公司希望解决其“典型的单一庞大编码基数问题”架构师 Dan Farrelly 这样说。“我们希望拥有一种流动性的基础架构,开发人员可以创建一个应用程序,可以根据需要部署并横向扩展它”。
</div>
<div class="col2">
<!-- <h2>Solution</h2>
Embracing containerization, Buffer moved its infrastructure from Amazon Web Services Elastic Beanstalk to Docker on AWS, orchestrated with&nbsp;Kubernetes. -->
<h2>解决方案</h2>
拥抱容器化Buffer 将其基础设施从 AWS 上的 Elastic Beanstalk 迁移到由 Kubernetes 负责编排的 Docker 上。
<br>
<br>
<!-- <h2>Impact</h2>
The new system "leveled up our ability with deployment and rolling out new changes," says Farrelly. "Building something on your computer and knowing that its going to work has shortened things up a lot. Our feedback cycles are a lot faster now&nbsp;too." -->
<h2>影响</h2>
Farrelly 说,新系统“提高了我们将新变化进行部署和上线的能力”。“在自己的计算机上构建一些东西,并且知道它是可用的,这已经让事情简单了很多;而且我们的反馈周期现在也快了很多。”
</div>
</div>
</section>
<div class="banner2">
<div class="banner2text">
<!-- "Its amazing that we can use the Kubernetes solution off the shelf with our team. And it just keeps getting better. Before we even know that we need something, its there in the next release or its coming in the next few months."<br><br><span style="font-size:16px;letter-spacing:2px;">- DAN FARRELLY, BUFFER ARCHITECT</span> -->
“我们的团队能够直接使用既有的 Kubernetes 解决方案,这太棒了,而且它还在不断改进中。在意识到我们需要某些功能之前,它就出现在下一个版本中,或者在未来几个月内出现。<br><br><span style="font-size:16px;letter-spacing:2px;">- DAN FARRELLY, BUFFER ARCHITECT</span>
</div>
</div>
<section class="section2">
<div class="fullcol">
<!-- <h2>Dan Farrelly uses a carpentry analogy to explain the problem his company, <a href="https://buffer.com">Buffer</a>, began having as its team of developers grew over the past few years.</h2> -->
<h2>Dan Farrelly 用木工类比来解释他的公司<a href="https://buffer.com"> Buffer </a>,随着过去几年的发展,公司开始有这个问题。</h2>
<!-- "If youre building a table by yourself, its fine," the companys architect says. "If you bring in a second person to work on the table, maybe that person can start sanding the legs while youre sanding the top. But when you bring a third or fourth person in, someone should probably work on a different table." Needing to work on more and more different tables led Buffer on a path toward microservices and containerization made possible by Kubernetes. -->
“如果你自己做一张桌子,这很好!”公司的架构师说。“如果你请另一个人一起来做这个桌子,也许这个人可以在你抛光桌面时开始对腿进行抛光。但是,当你把第三个或第四个人带进来时,有人也许应该在另外一张桌子上工作。”需要处理越来越多不同的桌子,使 Buffer 走上了 Kubernetes 实现微服务和容器化的道路。
<br><br>
<!-- Since around 2012, Buffer had already been using <a href="https://aws.amazon.com/elasticbeanstalk/">Elastic Beanstalk</a>, the orchestration service for deploying infrastructure offered by <a href="https://aws.amazon.com">Amazon Web Services</a>. "We were deploying a single monolithic <a href="http://php.net/manual/en/intro-whatis.php">PHP</a> application, and it was the same application across five or six environments," says Farrelly. "We were very much a product-driven company. -->
自2012年左右以来Buffer 开始使用<a href="https://aws.amazon.com/elasticbeanstalk/"> Elastic Beanstalk </a>,这是<a href="https://aws.amazon.com">亚马逊网络服务</a>提供的网络基础设施编排服务。“我们部署了一个单一的<a href="http://php.net/manual/en/intro-whatis.php">PHP</a>应用程序,它是在五六个环境中相同的应用程序”Farrelly 说。“我们在很大程度上是一家产品驱动型的公司。”
<!-- It was all about shipping new features quickly and getting things out the door, and if something was not broken, we didnt spend too much time on it. If things were getting a little bit slow, wed maybe use a faster server or just scale up one instance, and it would be good enough. Wed move on." -->
这一切都是为了尽快给应用推出新功能并进行交付,如果能够正常运行,我们就不会花太多时间在上面。如果产品变得有点慢,我们可能会使用更快的服务器或只是增加一个实例,这些就已经足够了。然后继续前进。
<br><br>
<!-- But things came to a head in 2016. With the growing number of committers on staff, Farrelly and Buffers then-CTO, Sunil Sadasivan, decided it was time to re-architect and rethink their infrastructure. "It was a classic monolithic code base problem," says Farrelly.<br><br>Some of the companys team was already successfully using <a href="https://www.docker.com">Docker</a> in their development environment, but the only application running on Docker in production was a marketing website that didnt see real user traffic. They wanted to go further with Docker, and the next step was looking at options for&nbsp;orchestration. -->
但事情在2016年就到了头。随着应用提交修改的数量不断增加Farrelly 和 Buffer 当时的首席技术官 Sunil Sadasivan 决定,是重新思考和构建其基础架构的时候了。“这是一个典型的单一庞大编码基数问题”Farrelly说。公司的一些团队已经在开发环境中成功使用<a href="https://www.docker.com">Docker</a>,但在生产环境中,运行在 Docker 上的唯一应用程序是一个看不到真实用户流量的营销网站。他们希望在使用 Docker 上更进一步,下一步是寻找业务流程的选项。
</div>
</section>
<div class="banner3">
<div class="banner3text">
<!-- And all the things Kubernetes did well suited Buffers needs. "We wanted to have the kind of liquid infrastructure where a developer could create an app and deploy it and scale it horizontally as necessary," says Farrelly. "We quickly used some scripts to set up a couple of test clusters, we built some small proof-of-concept applications in containers, and we deployed things within an hour. We had very little experience in running containers in production. It was amazing how quickly we could get a handle on it&nbsp;[Kubernetes]." -->
Kubernetes 所做的所有事情都很好地适应了 Buffer 的需求。Farrelly 说:“我们希望拥有一种流动基础架构,开发人员可以创建一个应用程序,并在必要时部署并进行水平扩展。”“我们很快就使用一些脚本来设置几个测试集群,在容器中构建了一些小的概念性验证应用程序,并在一小时内部署了这些内容。我们在生产中运行容器方面经验很少。令人惊奇的是,我们能很快地用 Kubernetes 来处理。”
</div>
</div>
<section class="section3">
<div class="fullcol">
<!-- First they considered <a href="https://mesosphere.com">Mesosphere</a>, <a href="https://dcos.io">DC/OS</a> and <a href="https://aws.amazon.com/ecs/">Amazon Elastic Container Service</a> (which their data systems team was already using for some data pipeline jobs). While they were impressed by these offerings, they ultimately went with Kubernetes. -->
首先,他们考虑了<a href="https://mesosphere.com">Mesosphere</a><a href="https://dcos.io">DC/OS</a><a href="https://aws.amazon.com/ecs/">Amazon Elastic Container Service</a>(他们的数据系统团队已经将其用于某些数据管道作业)。虽然他们对这些产品印象深刻,但他们最终还是与 Kubernetes 合作。
<!-- "We run on AWS still, so spinning up, creating services and creating load balancers on demand for us without having to configure them manually was a great way for our team to get into this," says Farrelly. "We didnt need to figure out how to configure this or that, especially coming from a former Elastic Beanstalk environment that gave us an automatically-configured load balancer. I really liked Kubernetes controls of the command line. It just took care of ports. It was a lot more flexible. Kubernetes was designed for doing what it does, so it does it very well." -->
Farrelly 说:“我们的应用仍在 AWS 上运行,但是我们的团队通过 Kubernetes 无需手动配置即可创建服务并按需创建负载均衡器,这是使用 Kubernetes 的最佳入门体验。”“我们不需要考虑如何配置这个或那个,特别是相较于以前的 Elastic Beanstalk 环境,它为我们提供了一个自动配置的负载均衡器。我真的很喜欢 Kubernetes 对命令行的控制只需要对端口进行配置这样更加灵活。Kubernetes 是为做它所做的事情而设计的,所以它做得非常好。”
<br><br>
<!-- And all the things Kubernetes did well suited Buffers needs. "We wanted to have the kind of liquid infrastructure where a developer could create an app and deploy it and scale it horizontally as necessary," says Farrelly. "We quickly used some scripts to set up a couple of test clusters, we built some small proof-of-concept applications in containers, and we deployed things within an hour. We had very little experience in running containers in production. It was amazing how quickly we could get a handle on it [Kubernetes]." -->
Kubernetes 所做的所有事情都很好地适应了 Buffer 的需求。Farrelly 说:“我们希望拥有一种流动基础架构,开发人员可以创建一个应用程序,并在必要时部署并进行水平扩展。”“我们很快就使用一些脚本来设置几个测试集群,在容器中构建了一些小的概念性验证应用程序,并在一小时内部署了这些内容。我们在生产中运行容器方面经验很少。令人惊奇的是,我们能很快地用 Kubernetes 来处理。”
<br><br>
<!-- Above all, it provided a powerful solution for one of the companys most distinguishing characteristics: their remote team thats spread across a dozen different time zones. "The people with deep knowledge of our infrastructure live in time zones different from our peak traffic time zones, and most of our product engineers live in other places," says Farrelly. "So we really wanted something where anybody could get a grasp of the system early on and utilize it, and not have to worry that the deploy engineer is asleep. Otherwise people would sit around for 12 to 24 hours for something. Its been really cool to see people moving much faster." -->
最重要的是它为公司最显著的特征之一提供了强大的解决方案他们的远程团队分布在十几个不同的时区。Farrelly 说“对我们的基础设施有深入了解的人生活在不同于我们相对集中的时区而我们的大部分产品工程师都住在其他地方。”“因此我们确实希望有人能够尽早掌握这套系统并利用好它而不必担心部署工程师正在睡觉。否则人们会为了一些东西必须得等待12到24小时左右。看到人们前进得更快这真的很酷。”
<br><br>
<!-- With a relatively small engineering team—just 25 people, and only a handful working on infrastructure, with the majority front-end developers—Buffer needed "something robust for them to deploy whatever they wanted," says Farrelly. Before, "it was only a couple of people who knew how to set up everything in the old way. With this system, it was easy to review documentation and get something out extremely quickly. It lowers the bar for us to get everything in production. We don't have the big team to build all these tools or manage the infrastructure like other larger companies&nbsp;might." -->
Farrelly 说Buffer 拥有相对较小的工程团队,只有 25 人,只有少数人从事基础设施工作,大多数前端开发人员都需要“一些强大的配置能力,以便部署任何他们想要的内容。”以前,“只有几个人知道如何用旧的方式设置一切。有了这个系统,审查文档变得很容易,并且能很快地看到效果。它降低了我们获取在开发环境中所需要一切的门槛。因为我们团队的人数不足以来构建所有这些工具或像其他大公司那样管理基础架构。”
</div>
</section>
<div class="banner4">
<div class="banner4text">
<!-- "In our old way of working, the feedback loop was a lot longer, and it was delicate because if you deployed something, the risk was high to potentially break something else," Farrelly says. "With the kind of deploys that we built around Kubernetes, we were able to detect bugs and fix them, and get them deployed super fast. The second someone is fixing [a bug], its out the&nbsp;door." -->
Farrelly 说:“在我们以往的工作方式中,反馈循环流程要长得多,而且很微妙,因为如果你部署了某些东西,就存在破坏其他东西的风险。”“我们通过围绕 Kubernetes 构建的部署类型,能够及时检测 Bug 并修复它们,并使其部署得超快。这一秒正在修复漏洞,不一会就上线运行了。”
</div>
</div>
<section class="section4">
<div class="fullcol">
<!-- To help with this, Buffer developers wrote a deploy bot that wraps the Kubernetes deploy process and can be used by every team. "Before, our data analysts would update, say, a <a href="https://www.python.org">Python</a> analysis script and have to wait for the lead on that team to click the button and deploy it," Farrelly explains. "Now our data analysts can make a change, enter a <a href="https://slack.com">Slack</a> command, /deploy, and it goes out instantly. They dont need to wait on these slow turnaround times. They dont even know where its running; it doesnt matter." -->
为了帮助解决这一问题Buffer 开发人员编写了一个部署机器人,该机器人包装了 Kubernetes 部署过程,并且每个团队都可以使用。”“以前,我们的数据分析师会更新<a href="https://www.python.org"> Python </a>分析脚本并且必须等待该团队的主管单击该按钮并部署它”Farrelly 解释道。“现在,我们的数据分析师可以进行更改,输入<a href="https://slack.com"> Slack </a>命令,‘/deploy,它会立即进行部署。他们不需要等待这些缓慢的周转时间,他们甚至不知道它在哪里运行。这些都不重要了。
<br><br>
<!-- One of the first applications the team built from scratch using Kubernetes was a new image resizing service. As a social media management tool that allows marketing teams to collaborate on posts and send updates across multiple social media profiles and networks, Buffer has to be able to resize photographs as needed to meet the varying limitations of size and format posed by different social networks. "We always had these hacked together solutions," says Farrelly. -->
团队使用 Kubernetes 从头开始构建的第一个应用程序是一种新的图像大小调整服务。作为一种社交媒体管理工具它允许营销团队通过发帖进行协作并通过多个社交媒体配置文件和网络发送更新Buffer 必须能够根据需要调整照片的大小以满足不同的社交网络。Farrelly 说:“我们一直有这些拼凑在一起的解决方案。”
<br><br>
<!-- To create this new service, one of the senior product engineers was assigned to learn Docker and Kubernetes, then build the service, test it, deploy it and monitor it—which he was able to do relatively quickly. "In our old way of working, the feedback loop was a lot longer, and it was delicate because if you deployed something, the risk was high to potentially break something else," Farrelly says. "With the kind of deploys that we built around Kubernetes, we were able to detect bugs and fix them, and get them deployed super fast. The second someone is fixing [a bug], its out the door." -->
为了创建这项新服务,一位高级产品工程师被指派学习 Docker 和 Kubernetes然后构建服务、测试、部署和监视服务他能够相对快速地完成该服务。Farrelly说“在我们以往的工作方式中反馈循环流程要长得多而且很微妙因为如果你部署了某些东西就存在破坏其他东西的风险。”“我们通过围绕 Kubernetes 构建的部署类型,能够及时检测 Bug 并修复它们,并使其部署得超快。这一秒正在修复漏洞,不一会就上线运行了。”
<br><br>
<!-- Plus, unlike with their old system, they could scale things horizontally with one command. "As we rolled it out," Farrelly says, "we could anticipate and just click a button. This allowed us to deal with the demand that our users were placing on the system and easily scale it to handle it." -->
此外,与旧系统不同,他们只需一个命令就可以水平缩放内容。“当我们推出它,”Farrelly说“我们可以预测只需点击一个按钮。这使我们能够处理用户对系统的需求,并轻松扩展以处理它。”
<br><br>
<!-- Another thing they werent able to do before was a canary deploy. This new capability "made us so much more confident in deploying big changes," says Farrelly. "Before, it took a lot of testing, which is still good, but it was also a lot of fingers crossed. And this is something that gets run 800,000 times a day, the core of our business. If it doesnt work, our business doesnt work. In a Kubernetes world, I can do a canary deploy to test it for 1 percent and I can shut it down very quickly if it isnt working. This has leveled up our ability to deploy and roll out new changes quickly while reducing&nbsp;risk." -->
他们以前不能做的另外一件事是金丝雀部署。Farrelly说这种新功能“使我们在部署重大变革方面更加自信。”“以前虽然进行很多测试但仍表现不错但它也存在很多手指交叉。这是每天运行 800000 次的东西,这是我们业务的核心。如果它不工作,我们的业务也无法运行。在 Kubernetes 世界中,我可以执行金丝雀部署以测试 1%,如果它不工作,我可以很快将其关闭。这使我们在快速部署和推出新更改的同时降低风险的能力得到了提高。”
</div>
</section>
<div class="banner5">
<div class="banner5text">
<!-- "If you want to run containers in production, with nearly the power that Google uses internally, this [Kubernetes] is a great way to do that," Farrelly says. "Were a relatively small team thats actually running Kubernetes, and weve never run anything like it before. So its more approachable than you might think. Thats the one big thing that I tell people who are experimenting with it. Pick a couple of things, roll it out, kick the tires on this for a couple of months and see how much it can handle. You start learning a lot this&nbsp;way." -->
Farrelly 说:“如果你想在生产中运行容器,拥有像谷歌内部使用的那种效果,那么 Kubernetes 就是一个很好的方法。”“我们是一个相对较小的团,实际上运行 Kubernetes我们之前从来没来做过这样的事情。因此它比你想象的更容易上手这正是我想要告诉正在尝试使用它的人们的一件很重要的事。挑几个应用,把它们准备好,在机器上运行几个月,看看它能处理的怎么样。通过这种方式你可以学到很多东西。”
</div>
</div>
<section class="section5">
<div class="fullcol">
<!-- By October 2016, 54 percent of Buffers traffic was going through their Kubernetes cluster. "Theres a lot of our legacy functionality that still runs alright, and those parts might move to Kubernetes or stay in our old setup forever," says Farrelly. But the company made the commitment at that time that going forward, "all new development, all new features, will be running on Kubernetes." -->
到 2016 年 10 月Buffer 54% 的流量都通过其 Kubernetes 集群。Farrelly 说:“我们很多传统功能仍然运行正常,这些部分可能会转移到 Kubernetes 或永远留在我们的旧设置中。”但该公司当时承诺,“所有新的开发,所有新功能,将在Kubernetes上运行。”
<br><br>
<!-- The plan for 2017 is to move all the legacy applications to a new Kubernetes cluster, and run everything theyve pulled out of their old infrastructure, plus the new services theyre developing in Kubernetes, on another cluster. "I want to bring all the benefits that weve seen on our early services to everyone on the team," says Farrelly. -->
2017年计划是将所有旧应用程序迁移到新的 Kubernetes 集群,并运行他们从旧基础架构中撤出的所有内容,以及他们正在另一个 Kubernetes 集群上开发的新服务。Farrelly 说:“我想为团队中的每个人带来我们早期服务的所有好处。”
<br><br>
<h2>
<!-- For Buffers engineers, its an exciting process. "Every time were deploying a new service, we need to figure out: OK, whats the architecture? How do these services communicate? Whats the best way to build this service?" Farrelly says. "And then we use the different features that Kubernetes has to glue all the pieces together. Its enabling us to experiment as were learning how to design a service-oriented architecture. Before, we just wouldnt have been able to do it. This is actually giving us a blank white board so we can do whatever we want on it." -->
对于 Buffer 的工程师来说,这是一个令人兴奋的过程。“每次部署新服务时,我们都需要弄清楚:好的体系结构是什么这些服务如何沟通构建此服务的最佳方式是什么”Farrelly说。“然后我们使用 Kubernetes 的特性将所有部分聚合到一起。在学习如何设计面向服务的体系结构时,它使我们能够进行试验。以前,我们只是不能做到这一点。这实际上给了我们一个空白的白板,所以我们可以做任何我们想要的。”
</h2>
<!-- Part of that blank slate is the flexibility that Kubernetes offers should the time come when Buffer may want or need to change its cloud. "Its cloud agnostic so maybe one day we could switch to Google or somewhere else," Farrelly says. "Were very deep in Amazon but its nice to know we could move away if we need to." -->
部分空白是 Kubernetes 提供的灵活性,如果某一天 Buffer 可能想要或需要改变他的云服务。“这是与云无关的所以也许有一天我们可以切换到谷歌或其他地方”Farrelly 说。“我们非常依赖亚马逊的基础服务,但很高兴知道,如果我们需要的话,我们可以搬走。”
<br><br>
<!-- At this point, the team at Buffer cant imagine running their infrastructure any other way—and theyre happy to spread the word. "If you want to run containers in production, with nearly the power that Google uses internally, this [Kubernetes] is a great way to do that," Farrelly says. "Were a relatively small team thats actually running Kubernetes, and weve never run anything like it before. So its more approachable than you might think. Thats the one big thing that I tell people who are experimenting with it. Pick a couple of things, roll it out, kick the tires on this for a couple of months and see how much it can handle. You start learning a lot this&nbsp;way." -->
此时Buffer 团队无法想象以任何其他方式运行其基础结构他们很乐意传播这一信息。Farrelly 说:“如果你想在生产中运行容器,拥有像谷歌内部使用的那种效果,那么 Kubernetes 就是一个很好的方法。”“我们是一个相对较小的团队,实际上运行 Kubernetes我们之前从来没来做过这样的事情。因此它比你想象的更容易上手这正是我想要告诉正在尝试使用它的人们的一件很重要的事。挑几个应用把它们准备好在机器上运行几个月看看它能处理的怎么样。通过这种方式你可以学到很多东西。”
<br><br>
</div>
</section>