Almost every software engineer has used Git before, but only a handful know how it works.
To begin with, it's essential to identify where our code is stored. The common assumption is that there are only two locations - one on a remote server like Github and the other on our local machine. However, this isn't entirely accurate. Git maintains three local storages on our machine, which means that our code can be found in four places:
- Working directory: where we edit files
- Staging area: a temporary location where files are kept for the next commit
- Local repository: contains the code that has been committed
- Remote repository: the remote server that stores the code
Most Git commands primarily move files between these four locations.
Over to you: Do you know which storage location the "git tag" command operates on? This command can add annotations to a commit.
β
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): https://t.co/uc5M7CdXXC
Explaining 7 Popular Network Protocols in 1 Diagram π
With Black Friday sales coming to an end, letβs take a peek inside a typical eCommerce website and see how these popular network protocols power the online shopping spree.
1οΈβ£ DNS
When you type the website URL into your browser, DNS translates the domain name into an IP address to locate the ecommerce servers.
2οΈβ£ HTTP/HTTPS
Your browser communicates securely with the servers via HTTPS to fetch product info and process purchases, typically over RESTful APIs.
3οΈβ£ gRPC
Behind the scenes, the store's microservices like order processing and payments communicate efficiently via gRPC.
4οΈβ£ WebSocket
The website establishes a WebSocket to instantly notify your browser when payment goes through.
5οΈβ£ SMTP
Once the order is fulfilled, SMTP sends you an order confirmation email.
6οΈβ£ Ping (ICMP)
But what if there's a snag? Our vigilant SRE engineer pings servers with ICMP to diagnose issues.
7οΈβ£ Video Call (UDP)
And when the going gets tough, engineers use real-time video call on UDP to resolve tricky bugs.
From product listing to payment to notifications and troubleshooting - the invisible protocols work in harmony so you can shop with ease this Black Friday.
Which network protocol fascinates you the most in enabling seamless digital commerce and why?
β
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): https://t.co/kNfv0DVDdf
Explaining the 4 Most Commonly Used Types of Queues in a Single Diagram.
Queues are popular data structures used widely in the system. The diagram below shows 4 different types of queues we often use.
1. Simple FIFO Queue
A simple queue follows FIFO (First In First Out). An new element is inserted at the tail of the queue, and an element is removed from the head of the queue.
If we would like to send out email notifications to the users whenever we receive a payment response, we can use a FIFO queue. The emails will be sent out in the same order as the payment responses.
2. Circular Queue
A circular queue is also called a circular buffer or a ring buffer. Its last element is linked to the first element. Insertion takes place at the front of the queue and deletion at the end of the queue.
A famous implementation is LMAXβs low-latency ring buffer. Trading components talk to each other via a ring buffer. This is implemented in memory and super fast.
3. Priority Queue
The elements in a priority queue have predefined priorities. We take the element with the highest (or lowest) priority from the queue. Under the hood, it is implemented using a max heap or a min heap where the element with the largest or lowest priority is at the root of the heap.
A typical use case is assigning patients with the highest severity to the emergency room while others to the regular rooms.
4. Deque
Deque is also called double-ended queue. The insertion and deletion can happen at both the head and the tail. Deque supports both FIFO and LIFO (Last In First Out), so we can use it to implement a stack data structure.
πΉ Over to you: Which type of queue have you used?
β
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): https://t.co/uc5M7CdXXC