Flagrant Malfeasance
  • Blog
    • Blatant Theft
    • Collusion
    • Corruption
    • Cybersecurity
    • Education
    • Hollywood
    • Linux
    • OSINT
    • Trump
  • Our Foundation
    • Declaration of Independence
    • United States Constitution
    • Bill of Rights
    • Gettysburg Address
    • Emancipation Proclamation
Select Page

Alex Xu on LinkedIn: #systemdesign #coding #interviewtips | 24 comments

by snoopy | Jul 5, 2022 | Cybersecurity

๐ŸŽ 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
.

  • No alternative text description for this image

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
.

  • No alternative text description for this image

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
.

  • No alternative text description for this image

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
.

  • No alternative text description for this image

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
.

  • No alternative text description for this image

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
.

  • No alternative text description for this image

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
.

  • No alternative text description for this image

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
.

  • No alternative text description for this image

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
.

  • No alternative text description for this image

Recent Posts

  • How enterprises can stay ahead of risks, threats and potential attacks [Q&A]
  • New Industry Report Finds InfoSec and GRC Teams Don’t Define Risk, Vulnerability and Threats Equally–Hinting at Major Challenges in Cyber Risk Managโ€ฆ
  • Cybersecurity: Why The C-Suite Should Care
  • Faltering against Ukraine, Russian hackers resort to ransomware: Researchers
  • This powerful email malware attack uses PDF and WSF files to break your defenses

Archives

  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • December 2017
  • July 2017
  • June 2017
  • May 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • November 2015

Categories

  • Blatant Theft
  • Collusion
  • Corruption
  • Cybersecurity
  • Education
  • Hollywood
  • Linux
  • OSINT
  • Trump
  • Uncategorized
  • White House
ยฉ 2021, Flagrant Malfeasance. All Rights Reserved.