Saturday, February 24, 2024

System Design Interview By Alex Xu

Don't Miss

Is Microservice Architecture The Silver Bullet

[Chinese] System Design Fireside chat with Alex Xu.

The diagram below shows why real-time gaming and low-latency trading applications should not use microservice architecture.

There are some common features of these applications, which make them choose monolithic architecture:

  • These applications are very latency-sensitive. For real-time gaming, the latency should be at the milli-second level for low-latency trading, the latency should be at the micro-second level. We cannot separate the services into different processes because the network latency is unbearable.

  • Microservice architecture is usually stateless, and the states are persisted in the database. Real-time gaming and low-latency trading need to store the states in memory for quick updates. For example, when a character is injured in a game, we dont want to see the update 3 seconds later. This kind of user experience can kill a game.

  • Real-time gaming and low-latency trading need to talk to the server in high frequency, and the requests need to go to the same running instance. So web socket connections and sticky routing are needed.

So microservice architecture is designed to solve problems for certain domains. We need to think about why when designing applications. Over to you: Have you met similar situations at work when you have to choose an architecture other than microservice?

Vertical Vs Horizontal Scaling

For many of you, it might seem basic, but its still important to emphasize some basic vocabulary when it comes to system design interviews.

When you design a system, you must think about what youd do in case the volume of traffic significantly increased. You have to think about scaling your application.

But scaling where and how?

In brief, there are two kinds of scaling.

  • Vertical scaling is often referred to as scaling up your application. It means adding more physical resources such as CPU, RAM, etc to your servers.
  • Horizontal scaling is also called scaling out your system. Instead of having more powerful servers, its about having more servers.

The larger applications you design, the more you have to think about horizontal scaling as vertical scaling has some hard limits. Its limited to how many CPUs, how much RAM you can add to a server.

Probably these are the most basic fundamentals to learn when you start preparing for your interviews.

System Design Interview Book Review: Finally A Book For Getting Better At Architecting Systems

I’ve come across the book System Design Interview: an Insider’s Guide by accident . I was looking for good book resources after several people have been asking me how they can get better at building distributed systems or learning designing systems at scale. Especially when they don’t have the opportunity to do so as part of their day-to-day work.

The topic is somewhat a chicken-and-egg one. You’ll know how to design a large system after you designed one before. But if you’ve not done so: how would you build an URL shortener like bit.ly, with hundreds of millions of links? A chat app like Whatsapp? A file storage system like Dropbox or Google Drive?

There are many resources online – the most well-known one being System Design Primer on GitHub or reading High Scalability articles. In my case, I was looking for a more “structured” approach, as opposed to just dumping a bunch of concepts you need to know in these interviews.

This book is the most “real-world” systems design book I’ve come across that does a solid effort to teach concepts, step by step, to people who have yet to work at systems at scale. And it’s also a welcome refresher to those who are familiar with some of these systems but would like to venture into various other types of large systems. It is clear from the start that the book was written by someone familiar with systems at scale. The author is Alex Xu, a software engineer previously at Oracle, Zynga, and Twitter.

Read Also: How To Succeed In A Job Interview

My Takes From System Design Interview By Alex Xu

Since 2015, I am attending interviews as an interviewer for recruiting new talents, for the selection of new partner companies etc. And since 2019 I am conducting interviews for my current company. The topics I interview for are usually General Tech and Culture Fit. I enjoy also system design and thought I can also help our company by taking over a few System Design Interviews hence I started to prepare myself for the next step. I saw System Desing Interview: An Insiders Guide by Alex Xu is suggested for interviewees to prepare for upcoming challenges so I thought I should give it a shot to sharpen my skills and understanding of the system design domain.

The book starts with the basics like designing for scaling, back of the envelope calculations then suggests a framework for system design and provides 12 different system design examples. I took some notes and also recorded some resources to read further.

Lets look into the suggested framework for system design. Its a four-step framework and actually, I found it quite useful to have such a structure.

The full version of this post can be read at

What Does It Include

System Design Interview An Insider S Guide Xu Alex

Let me briefly share what kind of system design challenges are shared in the book.

  • Scale From Zero To Millions Of Users
  • Back-of-the-envelope Estimation
  • Design A Search Autocomplete System
  • Design Google Drive

Its worth noting that often one chapter builds on another, such as a unique ID generator is referred to in later chapters. Still, you can read the chapters in any order as the references are explicit and if you are interested, you can easily jump to other topics.

The list of references and further readings at the end of each chapter are also very valuable.

Read Also: How To Prepare For Toptal Interview

A Framework For The Systems Design Interview

