๐ Giveaway Winners Announcement! ๐
We already have the list of lucky recipients for our giveaway! You will be receiving a message from our ByteByteGo Official account, detailing how you can claim your prize.ย
๐๐ ๐ฐ๐ข๐ฅ๐ฅ ๐๐ ๐ฌ๐๐ง๐๐ข๐ง๐ ๐ ๐ฆ๐๐ฌ๐ฌ๐๐ ๐ ๐ญ๐จ ๐๐จ๐ง๐๐ข๐ซ๐ฆ๐๐ ๐ฐ๐ข๐ง๐ง๐๐ซ๐ฌ ๐ฐ๐ข๐ญ๐ก๐ข๐ง ๐ ๐ฐ๐๐๐ค.
– For book recipients, we will have to ask for your mailing address.ย
– For subscription winners, we will be needing your email address to enroll you on the website.ย
10 book recipients:ย
Francis Lan, Cesar Campana, Candice Jia Hui, Melissa Pizarro โ, Annie Ho, Sandeep Gadhiya, Fernanda Alves, Nevin George, Dan ไธน K. , Nazik Almazova
90 subscription winners: in the comment section.
To everybody who joined and showed support, thank you so much!
๐๐ ๐ญ๐ก๐๐ซ๐ ๐ข๐ฌ ๐๐ง๐จ๐ฎ๐ ๐ก ๐ข๐ง๐ญ๐๐ซ๐๐ฌ๐ญ, ๐ฐ๐ ๐๐๐ง ๐๐จ ๐๐ง๐จ๐ญ๐ก๐๐ซ ๐ซ๐จ๐ฎ๐ง๐ ๐
โ
Subscribe to our weekly newsletter to learn something new every week:ย
https://bit.ly/3FEGliw
ย
#systemdesign #coding #interviewtips
.
ByteByteGo’s YouTube channel just reached 50,000 subscribers. Thank you everyone for making this happen!
We are new to this so please give us feedback or suggest topics to cover. Thank you!
โ Subscribe to our Youtube: https://lnkd.in/eMr5AxNP
#systemdesign #coding #interviewtips
.
Just sent the ByteByteGo system design newsletter to over 75k people. Each episode includes 3 original technical posts from us, 1 YouTube video we made, 1 analysis of the real-world system, and occasional bonus posts.
This week, we talked about the following topics:
๐นTCP or UDP for Zoom?
๐นWhy is Kafka fast? (YouTube video)
๐น100 system design book giveaway
๐นDistributed SQL
๐นBlocking vs non-blocking queue
Next week, we will cover:
๐น Important algorithms to master in SD interviews
๐น How do push notifications work?
๐น Credit card payment
๐น QR code payment
๐น How to store passwords safely (YouTube video)
Subscribe to our weekly newsletter so you wonโt miss it: https://bit.ly/3FEGliw
ย
#systemdesign #coding #interviewtips
.
How do we implement a ๐ง๐จ๐ง-๐๐ฅ๐จ๐๐ค๐ข๐ง๐ queue? What are the differences between blocking and non-blocking algorithms?
This post is written by Hua Li
The terms we use when discussing blocking and non-blocking algorithms can be confusing, so letโs start by reviewing the terminology in the concurrency area with a diagram.ย
๐นblocking
The blocking algorithm uses locks. Thread A acquires the lock first, and Thread B might wait for arbitrary lengthy periods if Thread A gets suspended while holding the lock. This algorithm may cause Thread B to starve.ย
๐นnon-blocking:
The non-blocking algorithm allows Thread A to access the queue, but Thread A must complete a task in a certain number of steps. Other threads like Thread B may still starve due to the rejections.ย
ย
This is the main ๐๐ข๐๐๐๐ซ๐๐ง๐๐ between blocking and non-blocking algorithms: The blocking algorithm blocks Thread B until the lock is released. A non-blocking algorithm notifies Thread B that access is rejected.
ย
๐นstarvation-free:ย
Thread Starvation means a thread cannot acquire access to certain shared resources and cannot proceed. Starvation-free means this situation does not occur.
ย
๐นwait-free:
All threads can complete the tasks within a finite number of steps.
๐๐ข๐ช๐ต-๐ง๐ณ๐ฆ๐ฆ = ๐๐ฐ๐ฏ-๐๐ญ๐ฐ๐ค๐ฌ๐ช๐ฏ๐จ + ๐๐ต๐ข๐ณ๐ท๐ข๐ต๐ช๐ฐ๐ฏ-๐ง๐ณ๐ฆ๐ฆ
โก๏ธ Non-Blocking Queue ๐๐ฆ๐ฉ๐ฅ๐๐ฆ๐๐ง๐ญ๐๐ญ๐ข๐จ๐ง
We can use Compare and Swap (CAS) to implement a non-blocking queue. The diagram below illustrates the algorithm.
โก๏ธ ๐๐๐ง๐๐๐ข๐ญ๐ฌ
1. No thread suspension. Thread B can get a response immediately and then decide what to do next. In this way, the thread latency is greatly reduced.
2. No deadlocks. Threads A and B do not wait for the lock to release, meaning that there is no possibility of a deadlock occurring.
โ
Subscribe to our weekly newsletter to learn something new every week: https://bit.ly/3FEGliw
ย
#systemdesign #coding #interviewtips
.
What is Distributed SQL? Why do we need it? How does it work?
.
.
Google’s Spanner popularized the term โdistributed SQLโ database in 2012. Distributed SQL databases ๐๐ฎ๐ญ๐จ๐ฆ๐๐ญ๐ข๐๐๐ฅ๐ฅ๐ฒ ๐ซ๐๐ฉ๐ฅ๐ข๐๐๐ญ๐ ๐๐๐ญ๐ across multiple nodes and are ๐ฌ๐ญ๐ซ๐จ๐ง๐ ๐ฅ๐ฒ ๐๐จ๐ง๐ฌ๐ข๐ฌ๐ญ๐๐ง๐ญ. Paxos or Raft algorithms are commonly used to achieve consensus across multiple nodes.
Examples of Distributed SQL databases: Google Spanner, Amazon Aurora, CockroachDB, YugabyteDB, TiDB, etc.
A few weeks ago, I met the CTO of TiDB Ed Huang, and a few other team members. We discussed how Distributed SQL databases evolved and how TiDB developed its own open-sourced database. After that conversation, I read more documentation/source code about it and I found it to be an interesting case study. I want to share my learning here.
Terms:
OLTP = Online transactional processing
OLAP = Online analytical processing
HTAP = Hybrid transaction/analytical processing
๐นThe life of an OLTP query (marked with ๐๐ฅ๐ฎ๐ sequence numbers):
Step 1. A client sends a MySQL query and the query is interpreted by TiDB, a stateless SQL layer that interprets the MySQL protocol.
Step 2: TiDB requests data mapping/placement information from the placement driver (PD).
Step 3: PD responds with data mapping/ placement instructions & timestamp.ย
Step 4: TiDB executes queries on TiKV servers (row-based storage).
Step 5, 6: Query results are sent back to the client.
๐นThe life of a complex ๐๐๐๐ query: marked with ๐ฒ๐๐ฅ๐ฅ๐จ๐ฐ sequence numbers.
Over to you: do you think the terms OLTP and OLAP have become obsolete or are they still very relevant? When should we use distributed SQL databases vs traditional relational databases?
โ
Subscribe to our weekly newsletter to learn something new every week: https://bit.ly/3FEGliw
ย
#systemdesign #coding #interviewtips
.
Why is Kafka fast (YouTube video explanation available)?ย
.
.
Designing a message queue is a commonly asked system design interview question. If you are preparing for interviews, I highly recommend watching this video or understanding the concepts mentioned in this post. You can find the link to our YouTube channel at the end of the post.
There are many design decisions that contributed to Kafkaโs performance. In this post, weโll focus on two. We think these two carried the most weight.
1๏ธโฃ The first one is Kafkaโs reliance on Sequential I/O.
ย
2๏ธโฃ The second design choice that gives Kafka its performance advantage is its focus on efficiency: zero copy principle.
ย
The diagram below illustrates how the data is transmitted between producer and consumer, and what zero-copy means.
ย
๐นStep 1.1 – 1.3: Producer writes data to the diskย
ย
๐นStep 2: Consumer reads data without zero-copy
2.1: The data is loaded from disk to OS cache
2.2 The data is copied from OS cache to Kafka application
2.3 Kafka application copies the data into the socket bufferย
2.4 The data is copied from socket buffer to network card
2.5 The network card sends data out to the consumer
ย
๐นStep 3: Consumer reads data with zero-copy
3.1: The data is loaded from disk to OS cache
3.2 OS cache directly copies the data to the network card via sendfile() command
3.3 The network card sends data out to the consumer
ย
Zero copy is a shortcut to save the multiple data copies between application context and kernel context.
ย
Over to you: what are some of the other systems that rely on Sequential I/O?
ย
โ
Subscribe to our system design newsletter and YouTube channel to learn something new every week.ย
ย
๐๐๐๐ค๐ฅ๐ฒ ๐ง๐๐ฐ๐ฌ๐ฅ๐๐ญ๐ญ๐๐ซ: https://bit.ly/3FEGliw
๐๐จ๐ฎ๐๐ฎ๐๐ ๐๐ก๐๐ง๐ง๐๐ฅ: https://bit.ly/3xWM7Kk
ย
#systemdesign #coding #interviewtips
.
200k followers! Giving away 100 system design books.ย
.
.
My LinkedIn just reached over 200K followers, and I couldn’t be more grateful for your continued support.ย
Every day is an opportunity to get new content out, and thank you for taking the time out of your busy lives to read what we write.
To show my appreciation, I will be giving away:ย ย
๐น 10 signed physical booksย (shipping costs are on me)
๐น 90 1-year subscriptions to the ByteByteGo website. ByteByteGo has contents for two system design books (volumes 1 and 2), and new system design contents are coming soon.
๐๐จ๐ฐ ๐ญ๐จ ๐ฉ๐๐ซ๐ญ๐ข๐๐ข๐ฉ๐๐ญ๐:ย
โ
Follow me on LinkedInย ย
โ
Like and comment on this post
โ
And subscribe to our Youtube channel: https://lnkd.in/eMr5AxNPย
โฐ Giveaway ends in 72 hours.ย
โ-
Subscribe to our weekly newsletter to learn something new every week (optional): https://lnkd.in/gqFQ49AV
#systemdesign #coding #giveaway
.
Which protocol does Zoom use for video streaming, TCP or UDP?
.
.
Letโs review the differences first.
๐นThe primary difference between TCP and UDP is that TCP is connection-based whereas UDP is connectionless.ย
Connection-based: It implies that all messages will arrive and arrive in the correct order.ย
Connectionless: It does not guarantee order or completeness.ย
๐นThe second difference is that UDP is faster than TCP.
– UDP does not require ACK message back
– UDP has no flow control
– No duplication verification at the receiving end
– Shorter header
UDP sacrifices correctness for speed. Users generally prefer smooth video calls and UDP is indeed the default choice for Zoom.ย
Over to you: the HTTP protocol used to be based on TCP, but the latest protocol HTTP/3 is based on UDP. Do you know why?
โ
Subscribe to our weekly newsletter to learn something new every week: https://bit.ly/3FEGliw
ย
#systemdesign #coding #interviewtips
.
This week, we talked about the following topics:
๐นDiagram as code
๐นCloudflare outage summary
๐นHow HTTPs works (video)
๐นEvent sourcing
๐นSystem Design YouTube channel survey
Next week, we will cover:
๐นSequential IO/Random IO (video)
๐นBlocking vs non-blocking
๐นHow notifications work
๐นDistributed SQLย
๐นQR code payment
ย
Subscribe to our weekly newsletter so you wonโt miss it: https://bit.ly/3FEGliw
ย
#systemdesign #coding #interviewtips
.