破解系统设计访谈:Twitter软件工程师的提示

by Zhia Hwa Chong

志华化

破解系统设计访谈:Twitter软件工程师的提示 (Crack the System Design interview: tips from a Twitter software engineer)

I recently wrote about how I landed offers from multiple top-tier tech companies. During my interview preparation process, I read up on a lot of material and prepared a set of notes on how to tackle system design problems. In this article, I’d like to share those tips with you all.

我最近写了关于如何从多家顶级科技公司获得报价的文章 。 在准备面试过程中,我阅读了许多材料,并准备了有关如何解决系统设计问题的一组说明。 在本文中,我想与大家分享这些技巧。

If you’re a fresh graduate with no experience in large-scale distributed systems, or even a seasoned engineer with years of experience under your belt, this article will be useful for you.

如果您是没有大规模分布式系统经验的应届毕业生,或者甚至是具有多年经验的经验丰富的工程师,那么本文对您都是有用的。

Update (3/24/2019): If you’d like to join a group of students to learn more about system design, I’m organizing a small class together! You can go to this link to learn more, or visit my website: zhiachong.com for more info.

更新(3/24/2019) :如果您想加入一组学生以了解有关系统设计的更多信息,我将一起组织一小堂课! 您可以转到此链接以了解更多信息,或访问我的网站zhiachong.com以获取更多信息。

This article is broken down into the following four sections:

本文分为以下四个部分:

  • Ask clarification questions

    提出澄清问题
  • Use your background

    使用你的背景
  • Tackle a problem systematically

    系统地解决问题
  • Keep your own notes

    保留自己的笔记

提出澄清问题 (Ask clarification questions)

A core aim of a systems design interview is to give the candidate an opportunity to demonstrate their knowledge.

系统设计面试的核心目的是使应聘者有机会证明自己的知识。

There are no strictly right or wrong answers. A good system design question usually sounds very ambiguous, and the reason for that is it’s supposed to give you a chance to demonstrate the following:

没有严格正确或错误的答案。 一个好的系统设计问题通常听起来很模棱两可,其原因是应该给您展示以下内容的机会:

  • How you would think about the problem space

    您如何看待问题空间
  • How you think about bottlenecks

    您如何看待瓶颈
  • What you can do to remove these bottlenecks.

    您可以采取哪些措施消除这些瓶颈。

Imagine that you’re being asked to design a black box. How would you tackle the problem? There are no clear directions on what you need to build here, aside from the box being able to hold some items within it.

想象您被要求设计一个黑匣子。 您将如何解决这个问题? 除了可以在其中容纳一些物品的盒子之外,这里没有明确的指示要建造什么。

One of the most useful strategies I personally employ is to ask clarification questions. What are “good” clarification questions, you ask?

我个人采用的最有用的策略之一是提出澄清问题。 您问什么是“好的”澄清问题?

A good clarification question helps you achieve one, or more, of several things:

一个好的澄清问题可以帮助您实现以下一项或多项目标:

  1. Helps you narrow the scope of what you’re supposed to do

    帮助您缩小应该做的事情的范围
  2. Helps clarify what the user expectation of the system is

    帮助阐明用户对系统的期望
  3. Gives you direction about where to proceed

    指导您进行下一步
  4. Informs you of possible bottlenecks/problem areas

    通知您可能的瓶颈/问题区域

In the black box example, you might ask, “well, what does the box hold? How many items does it hold? And who is the intended user?”

在黑匣子示例中,您可能会问:“那么,该箱子能容纳什么? 它容纳多少个物品? 谁是目标用户?”

To that I might say, let’s build a yellow box with a smiley on it that should hold at most 1 tennis ball. This is not an ordinary tennis ball, however. It will be at least 0.5m in radius and weighs about 1kg. It is meant to be hugged, not held, so I don’t want any handle on it.

也许我会说,让我们建立一个黄色的盒子,上面带有一个笑脸,最多可容纳1个网球。 但是,这不是普通的网球。 半径至少为0.5m,重约1kg。 它应该被拥抱,而不是被握住,所以我不需要任何处理。

There you go, this is the box.

您去了,这是盒子。

Always ask clarification questions. You are not being judged on whether or not you asked a specific question during the interview, but you are judged on how you think about the problem space.

总是问澄清问题。 您不会在面试过程中被问到是否问过某个特定问题,而是会根据您对问题空间的看法来判断您。

