System Design Interview Alex Xu Book 1 - Day 1
System Design Interview Alex Xu Book 1 - Day 1
Notes
Chapter 1: Scale from Zero to Millions of Users
- This is the chapter where we will design a system that supports a single user and gradually scale it up to serve millions of users.
- I think the goal of this chapter is to just gain a good grasp of what are the high level components that are involved in system design.
Single Server Setup
- Okay this is interesting, I think I like the way that he writes this stuff. It’s really minimalistic and gets to the point of things.
- I think it’s because he’s following a “high-level, high-level, high-level, high-level, …” style approach to explaining things instead of a “high-level, high-level-minus-one, high-level-minus-two, high-level-minus-two, high-level-minus-one, high-level-minus-two, high-level, …” approach.
- This first talks about a single server setup situation.
- We have a single web server that’s running a service.
- In order to get a response from it, the following happens
- First a request to the Domain Name System (DNS) is made.
- The Internet Protocol (IP) address is returned from it.
- The IP address helps you find the right place to send your Hypertext Transfer Protocol (HTTP) request to.
- Then the server sends back some sort of information (e.g. HTML, JSON) so that your browser code can render it.
- This flow makes sense. For example, you can break it down in high level components in code like the following:
- You have some sort of url that’s a domain name.
- If this domain name is itself a “get” request, then I guess you can just “get” the HTML. The browser will handle the loading of it. - Another way to break it down would be something like this:
- You have a JavaScript app that’s running in the browser.
- Ah, but something still has to send that JavaScript right? In order for your browser to use it?
- I was thinking that this would be the JSON route instead of pure HTML.
- So the JavaScript app would call an API, which would return a JSON, which the JavaScript would use to create some HTML rendering components.
- But the initial domain access would have to still call the server to send JavaScript to your browser so that it can use it to load stuff.
- What’s interesting is that you have a “domain name” that you send to the DNS which gives you an IP.
- I think this is interesting because both the domain name and IP addresses are both “addresses”.
- Why can you not just use the domain name to identify where to go to for the server? Or use the IP address to do so?
- In order to get a response from it, the following happens
- We also have 2 different traffic sources.
- Web Application
- Uses server side languages to handle business logic, storage, etc, and client-side languages for presentation.
- Apparently Java and Python are the common enough ones to mention in “server side languages”?
- He also mentions “HTML” as the “client-side” language. I thought it wasn’t really a “language”? Maybe he’s not specifically referring to a “programming language”.
- On a side note, what is the definition of a “language” anyways?
- Uses server side languages to handle business logic, storage, etc, and client-side languages for presentation.
- Mobile Application
- HTTP protocol is the communication protocol between the mobile app and the web server, while JSON is the commonly used API response format to transfer the data.
- Reading the two different sources, I don’t really understand why we are making a big deal out of differentiating these two sources at this point in time. Maybe it’s because we should be thinking about it from the start?
- AHHH, maybe the “Web Application” isn’t an application, but it really means an “Application on a Web Browser”.
- This would make differentiating the two sources make more sense because a mobile application would have the code to load the JSON into whatever UI framework the mobile is using on the device itself. (i.e. the code for the app).
- Wording it this way would also cover the case of when you’re using the web browser on mobile.
- AHHH, maybe the “Web Application” isn’t an application, but it really means an “Application on a Web Browser”.
- Web Application
- We have a single web server that’s running a service.
Database
- I guess now we need a database?
- The section doesn’t really explain why we introduce a database at this stage, but I’m assuming that in this particular scenario the author is trying to draw, whatever problems that are introduced by the “growth of the user base”, we now require a database to solve it.
Which Databases to use?
- I think this is technically a sub-section of the section before, but the heading is the same boldness, so I’m making it at the same level.
This post is licensed under CC BY 4.0 by the author.