破解系统设计访谈:Twitter软件工程师的提示
by Zhia Hwa Chong
志華化
破解系統(tǒng)設(shè)計(jì)訪談: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.
我最近寫(xiě)了關(guān)于如何從多家頂級(jí)科技公司獲得報(bào)價(jià)的文章 。 在準(zhǔn)備面試過(guò)程中,我閱讀了許多材料,并準(zhǔn)備了有關(guān)如何解決系統(tǒng)設(shè)計(jì)問(wèn)題的一組說(shuō)明。 在本文中,我想與大家分享這些技巧。
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.
如果您是沒(méi)有大規(guī)模分布式系統(tǒng)經(jīng)驗(yàn)的應(yīng)屆畢業(yè)生,或者甚至是具有多年經(jīng)驗(yàn)的經(jīng)驗(yàn)豐富的工程師,那么本文對(duì)您都是有用的。
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) :如果您想加入一組學(xué)生以了解有關(guān)系統(tǒng)設(shè)計(jì)的更多信息,我將一起組織一小堂課! 您可以轉(zhuǎn)到此鏈接以了解更多信息,或訪問(wèn)我的網(wǎng)站zhiachong.com以獲取更多信息。
This article is broken down into the following four sections:
本文分為以下四個(gè)部分:
- Ask clarification questions 提出澄清問(wèn)題
- Use your background 使用你的背景
- Tackle a problem systematically 系統(tǒng)地解決問(wèn)題
- Keep your own notes 保留自己的筆記
提出澄清問(wèn)題 (Ask clarification questions)
A core aim of a systems design interview is to give the candidate an opportunity to demonstrate their knowledge.
系統(tǒng)設(shè)計(jì)面試的核心目的是使應(yīng)聘者有機(jī)會(huì)證明自己的知識(shí)。
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:
沒(méi)有嚴(yán)格正確或錯(cuò)誤的答案。 一個(gè)好的系統(tǒng)設(shè)計(jì)問(wèn)題通常聽(tīng)起來(lái)很模棱兩可,其原因是應(yīng)該給您展示以下內(nèi)容的機(jī)會(huì):
- How you would think about the problem space 您如何看待問(wèn)題空間
- 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.
想象您被要求設(shè)計(jì)一個(gè)黑匣子。 您將如何解決這個(gè)問(wèn)題? 除了可以在其中容納一些物品的盒子之外,這里沒(méi)有明確的指示要建造什么。
One of the most useful strategies I personally employ is to ask clarification questions. What are “good” clarification questions, you ask?
我個(gè)人采用的最有用的策略之一是提出澄清問(wèn)題。 您問(wèn)什么是“好的”澄清問(wèn)題?
A good clarification question helps you achieve one, or more, of several things:
一個(gè)好的澄清問(wèn)題可以幫助您實(shí)現(xiàn)以下一項(xiàng)或多項(xiàng)目標(biāo):
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?”
在黑匣子示例中,您可能會(huì)問(wèn):“那么,該箱子能容納什么? 它容納多少個(gè)物品? 誰(shuí)是目標(biāo)用戶(hù)?”
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.
也許我會(huì)說(shuō),讓我們建立一個(gè)黃色的盒子,上面帶有一個(gè)笑臉,最多可容納1個(gè)網(wǎng)球。 但是,這不是普通的網(wǎng)球。 半徑至少為0.5m,重約1kg。 它應(yīng)該被擁抱,而不是被握住,所以我不需要任何處理。
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.
總是問(wèn)澄清問(wèn)題。 您不會(huì)在面試過(guò)程中被問(wèn)到是否問(wèn)過(guò)某個(gè)特定問(wèn)題,而是會(huì)根據(jù)您對(duì)問(wèn)題空間的看法來(lái)判斷您。
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.
例如,如果我要您現(xiàn)在設(shè)計(jì)Twitter,您將如何做? 花幾分鐘考慮一下,甚至可以在一張紙上畫(huà)出草圖。 盡可能深入和廣泛地討論,然后再回到本文。 更好的是,您可以在下面的評(píng)論中留下您的筆記 ,我們可以進(jìn)行進(jìn)一步討論。
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.
如果您尚未意識(shí)到這一點(diǎn),那么上面練習(xí)的最終結(jié)果將產(chǎn)生明顯不同的結(jié)果。 對(duì)于我自己的特定背景,我可能會(huì)真正深入地研究API設(shè)計(jì)和后端基礎(chǔ)結(jié)構(gòu)。 根據(jù)我的經(jīng)驗(yàn),我可能還會(huì)探討特定于iPhone的問(wèn)題。 我將討論客戶(hù)端如何與中間層端點(diǎn)交互,日志將如何工作,如何設(shè)計(jì)后端以確保正常運(yùn)行時(shí)間,等等。
These are quite interesting discussions that you can have with a colleague, and that is a very strong signal an interviewer is looking for.
您可以與同事進(jìn)行非常有趣的討論,這是面試官正在尋找的強(qiáng)烈信號(hào)。
利用您的背景優(yōu)勢(shì) (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.
我經(jīng)常看到工程師試圖弄清楚面試官要問(wèn)的問(wèn)題,然后根據(jù)他們的期望來(lái)滿足他們的要求。
I actually highly discourage anyone from doing this for several reasons:
實(shí)際上,出于以下幾個(gè)原因,我非常不鼓勵(lì)任何人這樣做:
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.
您的經(jīng)驗(yàn)和背景可能與下一個(gè)候選人有很大差異。 您將一套價(jià)值和專(zhuān)業(yè)知識(shí)帶到了桌上,這是其他人所無(wú)法企及的。 那就是讓您變得寶貴和不可替代的原因。 無(wú)論您處于哪個(gè)領(lǐng)域,人們都在乎您可以帶到餐桌上的東西。
系統(tǒng)地解決問(wèn)題 (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.
現(xiàn)在,考慮到我的專(zhuān)業(yè)知識(shí),我在處理新系統(tǒng)時(shí)會(huì)考慮幾件事。 我強(qiáng)烈建議您也為自己制定一套標(biāo)準(zhǔn)或步驟。
Some of the things in my mind when I work on a new system are:
在新系統(tǒng)上工作時(shí),我想到的一些事情是:
- What is the goal of the system? 系統(tǒng)的目標(biāo)是什么?
- Who are the users of the system? 誰(shuí)是系統(tǒng)的用戶(hù)?
- What is the scale we’re working with? 我們正在合作的規(guī)模是多少?
- Is this a new/old system? How do we handle versioning? 這是新舊系統(tǒng)嗎? 我們?nèi)绾翁幚戆姹究刂?#xff1f;
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.
瞧,我的標(biāo)準(zhǔn)集將不同于前端工程師的標(biāo)準(zhǔn)集。 我用這些標(biāo)準(zhǔn)在腦海里畫(huà)一幅畫(huà),這些將指導(dǎo)我的決策過(guò)程。
Armed with answers to those questions, I can start to tackle the problem at hand and then systematically break it down into individual components.
有了這些問(wèn)題的答案,我可以開(kāi)始解決當(dāng)前的問(wèn)題,然后系統(tǒng)地將其分解為各個(gè)部分。
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.
我喜歡做的一個(gè)好練習(xí)是如何設(shè)計(jì)咖啡訂購(gòu)系統(tǒng) 。 我有一天坐在星巴克時(shí)就想到了這一點(diǎn),并意識(shí)到,如果可以在手機(jī)上訂購(gòu)冰沙,然后在當(dāng)?shù)氐男前涂四闷鸨?#xff0c;那就太好了。
My mind started going in various directions:
我的想法開(kāi)始朝各個(gè)方向發(fā)展:
- What does this coffee-ordering machine do? 這臺(tái)咖啡訂購(gòu)機(jī)有什么作用?
- If I build one, can I sell it to Starbucks, or do I white-label it and sell it as a service? 如果我制造一個(gè),可以將其出售給星巴克,還是將其貼上白標(biāo)簽并作為服務(wù)出售?
- How many users do I need to support if I sell it to Starbucks? 如果將其出售給星巴克,需要支持多少用戶(hù)?
- 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? 或者,如果我將其貼上白標(biāo)簽,我可以將界面出售給我的咖啡訂購(gòu)服務(wù),然后幫助客戶(hù)構(gòu)建后端以便他們將訂單存儲(chǔ)在本地計(jì)算機(jī)上嗎?
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:
一旦獲得這些問(wèn)題的答案,我就可以完整地了解我的咖啡訂購(gòu)服務(wù)的功能。 我的咖啡訂購(gòu)服務(wù)版本如下所示:
My coffee-ordering service is a software as a service (SAAS). It offers an interface for various partners to plug into.
我的咖啡訂購(gòu)服務(wù)是一種軟件即服務(wù)( SAAS )。 它為各種合作伙伴提供了插入接口。
It has an API, called addCoffeeForMerchant, that inserts coffee name, coffee price, and coffee ingredients.
它具有一個(gè)名為addCoffeeForMerchant的API,可插入咖啡名稱(chēng),咖啡價(jià)格和咖啡原料。
It has a GET API, called getCoffeesForMerchant, that returns a list of coffees for a given merchant ID.
它具有一個(gè)名為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是使用某種哈希機(jī)制生成的唯一標(biāo)識(shí)符(UUID),可以與客戶(hù)進(jìn)一步闡明。
- 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. 該軟件針對(duì)只讀操作進(jìn)行了優(yōu)化,因?yàn)槲业拇蠖鄶?shù)客戶(hù)一次創(chuàng)建菜單并全天閱讀多次。
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)驅(qū)逐策略的緩存機(jī)制,因?yàn)槿绻欢螘r(shí)間未訂購(gòu)菜單項(xiàng),那么我的客戶(hù)將不在乎它在菜單上顯示的速度是否稍慢。
- 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. 萬(wàn)一其中一個(gè)數(shù)據(jù)存儲(chǔ)設(shè)備自爆,我的咖啡訂購(gòu)服務(wù)將跨美國(guó)西部和美國(guó)東海岸的不同集群復(fù)制數(shù)據(jù),因?yàn)槲夷壳皟H針對(duì)美國(guó)市場(chǎng)。
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.
另外,您可能想到的任何其他咖啡訂購(gòu)服務(wù)也很有可能。 這只是您要優(yōu)化的問(wèn)題。 我認(rèn)為這些都是非常有趣的問(wèn)題,這是使您保持頭腦活躍的一項(xiàng)很棒的心理鍛煉。
保留自己的筆記 (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.
作為軟件工程師,這是一個(gè)永無(wú)止境的學(xué)習(xí)過(guò)程。 我強(qiáng)烈建議您使用Evernote或Moleskin進(jìn)行筆記。 我個(gè)人隨身攜帶一個(gè)小筆記本,以記下我需要記下的快速想法,并盡可能地在Evernote上保存其他各種內(nèi)容。
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中有一個(gè)名為“編程”的筆記本。 每當(dāng)遇到新事物或有趣事物時(shí),我都會(huì)將其記在筆記本上以備參考。
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.
我逐月檢查并為這些新筆記分配標(biāo)簽,以確保筆記井井有條。 例如,對(duì)于與系統(tǒng)設(shè)計(jì)有關(guān)的任何事情,我都有一個(gè)“設(shè)計(jì)”標(biāo)簽。 可能是我發(fā)現(xiàn)有趣的YouTube視頻鏈接,或者是我的同事提出的我從未想過(guò)的有趣論點(diǎn)。
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非常適合進(jìn)行原型設(shè)計(jì),因?yàn)闊o(wú)需與其他團(tuán)隊(duì)進(jìn)行架構(gòu)討論。 如果要更改架構(gòu),則可以使用NoSQL數(shù)據(jù)庫(kù)快速完成。 這是我從“編程”筆記本中插入的工作中的關(guān)鍵經(jīng)驗(yàn)。
I break down my notes into:
我將筆記分解為:
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.
以上所有注釋都在“編程”下。 隨著時(shí)間的流逝,我發(fā)現(xiàn)我擁有過(guò)去已經(jīng)閱讀或探索過(guò)的偽組織的東西。
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.
就個(gè)人而言,認(rèn)識(shí)我的人不是一個(gè)有條理的人。 因此,我只收集了大約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.
知識(shí)和實(shí)踐是攜手并進(jìn)的,以便更好地進(jìn)行系統(tǒng)設(shè)計(jì)。 如果您認(rèn)為當(dāng)前的工作沒(méi)有給您提供進(jìn)行系統(tǒng)設(shè)計(jì)的機(jī)會(huì),那么您應(yīng)該找到一個(gè)可以做的設(shè)計(jì),或者嘗試設(shè)計(jì)現(xiàn)有體系結(jié)構(gòu)的一小部分,以使其更快,更便宜,更可靠,或者將來(lái)更容易修改。
我推薦的資源 (Resources I recommend)
Intro to: Architecture and Systems Designs - Great Youtube tutorial from an ex-Facebook-engineer about how to approach systems design problems.
簡(jiǎn)介:體系結(jié)構(gòu)和系統(tǒng)設(shè)計(jì) -前Facebook工程師提供的有關(guān)如何解決系統(tǒng)設(shè)計(jì)問(wèn)題的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 ?
設(shè)計(jì)數(shù)據(jù)密集型應(yīng)用程序 -學(xué)習(xí)如何按比例設(shè)計(jì)的另一個(gè)很好的資源。 它討論了典型軟件工程師理所當(dāng)然的各種事情-數(shù)據(jù)庫(kù)(mySQL和noSQL)如何工作,何時(shí)使用每種數(shù)據(jù)庫(kù)以及處理規(guī)模等各種技術(shù)的利弊。我強(qiáng)烈推薦它嗎?
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!
模擬面試-模擬實(shí)際面試的模擬環(huán)境對(duì)于準(zhǔn)備面試非常有幫助。 如果您可以找到一個(gè)朋友幫您做,那么我強(qiáng)烈推薦。 我還會(huì)進(jìn)行模擬面試,因此,如果您有興趣,請(qǐng)隨時(shí)訪問(wèn)zhiachong.com與我聯(lián)系 !
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.
每個(gè)軟件工程師應(yīng)該了解的有關(guān)實(shí)時(shí)數(shù)據(jù)統(tǒng)一抽象的知識(shí) -有關(guān)日志,權(quán)衡取舍的冗長(zhǎng)而技術(shù)性的討論。 我還沒(méi)有完成,但是強(qiáng)烈推薦給同事。
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.
印象筆記 -最好的? 我使用過(guò)的記事應(yīng)用程序。 有很多關(guān)于如何最好地利用Evernote的教程。 我還沒(méi)有經(jīng)歷過(guò)這些,僅僅是因?yàn)槲抑皇菍⑵溆米鞴P記本。 我將在此學(xué)習(xí)的所有內(nèi)容記錄下來(lái),然后偶爾進(jìn)行整理和整理。
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筆記本 -我真的很喜歡這一本。 它的質(zhì)量非常高。 價(jià)格略高,但是由于我每天使用它,因此我認(rèn)為這是一筆不錯(cuò)的投資。 每天我手里拿著一個(gè)漂亮的筆記本使我更加興奮地寫(xiě)下更多筆記。
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飛行員(黑色) -輕松獲得我曾經(jīng)使用過(guò)的最好的筆,并且是我唯一會(huì)使用的筆。 我從亞馬遜大量購(gòu)買(mǎi)它們,并隨處攜帶。 我的背包里有一個(gè),辦公室里有一個(gè),家庭辦公室里有一個(gè),所以我周?chē)偸怯幸恢ЧP。 它書(shū)寫(xiě)出色,墨水順暢流動(dòng),我只是喜歡用它書(shū)寫(xiě)。 加上Moleskin,有時(shí)候我只想拿起G2在那兒隨意玩,因?yàn)檫@兩者非常完美。
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.
探索系統(tǒng)設(shè)計(jì)面試 -這是朋友的推薦。 這是一門(mén)在線課程,教您如何詳細(xì)設(shè)計(jì)分布式系統(tǒng)。 然而,這是一門(mén)79美元的課程。 有團(tuán)隊(duì)定價(jià)。 如果有興趣,我會(huì)與他們核對(duì),看看是否有可能組建團(tuán)體折扣團(tuán)體。
Follow me on Twitter, Facebook, and LinkedIn. Sign up for my mailing list where I regularly send tips, tricks and industry learnings.
在Twitter , Facebook和LinkedIn上關(guān)注我。 注冊(cè)我的郵件列表 ,我在那里定期發(fā)送提示,技巧和行業(yè)知識(shí)。
If you enjoyed this article, comment below: what is your tip for building a scalable, reliable system?
如果您喜歡本文,請(qǐng)?jiān)谙旅嬖u(píng)論: 構(gòu)建可擴(kuò)展,可靠系統(tǒng)的提示是什么?
翻譯自: https://www.freecodecamp.org/news/how-to-system-design-dda63ed27e26/
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的破解系统设计访谈:Twitter软件工程师的提示的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: nginx mozilla_我发现Moz
- 下一篇: ios jenkins_如何使用Jenk