System design interviews can feel intimidating, and having a framework on how to navigate them can help you feel more in control. The book recommends a 4-step process that I also agree with:

  • Understand the problem and establish the design scope. I like to phrase this as confirming the problem, asking questions, and making constraints clear. “In a systems design interview, giving out an answer quickly does not give you you bonus points.” – the book suggests. They are right.
  • Propose high-level design and get buy-in. I see people all too often jump into implementing without confirming their approach satisfies the constraints, and they’re not over-engineering. The interviewers expect a conversation – similar to real-life design – and this step helps you achieve exactly that.
  • Design deep-dive. Once you know you’re on the right track, it’s time to roll up your sleeves and get into the details. This is the part you’ll need to have the understanding and vocabulary of the systems domain. The book will help understand several of the concepts you’ll need. Resources like System Design Primer also help with this phase.
  • Wrap-up. With a design that seems sensible, you might close with identifying the bottlenecks and improvement areas.
  • Is It Possible To Run C C++ Or Rust On A Web Browser

    What is web assembly ? Why does it attract so much attention? The diagram shows how we can run native C/C++/Rust code inside a web browser with WASM.

    Traditionally, we can only work with Javascript in the web browser, and the performance cannot compare with native code like C/C++ because it is interpreted. However, with WASM, we can reuse existing native code libraries developed in C/C++/Rust, etc to run in the web browser. These web applications have near-native performance. For example, we can run the video encoding/decoding library in the web browser. This opens a lot of possibilities for cloud computing and edge computing. We can run serverless applications with fewer resources and instant startup time. Over to you: Are you familiar with WASM or have you used it in the workplace?

    Thanks for reading ByteByteGo Newsletter! Subscribe for free to receive new posts and support my work.

    Also Check: How To Ace Project Manager Interview

    Preparing For The Systems Design And Coding Interview

    At Big Tech and high-growth startups, coding and systems design interviews are common – and fairly standard. A lot of people have asked me for preparation advice for these. Here is what I used when getting ready for an E5/E6 Facebook interview, and the one at Uber – where I was hired as a senior software engineer . It’s the same resources I recommend to people who are preparing for Big Tech or high-growth tech company interviews.

    Note that none of the below links are affiliate links or sponsored. See my ethics statement on the lack of such links.

    How Does Google Authenticator Work

    Systems Design Interview: Volume 2 Review and Payments Chapter Deepdive

    Google authenticator is commonly used for logging into our accounts when 2-factor authentication is enabled. How does it guarantee security? Google Authenticator is a software-based authenticator that implements a two-step verification service. The diagram below provides detail.

    There are two stages involved:

    • Stage 1 – The user enables Google’s two-step verification

    • Stage 2 – The user uses the authenticator for logging in, etc.

    • Can the secret key be obtained by others? We need to make sure the secret key is transmitted using HTTPS. The authenticator client and the database store the secret key, and we need to ensure the secret keys are encrypted.

    • Can the 6-digit password be guessed by hackers?No. The password has 6 digits, so the generated password has 1 million potential combinations. Plus, the password changes every 30 seconds. If hackers want to guess the password in 30 seconds, they need to enter 30,000 combinations per second.

    Over to you: What are some of the other 2-factor authentication devices you used?

    Also Check: Facebook Technical Program Manager Interview

    Take Ownership Of Your Education

    Big Tech interviews are both fairly standard and widely documented. There is a wealth of resources to prepare for the coding interview and a growing pile of systems design resources.

    It’s easy to get lost in so much information: which is why you should make a plan on how you will get “interview-ready”.

    Create a study plan with topics you want to cover for the interview types you’re expecting to have. Learn the theory, then practice this with practice and exercises where you create something from scratch: implementing a data structure, drawing up a diagram.

    There is no shortage of people complaining about the difficult interview process Big Tech has. However, I know of no other industry where you can get a high-paying job with no college degree, no connections: purely through interviews that are fairly standard among the highest paying employers like Netflix, Airbnb, Uber, Facebook, Pinterest, and others.

    Tech interviews being “standard” across the Big Tech makes preparing for these a high-leverage activity: study once, interview many times. Once you prepare, just make sure your software engineering resume grabs the attention of the recruiters.

    Good luck – and if you are looking for more advice for senior and above interviews, I have some.

    Featured Pragmatic Engineer Jobs

  • Staff Software Engineer at Qualified.com. San Francisco or Remote.
  • Infrastructure Team Lead at Ometria. £90-150K. United Kingdom or Portugal.
  • The above jobs score at least 10/12 on The Pragmatic Engineer Test. Browse more senior engineer and engineering leadership roles with great engineering cultures, or add your own on The Pragmatic Engineer Job board and apply to join The Pragmatic Engineer Talent Collective.

    Want to get interesting opportunities from vetted tech companies? Sign up to The Pragmatic Engineer Talent Collective and get sent great opportunities – similar to the ones below without any obligation. You can be public or anonymous, and Iâll be curating the list of companies and people.

    Are you hiring senior+ engineers or engineering managers? Apply to join The Pragmatic Engineer Talent Collective to contact world-class senior and above engineers and engineering managers/directors. Get vetted drops twice a month, from software engineers – full-stack, backend, mobile, frontend, data, ML – and managers currently working at Big Tech, high-growth startups, and places with strong engineering cultures. Apply here.

    Newsletter

    Also Check: How To Ask Behavioral Interview Questions

    More articles

    Popular Articles