/1 One picture is worth a thousand words. Interesting database selection trees.
iQIYI is one of the largest online video sites in the world, with over 500 million monthly active users. Let's look at how they choose relational and NoSQL databases.
/2 The following databases are used at iQIYI:
- MySQL
- Redis
- TiDB: a hybrid transactional/analytical processing (HTAP) distributed database
- Couchbase: distributed multi-model NoSQL document-oriented database
- TokuDB: open-source storage engine for MySQL and MariaDB.
/3 - Big data analytical systems, like Hive and Impala
- Other databases, like MongoDB, HiGraph, and TiKV
The database selection trees below explain how they choose a database.
/4 Over to you: choosing the database is hard. The view might be controversial. How do you usually pick the right DB?
/5 Disclaimer: This post is based on an article from PingCAP (a ByteByteGo newsletter sponsor). If you are interested in learning more, please check out their in-person HTAP database summit (free) in Mountain View, California: bit.ly/3EcKoDV
/1 How will you design the Stack Overflow website? If your answer is on-premise servers and monolith (bottom), you would likely fail the interview, but that's how it is built in reality!
/2 𝐖𝐡𝐚𝐭 𝐩𝐞𝐨𝐩𝐥𝐞 𝐭𝐡𝐢𝐧𝐤 𝐢𝐭 𝐬𝐡𝐨𝐮𝐥𝐝 𝐥𝐨𝐨𝐤 𝐥𝐢𝐤𝐞
The interviewer is probably expecting something at the top.
1. Microservice is used to decompose the system into small components. 2. Each service has its own database. Use cache heavily.
/3 3. The service is sharded. 4. The services talk to each other asynchronously through message queues. 5. The service is implemented using Event Sourcing with CQRS. 6. Showing off knowledge in distributed systems such as eventual consistency, CAP theorem, etc.
/1 Payment through scanning QR code is very common but do you know how many ways there are to do it?
There are 4 ways, no matter whether you’re using PayPal, Stripe, Paytm, WeChat, or Alipay. Is this surprising to you? To understand this, we will answer to questions.
/2 The first question is who presents the QR code:
1. You can present the QR code and the merchant scans the code for payment. This is called ‘consumer-presented mode, and what the merchant does is direct debit your account.
/3 2. Obviously, the other way is that the merchant presents the QR code for you to scan to pay the due amount. This is called ‘merchant-presented mode’ and you grant the direct credit from your account.
The diagram below shows the differences between a 𝐟𝐨𝐫𝐰𝐚𝐫𝐝 𝐩𝐫𝐨𝐱𝐲 and a 𝐫𝐞𝐯𝐞𝐫𝐬𝐞 𝐩𝐫𝐨𝐱𝐲.
/2 🔹 A forward proxy is a server that sits between user devices and the internet.
A forward proxy is good for:
1️⃣ Protect clients
2️⃣ Avoid browsing restrictions
3️⃣ Block access to certain content
/3 🔹 A reverse proxy is a server that accepts a request from the client, forwards the request to web servers, and returns the results to the client as if the proxy server had processed the request.
/1 The CAP theorem is one of the most famous terms in computer science, but I bet different developers have different understandings. Let’s examine what it is and why it can be confusing.
/2 CAP theorem states that a distributed system can't provide more than two of these three guarantees simultaneously.
𝐂𝐨𝐧𝐬𝐢𝐬𝐭𝐞𝐧𝐜𝐲: consistency means all clients see the same data at the same time no matter which node they connect to.
/3 𝐀𝐯𝐚𝐢𝐥𝐚𝐛𝐢𝐥𝐢𝐭𝐲: availability means any client which requests data gets a response even if some of the nodes are down.
/2 Live streaming is challenging because the video content is sent over the internet in near real-time. Video processing is compute-intensive. Sending a large volume of video content over the internet takes time. These factors make live streaming challenging.
/3 The diagram below explains what happens behind the scenes to make this possible.
Step 1: The streamer starts their stream. The source could be any video and audio source wired up to an encoder
/1 What is 𝐂𝐃𝐍 (Content Delivery Network)? How does CDN make content delivery 𝐟𝐚𝐬𝐭𝐞𝐫?
The diagram below shows why
A CDN refers to geographically distributed servers (edge servers) that provide fast delivery of 𝐬𝐭𝐚𝐭𝐢𝐜 𝐚𝐧𝐝 𝐝𝐲𝐧𝐚𝐦𝐢𝐜 𝐜𝐨𝐧𝐭𝐞𝐧𝐭
/2 With CDN, users don’t need to retrieve content (music, video, files, pictures, etc.) from the origin server. Instead, the content is cached at CDN nodes around the globe, and users can retrieve the content from nearby CDN nodes.