On this e-newsletter, we’ll speak concerning the following:
Common interview query: What’s the distinction between Course of and Thread?
To raised perceive this query, let’s first check out what’s a Program. A Program is an executable file containing a set of directions and passively saved on disk. One program can have a number of processes. For instance, the Chrome browser creates a unique course of for each single tab.
A Course of means a program is in execution. When a program is loaded into the reminiscence and turns into energetic, this system turns into a course of. The method requires some important assets reminiscent of registers, program counter, and stack.
A Thread is the smallest unit of execution inside a course of.
The next course of explains the connection between program, course of, and thread.
1. This system accommodates a set of directions.
2. This system is loaded into reminiscence. It turns into a number of working processes.
3. When a course of begins, it’s assigned reminiscence and assets. A course of can have a number of threads. For instance, within the Microsoft Phrase app, a thread may be answerable for spelling checking and the opposite thread for inserting textual content into the doc.
Important variations between course of and thread:
🔹 Processes are normally unbiased, whereas threads exist as subsets of a course of.
🔹 Every course of has its personal reminiscence house. Threads that belong to the identical course of share the identical reminiscence.
🔹 A course of is a heavyweight operation. It takes extra time to create and terminate.
🔹 Context switching is dearer between processes.
🔹 Inter-thread communication is quicker for threads.
Over to you:
1). Some programming languages assist coroutine. What’s the distinction between coroutine and thread?
2). The right way to listing working processes in Linux?
Interview Query: Design Twitter
This submit is a abstract of a tech speak given by Twitter in 2013. Let’s have a look.
The lifetime of a Tweet
1️⃣ A tweet is available in by means of the Write API.
2️⃣ The Write API routes the request to the Fanout service.
3️⃣ The Fanout service does lots of processing and shops them within the Redis cache.
4️⃣ The Timeline service is used to seek out the Redis server that has the house timeline on it.
5️⃣ A consumer pulls their dwelling timeline by means of the Timeline service.
Search & Discovery
🔹 Ingester: annotates and tokenizes Tweets so the info could be listed.
🔹 Earlybird: shops search index.
🔹 Blender: creates the search and discovery timelines.
Push Compute
🔹HTTP push
🔹Cell push
Disclaimer: This text relies on the tech speak given by Twitter in 2013 (https://bit.ly/3vNfjRp). Regardless that a few years have handed, it’s nonetheless fairly related. I redraw the diagram as the unique diagram is tough to learn.
Over to you: Do you employ Twitter? What are a number of the greatest variations between LinkedIn and Twitter that may form their system architectures?
A visible information on how to decide on the appropriate Database.
Choosing a database is a long-term dedication so the choice shouldn’t be made frivolously. The necessary factor to bear in mind is to decide on the appropriate database for the appropriate job.
Knowledge could be structured (SQL desk schema), semi-structured (JSON, XML, and many others.), and unstructured (Blob).
Widespread database classes embody:
🔹 Relational
🔹 Columnar
🔹 Key-value
🔹 In-memory
🔹 Broad column
🔹 Time Sequence
🔹 Immutable ledger
🔹Geospatial
🔹Graph
🔹Doc
🔹Textual content search
🔹Blob
Thanks, Satish Chandra Gupta
Over to you – Which database have you ever used for which workload?
Distinctive ID Generator
IDs are crucial for the backend. Are you aware tips on how to generate globally distinctive IDs?
On this submit, we’ll discover frequent necessities for IDs which might be utilized in social media reminiscent of Fb, Twitter, and LinkedIn.
Necessities:
🔹Globally distinctive
🔹Roughly sorted by time
🔹Numerical values solely
🔹64 bits
🔹Extremely scalable, low latency
The implementation particulars of the algorithms could be discovered on-line so we is not going to go into element right here.
Over to you: What sort of ID mills have you ever used?