For example, if I were to ask you to design Twitter right now, how would you do it? Take a few minutes to think about it, and maybe even sketch it out on a piece of paper. Go as deeply and widely as you can, and then come back to this article. Better yet, you can leave your notes in the comments below and we can discuss further.

例如,如果我要您现在设计Twitter,您将如何做? 花几分钟考虑一下,甚至可以在一张纸上画出草图。 尽可能深入和广泛地讨论,然后再回到本文。 更好的是,您可以在下面的评论中留下您的笔记 ,我们可以进行进一步讨论。

If you haven’t realized it yet, the end result of the exercise above would yield significantly different results. For my own specific background, I might delve really deeply into API design and backend infrastructure. I’d probably explore iPhone-specific problems as well, due to my experience. I’ll talk about how the client interacts with the middle-tier endpoints, how logging would work, how I’d design the backend to ensure uptime, and so on.

如果您尚未意识到这一点,那么上面练习的最终结果将产生明显不同的结果。 对于我自己的特定背景,我可能会真正深入地研究API设计和后端基础结构。 根据我的经验,我可能还会探讨特定于iPhone的问题。 我将讨论客户端如何与中间层端点交互,日志将如何工作,如何设计后端以确保正常运行时间,等等。

These are quite interesting discussions that you can have with a colleague, and that is a very strong signal an interviewer is looking for.

您可以与同事进行非常有趣的讨论,这是面试官正在寻找的强烈信号。

利用您的背景优势 (Use your background to your advantage)

Often times I see engineers trying to figure out what the interviewer is trying to ask, and then catering their responses to fit the expectations.

我经常看到工程师试图弄清楚面试官要问的问题,然后根据他们的期望来满足他们的要求。

I actually highly discourage anyone from doing this for several reasons:

实际上,出于以下几个原因,我非常不鼓励任何人这样做:

  1. Everyone has a unique background. In a systems design interview, it’s an opportunity for you to demonstrate what your strengths are. Don’t waste the opporunity trying to figure out what someone else might expect of you.

    每个人都有独特的背景。 在系统设计面试中,这是您展示自己的优势的机会。 不要浪费机会试图弄清楚别人对你的期望。
  2. The interviewer might have been nodding along to your answers, but they might’ve known that you’re just bluffing your way through and not actually thinking about the problem.

    面试官可能一直在回答您的答案,但他们可能已经知道您只是在虚张声势,没有真正考虑问题。

Your experience and background can vary widely from the next candidate. You bring a set of values and expertise to the table that no one else can. That is what makes you valuable and irreplaceable. Regardless of what field you’re in, people care about what you can bring to the table.

您的经验和背景可能与下一个候选人有很大差异。 您将一套价值和专业知识带到了桌上,这是其他人所无法企及的。 那就是让您变得宝贵和不可替代的原因。 无论您处于哪个领域,人们都在乎可以带到餐桌上的东西。

系统地解决问题 (Tackle the problem systematically)

Now, with my expertise in mind, there are several things that I think about when I’m tackling a new system. I highly recommend that you formulate a set of criteria or steps for yourself as well.

现在,考虑到我的专业知识,我在处理新系统时会考虑几件事。 我强烈建议您也为自己制定一套标准或步骤。

Some of the things in my mind when I work on a new system are:

在新系统上工作时,我想到的一些事情是:

  • What is the goal of the system?

    系统的目标是什么?
  • Who are the users of the system?

    谁是系统的用户?
  • What is the scale we’re working with?

    我们正在合作的规模是多少?
  • Is this a new/old system? How do we handle versioning?

    这是新旧系统吗? 我们如何处理版本控制?

Among others…

其中...

See, my set of criteria will be different from a front-end engineer’s set of criteria. I use these criteria to formulate a picture in my head, and these will guide my decision-making process.

瞧,我的标准集将不同于前端工程师的标准集。 我用这些标准在脑海里画一幅画,这些将指导我的决策过程。

Armed with answers to those questions, I can start to tackle the problem at hand and then systematically break it down into individual components.

有了这些问题的答案,我可以开始解决当前的问题,然后系统地将其分解为各个部分。

A good exercise I like to do is how to design a coffee-ordering system. I thought of this while I was sitting at Starbucks one day, and realized that it would be nice if I could order a smoothie on my phone and pick it up at my local Starbucks.

