Alex Xu Profile picture
Oct 5 โ€ข 9 tweets โ€ข 4 min read
/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.
/4 ๐–๐ก๐š๐ญ ๐ข๐ญ ๐š๐œ๐ญ๐ฎ๐š๐ฅ๐ฅ๐ฒ ๐ข๐ฌ
Stack Overflow serves all the traffic with only 9 on-premise web servers, and itโ€™s on monolith! It has its own servers and does not run on the cloud.

This is contrary to all our popular beliefs these days.
/5 ๐Ÿ‘‰ Over to you: what is good architecture, the one that looks fancy during the interview or the one that works in reality?
/6 Reference:
[1] Podcast by @rla4 and@shanselman: hanselminutes.com/847/engineerinโ€ฆ
[2] stackexchange.com/performance
/7 I hope you've found this thread helpful.

Follow me @alexxubyte for more.

Like/Retweet the first tweet below if you can:
Also drew a version like this. Which one do you like?

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Alex Xu

Alex Xu Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @alexxubyte

Oct 6
/1 Why do we use ๐œ๐จ๐ฅ๐ฎ๐ฆ๐ง-๐›๐š๐ฌ๐ž๐ ๐ƒ๐? Does column-based DB provide better performance?

The diagram below shows how data is stored in column-based DB. Image
/2 ๐–๐ก๐ž๐ง ๐ญ๐จ ๐ฎ๐ฌ๐ž

1๏ธโƒฃ The table is a wide table with many columns.
2๏ธโƒฃ The queries and calculations are on a small number of columns.
3๏ธโƒฃ A lot of the columns contain a few distinct values.
/3 ๐๐ž๐ง๐ž๐Ÿ๐ข๐ญ๐ฌ ๐จ๐Ÿ ๐œ๐จ๐ฅ๐ฎ๐ฆ๐ง-๐›๐š๐ฌ๐ž๐ ๐ƒ๐

1๏ธโƒฃ Higher data compression rates.
2๏ธโƒฃ Higher performance on OLAP functions.
3๏ธโƒฃ No need for additional indexes
Read 5 tweets
Oct 3
/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.
Read 6 tweets
Sep 30
/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.
Read 9 tweets
Sep 29
/1 Why is Nginx called a โ€œ๐ซ๐ž๐ฏ๐ž๐ซ๐ฌ๐žโ€ proxy?

The diagram below shows the differences between a ๐Ÿ๐จ๐ซ๐ฐ๐š๐ซ๐ ๐ฉ๐ซ๐จ๐ฑ๐ฒ and a ๐ซ๐ž๐ฏ๐ž๐ซ๐ฌ๐ž ๐ฉ๐ซ๐จ๐ฑ๐ฒ. Image
/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.
Read 6 tweets
Sep 28
/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. Image
/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.
Read 10 tweets
Sep 27
/1 How live streaming works (YouTube live, TikTok live, Twitch streaming)

You can watch and subscribe here:
bit.ly/3CfvBa8

If you prefer text, keep reading:
/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
Read 8 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(