我喜欢做的一个好练习是如何设计咖啡订购系统 。 我有一天坐在星巴克时就想到了这一点,并意识到,如果可以在手机上订购冰沙,然后在当地的星巴克拿起冰沙,那就太好了。

My mind started going in various directions:

我的想法开始朝各个方向发展:

  • What does this coffee-ordering machine do?

    这台咖啡订购机有什么作用?
  • If I build one, can I sell it to Starbucks, or do I white-label it and sell it as a service?

    如果我制造一个,可以将其出售给星巴克,还是将其贴上白标签并作为服务出售?
  • How many users do I need to support if I sell it to Starbucks?

    如果将其出售给星巴克,需要支持多少用户?
  • Alternatively, if I white-label it, can I sell the interface to my coffee-ordering service, and then help the customers build out a backend so that they can store the orders on their local machines?

    或者,如果我将其贴上白标签,我可以将界面出售给我的咖啡订购服务,然后帮助客户构建后端以便他们将订单存储在本地计算机上吗?

Once I get answers to these questions, I can finally form a full picture of what my coffee-ordering service does. Here’s what my version of the coffee-ordering service would look like:

一旦获得这些问题的答案,我就可以完整地了解我的咖啡订购服务的功能。 的咖啡订购服务版本如下所示:

My coffee-ordering service is a software as a service (SAAS). It offers an interface for various partners to plug into.

我的咖啡订购服务是一种软件即服务( SAAS )。 它为各种合作伙伴提供了插入接口。

  • It has an API, called addCoffeeForMerchant, that inserts coffee name, coffee price, and coffee ingredients.

    它具有一个名为addCoffeeForMerchant的API,可插入咖啡名称,咖啡价格和咖啡原料。

  • It has a GET API, called getCoffeesForMerchant, that returns a list of coffees for a given merchant ID.

    它具有一个名为getCoffeesForMerchant的GET API,该API返回给定商家ID的咖啡列表。

  • The merchant ID is a unique identifier (UUID) that is generated using some hashing mechanism, which can be further clarified with the customer.

    商家ID是使用某种哈希机制生成的唯一标识符(UUID),可以与客户进一步阐明。
  • The software is optimized for read-only operations, because most of my customers create their menu once and read it multiple times throughout the day.

    该软件针对只读操作进行了优化,因为我的大多数客户一次创建菜单并全天阅读多次。
  • It has a caching mechanism that uses Least-Recently-Used (LRU) eviction strategy, because if the menu item hasn’t been ordered in a while, my customer doesn’t care if it’s slightly slower in showing up on the menu.

    它具有使用最近最少使用(LRU)驱逐策略的缓存机制,因为如果一段时间未订购菜单项,那么我的客户将不在乎它在菜单上显示的速度是否稍慢。

  • In case one of the data stores self-erupts, my coffee-ordering service will replicate data across different clusters across US west and US east coast because I am targeting the US market only for now.

    万一其中一个数据存储设备自爆,我的咖啡订购服务将跨美国西部和美国东海岸的不同集群复制数据,因为我目前仅针对美国市场。

Alternatively, any other coffee-ordering service that you can think of would be highly probable as well. It’s just a matter of what you’re optimizing for. I think these are very interesting problems, and it’s a great mental exercise to keep your mind engaged.

另外,您可能想到的任何其他咖啡订购服务也很有可能。 这只是您要优化的问题。 我认为这些都是非常有趣的问题,这是使您保持头脑活跃的一项很棒的心理锻炼。

保留自己的笔记 (Keep your own notes)

As a software engineer, it’s a never-ending process of learning. I highly recommend that you use either Evernote or a Moleskin to keep notes. I personally carry a small notebook for quick ideas I need to jot down, and I keep various other things on Evernote whenever I can.

作为软件工程师,这是一个永无止境的学习过程。 我强烈建议您使用Evernote或Moleskin进行笔记。 我个人随身携带一个小笔记本,以记下我需要记下的快速想法,并尽可能地在Evernote上保存其他各种内容。

I have a Notebook named “Programming” in my Evernote. Whenever I run into something new, or something interesting, I jot it down within my notebook for further reference.

我的Evernote中有一个名为“编程”的笔记本。 每当遇到新事物或有趣事物时,我都会将其记在笔记本上以备参考。

I go through and assign labels to these new notes on a monthly or quarterly basis to make sure the notes are organized. For example, I have a “Design” label for anything that has to do with system design. It could be something like a link to a YouTube video that I found interesting, or an interesting argument my coworker put forth that I hadn’t thought about.

我逐月检查并为这些新笔记分配标签,以确保笔记井井有条。 例如,对于与系统设计有关的任何事情,我都有一个“设计”标签。 可能是我发现有趣的YouTube视频链接,或者是我的同事提出的我从未想过的有趣论点。

This is a sample of what one of my notes looks like:

这是我的注释之一的示例:

One of the things I learned recently from a coworker is that NoSQL is great for prototyping, because there’s no need to undergo schema discussions with other teams. If I wanted to change the schema, I can do that really quickly with a NoSQL database. That was a key learning from work that I inserted into my “Programming” notebook.

我最近从一位同事那里了解到的一件事是NoSQL非常适合进行原型设计,因为无需与其他团队进行架构讨论。 如果要更改架构,则可以使用NoSQL数据库快速完成。 这是我从“编程”笔记本中插入的工作中的关键经验。

I break down my notes into:

我将笔记分解为:

  1. Systems designs

    系统设计
  2. Interviewing (experience + review of different interviews I’ve had in the past, grouped by company name)

    面试(经验+对我过去进行过的不同面试的审查,按公司名称分组)
  3. Random tid-bits, CS good-to-know, like useful bash scripts or command-line tricks

    随机的tid位,CS众所周知,例如有用的bash脚本或命令行技巧
  4. Readings / YouTube videos

    阅读资料/ YouTube视频

All of the notes above go under “Programming”. Over time, I find that I have a pseudo-organized collection of things I’ve either read or explored in the past.

以上所有注释都在“编程”下。 随着时间的流逝,我发现我拥有过去已经阅读或探索过的伪组织的东西。

As anyone who knows me on a personal level, I’m not a very organized person. Thus, I’ve only collected maybe 10 - 15% of things, so there’s much more left to do there.

就个人而言,认识我的人不是一个有条理的人。 因此,我只收集了大约10%到15%的东西,因此还有更多要做的事情。

Knowledge and practice go hand-in-hand in getting better at systems designs. If you feel that your current work doesn’t afford you the opportunity to do systems designs, then you should either find one that does, or try to design one small part of an existing architecture such that it’s either faster, cheaper, more robust, or easier to modify in the future.

知识和实践是携手并进的,以便更好地进行系统设计。 如果您认为当前的工作没有给您提供进行系统设计的机会,那么您应该找到一个可以做的设计,或者尝试设计现有体系结构的一小部分,以使其更快,更便宜,更可靠,或者将来更容易修改。

我推荐的资源 (Resources I recommend)

Intro to: Architecture and Systems Designs - Great Youtube tutorial from an ex-Facebook-engineer about how to approach systems design problems.

简介:体系结构和系统设计 -前Facebook工程师提供的有关如何解决系统设计问题的Great Youtube教程。

Designing data-intensive applications - Another good resource for learning how to design for scale. It talks about various things a typical software engineer takes for granted — how databases (mySQL and noSQL) work, when to use each, pros and cons of various techniques for handling scale etc. I highly recommend it ?

设计数据密集型应用程序 -学习如何按比例设计的另一个很好的资源。 它讨论了典型软件工程师理所当然的各种事情-数据库(mySQL和noSQL)如何工作,何时使用每种数据库以及处理规模等各种技术的利弊。我强烈推荐它吗?

Mock Interviews - A simulated environment that mimics the actual interview is extremely helpful in preparing for interviews. If you can find a friend to do it for you, then I highly recommend it. I also run mock interviews, so if you’re interested, feel free to reach me at zhiachong.com!

模拟面试-模拟实际面试的模拟环境对于准备面试非常有帮助。 如果您可以找到一个朋友帮您做,那么我强烈推荐。 我还会进行模拟面试,因此,如果您有兴趣,请随时访问zhiachong.com与我联系

What every software engineer should know about real-time data’s unifying abstraction - A very lengthy and technical discussion about logs, trade-offs. I haven’t finished it yet, but it comes highly recommended from a coworker.

每个软件工程师应该了解的有关实时数据统一抽象的知识 -有关日志,权衡取舍的冗长而技术性的讨论。 我还没有完成,但是强烈推荐给同事。

Evernote - The best ? note-keeping app I’ve used. There are many tutorials on how to best utilize Evernote. I haven’t gone through them yet, simply because I use it as just a notebook. I log everything I learn on there, and then occasionally go through and reorganize them.

印象笔记 -最好的? 我使用过的记事应用程序。 有很多关于如何最好地利用Evernote的教程。 我还没有经历过这些,仅仅是因为我只是将其用作笔记本。 我将在此学习的所有内容记录下来,然后偶尔进行整理和整理。

Moleskin notebook - I really enjoy this one. The quality of it is extremely high. The price is slightly higher, but since I use it on a daily basis, I consider it a good investment. Holding a beautiful notebook in my hands everyday makes me more excited to write more notes.

Moleskin笔记本 -我真的很喜欢这一本。 它的质量非常高。 价格略高,但是由于我每天使用它,因此我认为这是一笔不错的投资。 每天我手里拿着一个漂亮的笔记本使我更加兴奋地写下更多笔记。

Pilot G2 (Black) - Easily the best pens I’ve ever used, and the only pens I’ll use. I buy them in bulk from Amazon and keep them around everywhere I go. I have one in my backpack, one in the office, and one in my home office so that I always have a pen around. It writes great, the ink flows smoothly, and I just love the feel of writing with it. Coupled with the Moleskin, sometimes I just want to pick up the G2 to jot random things on there because these two are so perfect together.

G2飞行员(黑色) -轻松获得我曾经使用过的最好的笔,并且是我唯一会使用的笔。 我从亚马逊大量购买它们,并随处携带。 我的背包里有一个,办公室里有一个,家庭办公室里有一个,所以我周围总是有一支笔。 它书写出色,墨水顺畅流动,我只是喜欢用它书写。 加上Moleskin,有时候我只想拿起G2在那儿随意玩,因为这两者非常完美。

Grokking the System Design Interview — This one comes as a recommendation from friends. It’s an online course that teaches how to design distributed system in detail. It’s a $79 course, however. There’s a team-pricing. If there’s any interest, I’ll check with them to see if it’s possible to form a group for group-discount.

探索系统设计面试 -这是朋友的推荐。 这是一门在线课程,教您如何详细设计分布式系统。 然而,这是一门79美元的课程。 有团队定价。 如果有兴趣,我会与他们核对,看看是否有可能组建团体折扣团体。

Follow me on Twitter, Facebook, and LinkedIn. Sign up for my mailing list where I regularly send tips, tricks and industry learnings.

TwitterFacebookLinkedIn上关注我。 注册我的邮件列表 ,我在那里定期发送提示,技巧和行业知识。

If you enjoyed this article, comment below: what is your tip for building a scalable, reliable system?

如果您喜欢本文,请在下面评论: 构建可扩展,可靠系统的提示是什么?

翻译自: https://www.freecodecamp.org/news/how-to-system-design-dda63ed27e26/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Computers and computer networks are one of the most incredible inventions of the 20th century, having an ever-expanding role in our daily lives by enabling complex human activities in areas such as entertainment, education, and commerce. One of the most challenging problems in computer science for the 21st century is to improve the design of distributed systems where computing devices have to work together as a team to achieve common goals. In this book, I have tried to gently introduce the general reader to some of the most fundamental issues and classical results of computer science underlying the design of algorithms for distributed systems, so that the reader can get a feel of the nature of this exciting and fascinating field called distributed computing. The book will appeal to the educated layperson and requires no computer-related background. I strongly suspect that also most computer-knowledgeable readers will be able to learn something new. Gadi Taubenfeld is a professor and past dean of the School of Computer Science at the Interdisciplinary Center in Herzliya, Israel. He is an established authority in the area of concurrent and distributed computing and has published widely in leading journals and conferences. He authored the book Synchronization Algorithms and Concurrent Programming, published by Pearson Education. His primary research interests are in concurrent and distributed computing. Gadi was the head of the computer science division at Israel's Open University; member of technical staff at AT&T Bell Laboratories; consultant to AT&T Labs–Research; and a research scientist and lecturer at Yale University. Gadi served as the program committee chair of PODC 2013 and DISC 2008 and holds a Ph.D. in Computer Science from the Technion–Israel Institute of Technology.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值