<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[System Design From Scratch]]></title><description><![CDATA[A newsletter about building software systems with first principles.]]></description><link>https://systemdesignfromscratch.org</link><image><url>https://substackcdn.com/image/fetch/$s_!hyee!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b5863-6e28-4ece-85b0-5aa8fe2632cc_608x608.png</url><title>System Design From Scratch</title><link>https://systemdesignfromscratch.org</link></image><generator>Substack</generator><lastBuildDate>Fri, 23 Oct 2026 10:10:04 GMT</lastBuildDate><atom:link href="https://systemdesignfromscratch.org/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Mandeep Singh]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[msdeep14@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[msdeep14@substack.com]]></itunes:email><itunes:name><![CDATA[Mandeep Singh Shekhawat]]></itunes:name></itunes:owner><itunes:author><![CDATA[Mandeep Singh Shekhawat]]></itunes:author><googleplay:owner><![CDATA[msdeep14@substack.com]]></googleplay:owner><googleplay:email><![CDATA[msdeep14@substack.com]]></googleplay:email><googleplay:author><![CDATA[Mandeep Singh Shekhawat]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[MUST-KNOW Concurrency Concepts for System Design Interviews]]></title><description><![CDATA[Concurrency is critical discussion point in Low-Level System design discussions]]></description><link>https://systemdesignfromscratch.org/p/must-know-concurrency-concepts-for</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/must-know-concurrency-concepts-for</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Sun, 18 Oct 2026 10:31:07 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!weIi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I made a <a href="https://github.com/msdeep14/getAheadWithMe/tree/main/LowLevelDesign/Concurrency">lot of notes</a> during my interview preparation and it was lost in GitHub commit history. These notes were quite helpful during my interviews, specifically for low-level design (LLD) interviews. You can use them as a reference for your interview preparation as well. Best of Luck :) </p><blockquote><ul><li><p>Few of the concepts are specific to JAVA. I used to write a lot of Java and Kotlin code earlier :)</p></li><li><p>The information is compiled here basis my understanding by reading multiple blogs/oracle docs/videos and is mostly suitable for interview preparation. You can explore more on internet (some references are also included) for further deep dive.</p></li><li><p>These are self-written notes without AI help, so don&#8217;t expect nice and fancy English. Written in minimal terms for quick revision and reference for interviews.</p></li><li><p>There are additional code samples in GitHub repo: <a href="https://github.com/msdeep14/getAheadWithMe/tree/main/LowLevelDesign/Concurrency">msdeep14/getAheadWithMe</a>.</p></li></ul></blockquote><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Let&#8217;s start the discussion with the most basic term, process.</p><h2>Process</h2><p>You can think of process as a sequence of steps to be performed to achieve a task. Here are some key details on how processes work on an Operating System (OS).</p><ul><li><p>Process has separate memory allocated space. A process doesn&#8217;t share memory with other processes. This ensures complete isolation of processes from each other. In summary, one process&#8217;s state don&#8217;t impact the state of another process.</p></li><li><p>Processes interact with each other via Inter process communication (IPC) mechanisms such as Shared Memory or Message passing.</p></li><li><p>Processes take more time in creation, termination, context switching (in comparison to threads, discussed shortly). <strong>Why?</strong> Because process has its own Process Control Block(PCB), stack and address space. Separate data segment and code segment is created at each process level.  </p></li><li><p>A process goes through multiple states. These states include <code>NEW</code>, <code>READY</code>, <code>RUNNING</code>, <code>WAITING</code>, <code>TERMINATED</code> and <code>SUSPENDED</code>.</p></li><li><p>Process creation requires OS API call - fork(). For example, <a href="https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Process.html">java.lang.Process</a> for JAVA.</p></li><li><p>Processes don&#8217;t require synchronization between them unlike threads where synchronization needs to explicitly managed to avoid unwanted issues.</p></li></ul><p>There is mention of threads at couple of places above, let&#8217;s discuss threads next.</p><h2>Threads</h2><p>Think of thread as sub step of a process. A thread can be referred to as a light-weight process. Multiple threads can be created inside a process to carry out specific actions. Here are couple of characteristics associated to a thread.</p><ul><li><p>Threads share the memory space which makes them less latent.</p></li><li><p>If one thread is blocked within a process, it will also impact other threads in the same process.</p></li><li><p>Each thread in process has their own stack and register.</p></li></ul><p>A thread can be of multiple types, let&#8217;s discuss the thread types next.</p><h3>Thread Types</h3><p>A thread can be of two types, user level and kernel level.</p><p><strong>User Level Thread:</strong> Threads managed by users and created via user-level libraries such as JAVA Thread library.</p><p><strong>Kernel Level Thread:</strong> Threads managed by kernel. Kernel-level threads are created via OS system calls.</p><h3>Java Virtual Threads</h3><p>Light-weight implementation of Java threads. 1 Java Thread == 1 OS thread, which is resource intensive. Virtual threads store their stack frames in Java&#8217;s garbage-collected heap rather than in monolithic blocks of memory allocated by the operating system.</p><p>A good read - <a href="https://www.infoq.com/articles/java-virtual-threads/">infoQ article</a>. I earlier mentioned there is no need of synchronization for processes but it is for threads. Let&#8217;s discuss what I mean from thread-safe.</p><h3>Thread-safe</h3><p>Thread-safe class/method/codeBlock means a class/method/codeBlock that can used by multiple threads concurrently without any issues. The output of threads should be same as if they were processed sequentially.</p><p>Singleton is class used by multiple threads as a single object exists. The singleton class should be thread-safe. This is also referred to as Double-Checked locking with Singleton. Refer <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/practice/threadsafesingleton/ThreadSafeSingleton.java">ThreadSafeSingleton class</a> for code implementation.</p><p>If the code is not written properly, e.g. one thread block another thread for execution, the situation can lead to deadlock. Let&#8217;s discuss deadlock next.</p><h2>Deadlock</h2><p>A process/thread is in waiting state because it is waiting for a resource that is held by another process P2. P2 is waiting on another resource held by P3. P3 is waiting for another resource held by P1. All the processes are waiting on each other without being progressing eventually leading to deadlock situation.</p><p><strong>Deadlock conditions:</strong> All four conditions should satisfy for system to be in deadlock state -</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><ul><li><p>Mutual Exclusion: resources can&#8217;t be shared by multiple processes at the same time.</p></li><li><p>Hold and Wait: holding resource and waiting for other resource.</p></li><li><p>No Preemption: resources acquired by process can only be released by itself once execution completes.</p></li><li><p>Circular Wait: processes waiting on each other.</p></li></ul><p>There are ways to avoid being in deadlock situation. If deadlock occurs, the system should get out of it. Let&#8217;s discuss them next.</p><h3>Deadlock Handling</h3><p>We&#8217;ll discuss three techniques for deadlock handling: prevention, avoidance and detection.</p><p><strong>Deadlock Prevention:</strong> Don't let system enter into deadlock state by avoiding any of the four conditions specified in above section.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3jeB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3d5914-17d4-4962-bc64-6844cbb4e71e_1241x385.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3jeB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3d5914-17d4-4962-bc64-6844cbb4e71e_1241x385.png 424w, https://substackcdn.com/image/fetch/$s_!3jeB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3d5914-17d4-4962-bc64-6844cbb4e71e_1241x385.png 848w, https://substackcdn.com/image/fetch/$s_!3jeB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3d5914-17d4-4962-bc64-6844cbb4e71e_1241x385.png 1272w, https://substackcdn.com/image/fetch/$s_!3jeB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3d5914-17d4-4962-bc64-6844cbb4e71e_1241x385.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3jeB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3d5914-17d4-4962-bc64-6844cbb4e71e_1241x385.png" width="1241" height="385" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1c3d5914-17d4-4962-bc64-6844cbb4e71e_1241x385.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:385,&quot;width&quot;:1241,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:705250,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://systemdesignfromscratch.org/i/219425084?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3d5914-17d4-4962-bc64-6844cbb4e71e_1241x385.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3jeB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3d5914-17d4-4962-bc64-6844cbb4e71e_1241x385.png 424w, https://substackcdn.com/image/fetch/$s_!3jeB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3d5914-17d4-4962-bc64-6844cbb4e71e_1241x385.png 848w, https://substackcdn.com/image/fetch/$s_!3jeB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3d5914-17d4-4962-bc64-6844cbb4e71e_1241x385.png 1272w, https://substackcdn.com/image/fetch/$s_!3jeB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c3d5914-17d4-4962-bc64-6844cbb4e71e_1241x385.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Deadlock Avoidance:</strong> The resource request is analyzed before-hand to ensure if it can cause any deadlock situations in the future. To perform this analysis, it requires all the information in advance around how resources will be requested/used in the future. Deadlock avoidance algorithm - <a href="https://en.wikipedia.org/wiki/Banker%27s_algorithm">Banker's algorithm</a>.</p><p><strong>Deadlock Detection: </strong></p><ol><li><p>Check process state for deadlock in system.</p></li><li><p>If <code>isDeadlock == true</code>, apply algorithm for deadlock resolution.</p><ol><li><p>Process Termination: Abort the processes involved in deadlock. This might result in program failures as process might be partially completed. Instead of all process abort, system can look for processes which are of low priority or are running for too long in the system.</p></li><li><p>Resource Preemption: resources are preempted and allocated to other processes until deadlock is resolved.</p></li></ol></li></ol><p>Moving on to a similar concept to deadlock, livelock.</p><h2>LiveLock</h2><p>The threads/processes are not blocked as in deadlock situation but the state keep on changing from one to another and not making any further progress. </p><p><strong>Example:</strong> </p><p>Queue Message processing: Queue consumer failed with exception and it puts back to queue in hope that it will processed next time but it keeps on failing again and again with same exception.  A solution could be to keep a upper limit on number of retries for specific failure if msgs are put into dead-letter queue. Failed msgs should anyway never be put in the same queue again for re-processing.</p><h2>Starvation</h2><p>Process in on hold because resources are not allocated to it. This could happen if resources keep getting allocated to high priority threads and low priority threads keep on waiting.</p><p>Some ways to avoid starvation situation -</p><ol><li><p>Age of process - If process is too old, it should be given priority for resource allocation even though it is low priority task.</p></li><li><p>Multi-level feedback queue - <a href="https://www.geeksforgeeks.org/multilevel-feedback-queue-scheduling-mlfq-cpu-scheduling/">geeksforgeeks article</a></p></li></ol><h2>Mutex vs Semaphore</h2><h4><strong>Semaphore</strong></h4><p>Semaphores can be used to manage access of limited resources(via counting semaphores) or to resolve critical section problem(via binary semaphores).</p><p>Refer <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/semaphoremutex/SemaphoreImpl.java">SemaphoreImpl class</a> for sample example.</p><h4><strong>Mutex</strong></h4><p><code>Mutex = Mutual Exclusion</code>. It is <strong>similar</strong> to binary semaphore which ensures only one thread can acquire it and access the critical section.</p><ol><li><p>Mutex is a locking mechanism whereas semaphore is signalling mechanism. The context which acquired the mutex lock can only release it but this is not the case with semaphores.</p></li><li><p>The #1 can prove to be downside if mutex lock is not released as it can&#8217;t be unlocked from different context than who acquired it leading to starvation.</p></li></ol><h2>I/O Bound vs CPU Bound</h2><p><strong>I/O Bound:</strong> Application is referred as I/O bound if it involves reading/writing from/to input/output system and waiting for information. </p><p>The main disadvantage of such applications could be the application can be spending too much time in I/O operations without doing any actual operations. Example - upload/download files.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share System Design From Scratch&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://systemdesignfromscratch.org/?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share System Design From Scratch</span></a></p><p><strong>CPU Bound:</strong> Task/process execution is dependent on CPU without requiring any I/O operations. Example - High Performance computing</p><h2>Blocking I/O vs Non-Blocking I/O</h2><h4><strong>Blocking I/O</strong></h4><p>The request waits for server to complete its processing. In general terms, the request will wait for read or write before returning back meaning the thread will be blocked state until there is data available for read or ongoing write operation is fully completed.</p><p>Blocking I/O operations are available with java.io package.</p><ol><li><p>One byte data at a time - <code>InputSteam</code> and <code>OutputStream</code></p></li><li><p>Wrapper for streams - <code>Reader</code> and <code>Writer</code>.</p></li></ol><h4><strong>Non-Blocking I/O</strong></h4><p>The request is executed immediately. There could be possibility that request is not processed as soon as it is received, if there are no available threads to process the request, the request is queued(to be processed at later point of time) and response is returned. Other way to look at is if there is ongoing write operation, the thread can perform any other operation.</p><p>In analogy to event-driven architecture, you can think of this scenario as communication between service A and service B. service A invokes service B API for some processing and gets a response that request is received by service B. Once the request processing completes by service B, it can publish an event to SNS topic(or Kafka topic) to which service A is subscribed. service A can then perform any additional required processing basis Service B response.</p><p>Non-Blocking I/O operations are available with java.nio package.</p><ol><li><p>Read chunks of data at a time - <code>Buffer</code>.</p></li><li><p>Mapping raw bytes to/from readable characters - <code>CharsetDecoder</code></p></li><li><p>Outside world communication - <code>Channel</code></p></li><li><p>Enable multiplexing on a SelectableChannel and provide access to any Channels which are ready for I/O - <code>Selector</code>.</p></li></ol><h2>Volatile/ Atomic Integer/ Synchronized</h2><h3>Volatile Keyword</h3><p>Volatile keyword is used inside a class to make it thread-safe. It can be used for any variable such as value of it can be modified by different threads at same time without any problem.</p><ol><li><p>It can be used for primitive or object types though it can&#8217;t be used with classes/methods.</p></li><li><p>Volatile keyword enforces to always read variable value from main memory and it is not cached. Both reads and writes will be atomic.</p></li><li><p>Compiler don&#8217;t perform any optimization and order of instructions is maintained.</p></li><li><p>It can be used as replacement of <code>synchronized</code> in specific cases.</p></li></ol><p><strong>NOTE 1 -</strong> Visibility problem is created without the usage of volatile keyword. How? Any modification performed by a thread A is updated thread A&#8217;s local cache so thread B will still assume previous value of any variable. This can be solved by volatile keyword as volatile enforces to read always from main memory and not from local thread cache.</p><p><strong>NOTE 2-</strong> volatile can be used to resolve visibility practice, prefer to use it for setting flag variables. For compound operations or counters, prefer AtomicInteger/AtomicLong/AtomicReference.</p><h3>Atomic Integer</h3><p><code>java.util.concurrent.atomic.AtomicInteger</code>. Refer the sample example and comparison of volatile, AtomicInteger and synchronized keyword in class <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/volatilesample/VolatileKeywordImpl.java">VolatileKeywordImpl</a>.</p><pre><code><code>AtomicInteger count = new AtomicInteger(1);
</code></code></pre><p>Operations available with AtomicInteger -</p><ol><li><p>incrementAndGet</p></li><li><p>decrementAndGet</p></li><li><p>addAndGet(int delta)</p></li><li><p>compareAndSet(int expectedValue, int newValue) - Type of optimistic locking.</p></li></ol><p><strong>NOTE -</strong> AtomicReference provides atomic operations on underlying object reference variable.</p><h3>Synchronized</h3><p>Synchronized keyword over a method or block of code ensures only single threads access it at a time avoiding race conditions.</p><p>Refer <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/volatilesample/SynchronizeSample.java">SynchronizeSample class</a> for example.</p><ol><li><p>Any object in synchronized block is placed inside a lock(lock acquired on start of block and released at end of the block). The lock is internal monitor which is responsible for checking synchronization.</p></li><li><p>Synchronized keyword should not be used with constructors/variables.</p></li></ol><h2>Locks</h2><p>Locks can be used to ensure single thread access the critical section at a time. Think of lock as a guard to critical section and this guard provides key to enter the critical section and while leaving critical section, handover this key back to guard. Java Lock is similar to synchronized block discussed in above section.</p><h3>Reentrant Locks</h3><p><code>private static Lock lock = new ReentrantLock()</code>.</p><ol><li><p>synchronized is implicit lock and locks are explicit. We need to specifically define variable to create a lock and use it in the code block.</p></li><li><p>You can acquire the lock in one method and release in another method. There is no such flexibility in synchronized keyword.</p></li><li><p>tryLock() method with Locks which can be used to check if lock is available.</p></li><li><p>ReentrantLocks allows to call lock.lock() multiple times without calling unlock(). Finally you can unlock() for the number of times lock() was called. <code>getHoldCount()</code> can be used to check how many times to lock() is called.</p></li><li><p>To make the lock fair, use <code>lock = new ReentrantLock(true)</code>. This ensures that longest waiting thread gets the lock. Fair locks can be little slower as an extra queue needs to be maintained based ageing. Unfair lock could be faster, but it can potentially lead to thread starvation in some cases.</p></li><li><p>tryLock() doesn&#8217;t honor lock fairness. To make it fair, use <code>lock.tryLock(0, TimeUnit.SECONDS)</code>.</p></li></ol><p>Refer <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/locksample/LockSample.java">LockSample class</a>.</p><h3>ReadWrite Locks</h3><p>Reentrant locks can be inefficient if there are threads blocked which only want to read some data. ReadWriteLocks helps to optimize this kind of use-case.</p><ol><li><p>Reentrant lock - one thread at a time.</p></li><li><p>ReadWrite lock - one writer thread at a time <strong>OR</strong> multiple reader threads at a time. Key Point - Both read and write threads will not be given permission simultaneously, either one of them can execute at a time.</p></li><li><p>ReadWrite lock can be efficient for use-cases which requires high number of reads and less writes in general.</p></li></ol><p>Refer <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/locksample/ReadWriteLock.java">ReadWriteLock class</a>.</p><h3>Optimistic and Pessimistic Locking</h3><p><strong>Pessimistic Locking -</strong> Lock the object beforehand performing any operation. Java synchronized keyword is example of pessimistic locking. It has extra performance bottleneck as threads have to wait unless permitted to execute specific operation.</p><p><strong>Optimistic Locking -</strong> As name suggests, in this approach you can go ahead and execute the operation with assumption that no other thread will interfere. It relies on collision detection and handle if detected via retry/failure. Java CompareAndSwap is example of optimistic locking.</p><h3>Two-Phase Locking</h3><p>Locking and unlocking has two phases -</p><ol><li><p>Growing Phase - Locks are obtained but not released.</p></li><li><p>Shrinking Phase - Locks are released but no new locks are obtained.</p></li></ol><p>This ensures serializability but can cause deadlock, starvation and cascading rollback.</p><p>The last lock acquired in growing phase is referred as <strong>Lock Point</strong>. Lock Points are used to define serializability, example basis lock point you can identify which transaction comes first in series of transactions.</p><h2>Phaser, CountDownLatch and CyclicBarrier</h2><p>Read more <a href="https://www.oracle.com/technical-resources/articles/javase/concurrent-programming.html">on oracle docs</a>. Here is the summary of these terms.</p><h4><strong>CountDownLatch</strong></h4><p>This is helpful in scenarios if there is requirement to initialize some piece of code before executing further system logic or other threads. Think of a scenario, where database connection to be established before other threads can actually carry out the db query operations.</p><p>Refer <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/countDownLatchPhaserCyclicBarrier/CountDownLatchSample.java">CountDownLatchSample class</a>.</p><h4><strong>CyclicBarrier</strong></h4><p>Set of threads wait for each other to reach a common barrier point. and once common point is reached, then all the threads can carry forward their execution.</p><p><strong>Why cyclic?</strong> The same barrier can be used again and again among the threads.</p><h4><strong>Phaser</strong></h4><p>It is similar to CountDownLatch with some added functionalities. Phaser allows dynamic number of threads that needs to wait for continuing execution, in countDownLatch, we specific fixed number of parties upon initialization.</p><ol><li><p>register() - party can register itself</p></li><li><p>bulkRegister() - extra parties register in bulk</p></li><li><p>arrive() - parties can arrive and continue</p></li><li><p>arriveAndAwaitAdvance() - parties can arrive and await for other parties.</p></li><li><p>arriveAndDeregister() - Parties can arrive, deregister and continue.</p></li></ol><h2>Conditions</h2><p>Take an example of Thread-1 and Thread-2. Thread-1 complete execution in two stages. Stage-1 and Stage-2. Stage-1 is executed and the execution of State-2 is dependent on completion of Thread-2. In such scenarios, Thread-1 will put an additional condition <code>condition.await()</code> to put thread in blocked state. Once Thread-2 execution is completed, it will run <code>condition.signal()</code> or <code>condition.signalAll()</code> and with this signal all the threads which are blocked on this condition will carry forward their execution.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://systemdesignfromscratch.org/subscribe?"><span>Subscribe now</span></a></p><p>This is similar to <code>monitor.wait()</code> and <code>monitor.notify()</code> in synchronized code block.</p><p>Refer <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/locksample/ConditionSample.java">ConditionSample class</a>.</p><h2>wait(), notify() and notifyAll()</h2><p><code>wait()</code>, <code>notify()</code> and <code>notifyAll()</code> can be used in replacement of conditions. They can be applied on any java object.</p><ol><li><p>wait() - similar to myCondition.await()</p></li><li><p>notify() - similar to myCondition.signal()</p></li><li><p>notifyAll() - similar to myCondition.signalAll()</p></li></ol><p>Refer <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/practice/producerconsumer/lockCondition/MyBlockingQueue.java">MyBlockingQueue class</a> and <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/practice/producerconsumer/waitNotify/MyBlockingQueue2.java">MyBlockingQueue2 class</a> for sample examples.</p><h2>ExecutorService</h2><p><code>1 Java Thread == 1 OS Thread</code></p><p>How to run tasks in parallel? via using Thread class.</p><pre><code><code>for(int i=0;i&lt;1000;i++) {
   Thread thread = new Thread(some Runnable);
   thread.start();
}
</code></code></pre><p>The above operation will be too expensive as 1000 threads are being created at the same time which could lead to system crash.</p><p>To solve this problem, you can create a pool of threads and submits the large list of tasks to them. Now the tasks can be picked up as there are free threads present in the thread pool which are being maintained in a BlockingQueue.</p><p>Example - ThreadPool size = 10, even though submitted task size = 1000, the system will execute max 10 tasks at a time.</p><pre><code><code>   ExecutorService service = Executors.newFixedThreadPool(10);
   for(int i=0;i&lt;1000;i++) {
      service.execute(Runnable task);
   }
</code></code></pre><h3>submit() vs execute()</h3><p><strong>submit()execute()</strong>return type is Futurereturn type is voidBoth Runnable and Callable can be passedRunnable task can be passed as input</p><h3>ThreadPool Types</h3><ol><li><p>FixedThreadPool - initialize thread pool with fixed number of threads.</p></li><li><p>CachedThreadPool - tasks are held in synchronous queue. It will check if there are already available free threads, if yes then use one from available else create a new thread and assign task to it. This threadPool kills the idle threads with lifecycle more than 60 seconds.</p></li><li><p>ScheduledThreadPool - tasks that are required to be submitted after certain delay or require scheduling. It stores the tasks in delayQueue which stores tasks basis when these tasks should be executed(priority order is basis that).</p><ol><li><p>service.schedule(Runnable, delay:10, SECONDS). Task will be enabled after 10 seconds.</p></li><li><p>service.scheduleAtFixedRate(Runnable, initialDelay:15, period:10, SECONDS). First task will start after 15 seconds. Subsequent tasks will execute at initialDelay+period, then initialDelay+2*period, and so on...</p></li><li><p>service.scheduleAtFixedDelay(Runnable, initialDelay:15, delay:10, TimeUnit.SECONDS). First task will start after 15 seconds. Once this is completed, second will start after 10 seconds of 1st task completion.</p></li></ol></li><li><p>SingleThreadedExecutor - similar to FixedThreadPool with <code>numThreads=1</code></p></li></ol><h3>Future</h3><ol><li><p>Placeholder for value that will arrive sometime in the future.</p></li><li><p>To get actual response of <code>submit()</code>, use <code>future.get()</code>.</p></li><li><p>get() is blocking operation - it will wait until the thread result is returned. We can use <code>future.get(1000, TimeUnit.MILLISECONDS)</code> to specify a timeout value for it to be blocked state if result is not available.</p></li></ol><h3>Runnable vs Callable</h3><p>Runnable return type is void whereas Callable can return a value.</p><p>Refer <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/practice/generalPatterns/RunnableVsCallable.java">RunnableVsCallable class</a> for example.</p><h3>CompletableFuture</h3><ol><li><p>Assume you&#8217;ve used a for loop to gather all the results from callables.</p></li><li><p>There is possibility that as your iterate over future list, not all futures are computed at a moment.</p></li><li><p>In such scenario, the thread will blocked for time being until the future result arrives for specific thread.</p></li><li><p>There can be a case in which you&#8217;re waiting at 4th thread whose result is not computed yet but results for 10th and 11th thread are already in.</p></li><li><p>But since you&#8217;re iterating in for loop, you&#8217;ll still be blocked on 4th thread.</p></li><li><p>How can you overcome this?</p><ol><li><p>use timeout value on <code>future.get(1000, TimeUnit.MILLISECONDS)</code></p></li><li><p>use CompletableFuture to run threads independently.</p></li><li><p>Use ExecutorCompletionService - helps in processing the threads as their execution completes.</p></li></ol></li></ol><p>CompletableFuture helps to run a series of tasks on a separate thread than the main thread. Consider an example of uploading a youtube video on <a href="https://www.youtube.com/@MsDeepSingh">@MsDeepSingh</a> channel, what are the steps.</p><ol><li><p>upload video file from local store.</p></li><li><p>run validation checks</p></li><li><p>upload in SD format</p></li><li><p>upload in HD format.</p></li></ol><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/p/must-know-concurrency-concepts-for?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://systemdesignfromscratch.org/p/must-know-concurrency-concepts-for?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p>Now these steps should be executed one after another and also there could be multiple users who are uploading videos on their YT channels. CompletableFuture makes it easier to code such pattern with proper exception handling.</p><h3>ExecutorCompletionService</h3><p>ExecutorCompletionService helps to retrieve response as Futures finish. Refer <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/practice/generalPatterns/ExecutorCompletionServiceSample.java">ExecutorCompletionServiceSample class</a> for example.</p><h2>ForkJoinPool</h2><p>Achieve similar functionality to ExecutorService. ForkJoinPool is optimized for use-cases where tasks creates sub-tasks on the go. Example - mergesort. As the name suggests, ForkJoin consists of two operations -</p><ol><li><p>fork - divide task into sub-tasks</p></li><li><p>Join - aggregate the result of sub-tasks.</p></li></ol><p><strong>Per-thread queuing -</strong> Each thread has their own deque, so all the sub-tasks will be part of this deque.</p><p><strong>Work-Stealing algorithm</strong> Take a scenario of two threads, Thread-1 and Thread-2. In a scenario where Thread-1 created large number of sub-tasks and Thread-2 has very less number of sub-tasks. Once Thread-2 completes its subtasks, it will subtasks from Thread-1(from other end of the queue) to help out in processing of subtasks. In simple terms, available threads take up tasks from busy threads.</p><h2>Synchronous Queue</h2><p>Synchronous queue is similar to blocking queue with size=1. Refer producer-consumer example to understand about blocking queue.</p><p>so why do we need a queue with size=1?</p><blockquote><p>There is direct handoff between producer and consumer. The item is not moved to queue. The producer will not be allowed to put item into queue even though the queue is empty. The producer is only allowed to put item to queue once consumer requests for item. Well, technically item is not put into the queue. The item is passed on once consumer thread requests for it.</p></blockquote><h2>ConcurrentModificationException</h2><p>When collection is modified when already an operation is going on. Example, iterating over the list and at the same time removing of an element.</p><h2>Monitors</h2><p>Monitors are nothing but implementation of <code>synchronized</code> keyword in JAVA. Monitor is an abstraction that helps to achieve mutual exclusion between multiple threads trying to access a resource concurrently.</p><p>Additionally in JAVA, any object can act as a monitor utilizing <code>wait()</code> and <code>notify()</code> methods. Refer <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/practice/producerconsumer/waitNotify/MyBlockingQueue2.java">MyBlockingQueue2 class</a> for example.</p><h2>Practice</h2><h3>Producer Consumer Problem</h3><ol><li><p>Multiple producers and consumers.</p></li><li><p>Producer is responsible for generation of new tasks.</p></li><li><p>Consumer is responsible for executing the tasks created by producer.</p></li></ol><p>Clarifying questions -</p><ol><li><p>What&#8217;s the maximum number of tasks that producers can produce? Is there any upper cap? For this problem, assume producers will produce max n tasks and then wait for consumer to consume.</p></li><li><p>The scale of operation, how many producers? how many consumers?</p></li></ol><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Enjoying the article? Subscribe for more such posts via System Design From Scratch newsletter!</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Approach - Producer</p><ol><li><p>Create a FIFO queue with max size = n</p></li><li><p>Producer threads will put tasks to queue until full.</p></li><li><p>Block producer threads if queue capacity is full.</p></li><li><p>Publish a signal that queue is not empty.</p></li></ol><p>Approach - Consumer</p><ol><li><p>Get tasks from queue if queue is not empty.</p></li><li><p>Block consumer threads if queue is empty.</p></li><li><p>Publish a signal that queue is not full anymore once consumer fetches a task.</p></li></ol><h3>Dining Philosopher&#8217;s Problem</h3><p>Round dining table where philosophers are sat. There can be two states for them -</p><ol><li><p>Eating</p></li><li><p>Thinking</p></li></ol><p>They need to make use of forks, philosopher need two forks adjacent to him and starts eating. Problem? The forks are limited, with 5 philosophers there are only 5 forks but philosopher need two forks to start eating, so all philosophers can&#8217;t each at the same time.</p><ol><li><p>No philosophers who are adjacent to each other should not eat at the same time.</p></li><li><p>A philosopher may pick up only one fork at a time.</p></li><li><p>Philosopher can&#8217;t pick fork from neighbour&#8217;s hand.</p></li><li><p>Once philosopher is done eating, he puts back the forks on the table.</p></li></ol><p>Why solve such problem? - Problem of resource utilization and how limited set of resources can be allocated to bunch of processes.</p><p><strong>Solution Approach</strong></p><ol><li><p>Each fork is represented by semaphore.</p></li><li><p>Philosopher picks up fork and put corresponding semaphore to <code>await()</code> state.</p></li><li><p>Once done eating, philosopher releases both left and right fork with <code>signal()</code> operation.</p></li></ol><pre><code><code>//binary semaphore, initialized to 0
Semaphore forks[5];

for philosopher i
do {
    //change semaphore value to 1 ---&gt; java: semaphore[i].acquire();
    await(fork[i])
    await(fork[(i+1)%5])
    //eat
    
    //change semaphore value back to 0 ---&gt; java: semaphore[i].release();
    signal(fork[i])
    signal(fork[(i+1)%5]);
    
    //think
} while(true);
</code></code></pre><p>Any issues with above approach? Deadlock situation - All the philosophers get hungry at the same time and pick up the left fork. Now all the philosophers are waiting for fork in the right and none of them is actually eating.</p><p>Potential solutions -</p><ol><li><p>Allow only 4 philosophers at the table for the table of 5.</p></li><li><p>Allow philosopher to pick up a fork only if both forks are available. - execute code in critical section - Refer <a href="https://en.wikipedia.org/wiki/Dining_philosophers_problem">wikipedia blog for Dijkstra&#8217;s solution</a>.</p></li><li><p>Asymmetric solution - odd philosopher picks up first left fork and right fork; even philosopher picks up first right fork and then left fork. This can also be achieved by - All the philosophers pick up their left fork except the last one, so essentially the 5th philosopher will pick right fork first and then the left fork. Refer this implementation in <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/practice/diningphilosopher/DiningPhilosophers.java">DiningPhilosophers class</a>.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!weIi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!weIi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg 424w, https://substackcdn.com/image/fetch/$s_!weIi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg 848w, https://substackcdn.com/image/fetch/$s_!weIi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!weIi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!weIi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg" width="1168" height="784" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:784,&quot;width&quot;:1168,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:296151,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://systemdesignfromscratch.org/i/219425084?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!weIi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg 424w, https://substackcdn.com/image/fetch/$s_!weIi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg 848w, https://substackcdn.com/image/fetch/$s_!weIi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!weIi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2b017c7-52f1-482a-9a0a-c2a7ff71a5ce_1168x784.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>&lt;image generated using Grok&gt;</p><h2>Practice</h2><ol><li><p>Leetcode problemset - <a href="https://leetcode.com/problemset/concurrency/">https://leetcode.com/problemset/concurrency/</a></p></li><li><p><a href="https://www.careercup.com/page?pid=threads-interview-questions">https://www.careercup.com/page?pid=threads-interview-questions</a></p></li><li><p>Refer to <a href="https://github.com/msdeep14/getAheadWithMe/blob/main/LowLevelDesign/Concurrency/src/practice">src/practice folder for problem set</a>.</p></li></ol>]]></content:encoded></item><item><title><![CDATA[System Design From Scratch]]></title><description><![CDATA[New O&#8217;Reilly book in early release, not a regular System Design interview preparation book...]]></description><link>https://systemdesignfromscratch.org/p/system-design-from-scratch</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/system-design-from-scratch</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Thu, 08 Oct 2026 11:51:24 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!mIiU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You&#8217;re reading the newsletter &#8216;System Design From Scratch&#8217; but I&#8217;m also working on a book with the same name in partnership with O&#8217;Reilly. Two chapters from the book are in <a href="https://learning.oreilly.com/library/view/system-design-from/0642572384012/">early-release</a> on the O&#8217;Reilly platform. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts and updates on O&#8217;Reilly book.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p><strong>What&#8217;s early release?</strong> Well you get hands on the content before it&#8217;s edited or technically reviewed. It helps to gather feedback from larger audience and incorporate it before hard copies are out.</p><h2>About the Book</h2><p>As a product grows from a proof of concept to a large-scale distributed system, its design has to evolve with it. <em>System Design from Scratch</em> follows that process, evaluating trade-offs involving scale, cost, expertise, time to market, resilience, and operational overhead at each stage.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mIiU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mIiU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg 424w, https://substackcdn.com/image/fetch/$s_!mIiU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg 848w, https://substackcdn.com/image/fetch/$s_!mIiU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!mIiU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mIiU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg" width="238" height="312.3205128205128" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1433,&quot;width&quot;:1092,&quot;resizeWidth&quot;:238,&quot;bytes&quot;:271346,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://systemdesignfromscratch.org/i/219409910?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mIiU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg 424w, https://substackcdn.com/image/fetch/$s_!mIiU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg 848w, https://substackcdn.com/image/fetch/$s_!mIiU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!mIiU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c752d47-07e3-4f1b-a45c-2bcb3b0ec1c7_1092x1433.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Software engineer Mandeep Singh takes an iterative approach to system design, showing you how choices around compute, databases, load balancing, caching, deployment, and software engineering principles change as systems scale. As you follow along, you&#8217;ll learn how to weigh technical and operational considerations and make choices that fit your organization&#8217;s needs.</p><ul><li><p>Understand how core system design concepts work together</p></li><li><p>Apply a decision framework to evaluate trade-offs involving scale, cost, expertise, time to market, and resilience</p></li><li><p>Make technical choices based on your organization&#8217;s needs</p></li><li><p>Design systems that are practical to run and maintain over time</p></li><li><p>Use AI as an assistant in system design or as a component of the system</p></li></ul><h2>What&#8217;s Unique? </h2><p>System Design content, wherever it&#8217;s available is theoretical and heavily influenced by the interview preparation. System Design From Scratch takes entirely a different approach, an approach of how you work in actual life. A Software Engineering journey.</p><blockquote><p><mark data-color="#ffff00" style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">The role of this book is to not act as a consultant giving recommendations, but as a fellow engineer working on the problem statement piece by piece and developing an understanding of system design from scratch.</mark></p></blockquote><p>System Design is not theoretical and it should not taught via theoretical means drawing boxes. Don't make system design decisions because you read on some blog. Experience the trade-offs first hand with my new O'Reilly book, &#8216;System Design From Scratch&#8217;.</p><h2>Practical, How?</h2><p>Practical means actually thinking, designing and building and deploying the systems. The journey mentioned earlier is followed via the GitHub repository - <a href="https://github.com/msdeep14/systemdesign-from-scratch">msdeep14/systemdesign-from-scratch</a>.</p><p>This is public GitHub repository, refer <code>README.md</code> to make best use of the repository. Feel free to contribute in any way possible :)</p><h2>Coming up, NEXT&#8230;</h2><p>I&#8217;ll use this newsletter to publish the Software Engineering journey for the chapters published as part of the book. Stay Tuned and subscribed for new updates. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for new updates.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Happy Building!</p>]]></content:encoded></item><item><title><![CDATA[Caching doesn’t mean Redis]]></title><description><![CDATA[Caching implementation at different layers of a service]]></description><link>https://systemdesignfromscratch.org/p/caching-doesnt-mean-redis</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/caching-doesnt-mean-redis</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Sun, 27 Sep 2026 10:31:44 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/0eb8539c-e948-4f21-ab19-c8fef0b2210f_495x252.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The database queries are taking too much time. What&#8217;s the common resolution?, a cache in front of a database. The answer might not be a right one, but this is direct response you get many times. </p><p>Cache doesn&#8217;t just mean Redis. Redis has an early advantage of market adoption but that doesn&#8217;t mean Redis is only solution. Caching is a general concept and today we&#8217;re going to uncover if adding a cache really helps. If it does, then at which layer (yes, there could be multiple layers) a cache should be added.</p><h2>Need For Caching</h2><p>A same request can be made multiple times by a single user or multiple users depending on the application behaviour. Processing the request and generating response takes time as well as processing power. Caching helps remove this bottleneck. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>The response once computed are stored in cache store, so user queries can be served from the cache instead of processing the request again and again.  You can very well use any datastore as a caching solution such as a relational database (e.g. PostgreSQL, MySQL) and in-memory data stores (e.g. Redis, valkey, dragonflydb).</p><p><mark data-color="#ffff00" style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">Read a detailed chapter </mark><strong><mark data-color="#ffff00" style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">&#8216;Caching Solutions and Strategies&#8217;</mark></strong><mark data-color="#ffff00" style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);"> in my O&#8217;Reilly book </mark><strong><a href="https://msdeepsingh.com/books/"><mark data-color="#ffff00" style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">System Design on AWS</mark></a></strong><mark data-color="#ffff00" style="background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);">.</mark></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VkFX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf32239e-a1a1-4803-809a-a0e7f23ec903_1024x1366.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VkFX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf32239e-a1a1-4803-809a-a0e7f23ec903_1024x1366.png 424w, https://substackcdn.com/image/fetch/$s_!VkFX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf32239e-a1a1-4803-809a-a0e7f23ec903_1024x1366.png 848w, https://substackcdn.com/image/fetch/$s_!VkFX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf32239e-a1a1-4803-809a-a0e7f23ec903_1024x1366.png 1272w, https://substackcdn.com/image/fetch/$s_!VkFX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf32239e-a1a1-4803-809a-a0e7f23ec903_1024x1366.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VkFX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf32239e-a1a1-4803-809a-a0e7f23ec903_1024x1366.png" width="220" height="293.4765625" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/af32239e-a1a1-4803-809a-a0e7f23ec903_1024x1366.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1366,&quot;width&quot;:1024,&quot;resizeWidth&quot;:220,&quot;bytes&quot;:1016395,&quot;alt&quot;:&quot;System Design on AWS&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://systemdesignfromscratch.org/i/215369220?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1438118-b47a-4250-8d81-4a139d6330e2_1024x1366.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="System Design on AWS" title="System Design on AWS" srcset="https://substackcdn.com/image/fetch/$s_!VkFX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf32239e-a1a1-4803-809a-a0e7f23ec903_1024x1366.png 424w, https://substackcdn.com/image/fetch/$s_!VkFX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf32239e-a1a1-4803-809a-a0e7f23ec903_1024x1366.png 848w, https://substackcdn.com/image/fetch/$s_!VkFX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf32239e-a1a1-4803-809a-a0e7f23ec903_1024x1366.png 1272w, https://substackcdn.com/image/fetch/$s_!VkFX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf32239e-a1a1-4803-809a-a0e7f23ec903_1024x1366.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://msdeepsingh.com/system_design/&quot;,&quot;text&quot;:&quot;System Design Resources&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://msdeepsingh.com/system_design/"><span>System Design Resources</span></a></p><p>Today&#8217;s blog talks about different caching layers and how a generalized solution can be implemented across the teams. It references <a href="https://careersatdoordash.com/blog/how-doordash-standardized-and-improved-microservices-caching/">DoorDash</a> internal implementation. Let&#8217;s start with the problem statement. </p><h3>Problem Statement</h3><ul><li><p>Each team follows a different approach for caching implementation. Mostly <a href="https://github.com/ben-manes/caffeine">Caffeine</a> is used for local caching (instance level) and <a href="https://github.com/redis/lettuce">Redis Lettuce</a> for distributed caching. </p></li><li><p>Each team is responsible to manage their data. The data is exposed to other teams via gRPC APIs.</p></li></ul><p>Every team is spending time to manage the similar kind of infrastructure and posses multiple challenges. Let&#8217;s discuss challenges with current implementation.</p><h3>Bottlenecks with Independent Implementations</h3><p>Here are few challenges. :</p><ul><li><p>The cache should not lag behind (by larger margin). Cache staleness should be handled appropriately.</p></li><li><p>Single point of failure on Redis. If Redis is unavailable, the whole caching infrastructure falls apart.</p></li><li><p>For introducing a new cache (or caching layer), new deployment and rollback strategies are needed. There is no control at runtime.</p></li><li><p>There is no standard schema to store the data in cache. Each team follows their own standards for caching keys.</p></li><li><p>Observability is big pain point. The metrics like cache hit, error rates are not consistent for every team to monitor the cache success.</p></li><li><p>Multi-layer caching support is not there. For teams, cache means Redis in current architecture.</p></li></ul><p>Each team is spending the time to fix these challenges on their own so there is duplication of effort. The better idea could be a centralised solution, let&#8217;s discuss the solution in details.</p><h2>Solution</h2><p>The implementation abstraction can help teams to focus on the business logic instead of spending time on managing the caching infrastructure. The solution is to create a single interface for client&#8217;s interaction, depicted below.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:null}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">single_interface_cache.get(cache_name, cache_key)</code></pre></div><p>The interface handles querying for the data across multi-layered cache and return once found, mentioned in the sequence below (subscribe for free to continue reading on the architecture details).</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Upgrade&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Subscribe for free to continue reading on multi-layered caching architecture.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Upgrade"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Let&#8217;s conclude on today&#8217;s discussion.</p><h2>Conclusion</h2><p>Every system design decision has trade-offs. It&#8217;s always recommended to do proper analysis if you think caching can solve a problem. If it does, which caching layer (or combination of layers) should be included as part of constructing request&#8217;s response.</p><p>You can watch complimentary video on YouTube for the analysis on DoorDash architecture - </p><div id="youtube2-mBLaAGAnpw0" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;mBLaAGAnpw0&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/mBLaAGAnpw0?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><p>Happy Building!</p>]]></content:encoded></item><item><title><![CDATA[How to Win System Design Interviews]]></title><description><![CDATA[Crack your next system design interview with these TIPS]]></description><link>https://systemdesignfromscratch.org/p/never-fail-system-design-interviews</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/never-fail-system-design-interviews</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Sun, 13 Sep 2026 10:30:50 GMT</pubDate><enclosure url="https://substackcdn.com/image/youtube/w_728,c_limit/JzUX4Q7NqZ8" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>System Design (SD) interviews are common for SDE-2 roles and beyond. Basic knowledge of systems is also expected for junior SDE positions as interviews are evolving with AI. </p><p>What are some of the things you can do so you can stand out from rest of the crowd and show a clear impact. In short, &#8220;Make Interviewer believe that you&#8217;re the one&#8221;.</p><h1>Approaching System Design Problems</h1><p>Every problem can be approached in a certain way and you&#8217;ve to time it to 45-60 minutes. Time allocation is equally important because you don&#8217;t want to miss critical considerations for a system. </p><blockquote><p>SD interviews are generally timed interviews but I&#8217;ve seen instances where you&#8217;re given a full fledged problem statement, you brainstorm on it for a week or so and then present a solution.</p></blockquote><p>We&#8217;ll discuss the step-wise structure for approaching a system design problem. For each step, we&#8217;ll also focus on important details you should keep in mind. Let&#8217;s start with first step, system requirements.</p><h2><span>System Requirements</span></h2><p>The first part of solving something is identifying the requirements and the same is true for system design problem statement as well. <span>Requirements means what a system is expected to do (and not do). The requirements can be classified into two categories, functional requirements (FR) and non-functional requirements (NFR).</span></p><p><span>As part of requirement gathering, you should be clear on system expectations and don&#8217;t leave any ambiguity on the table. A recommendation for interviews is keeping a limited scope. </span>Always try to limit the requirements, keep in mind you&#8217;ll have to fulfil those requirements in next 30 minutes.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Let&#8217;s take an example of designing Facebook. You can&#8217;t design Facebook in one hour or a week or even a year, there are a lot (a lot) of points to consider. So the next step is figuring out what part Facebook should be considered? This could be focused on photos feed, video management, handling ads, etc.</p><blockquote><p>The intention of interviews is never to design full-fledged system. It&#8217;s the thought process and how you tackle an ambiguous problem. You&#8217;re not being hired to design next Facebook (this could be the case as well) but the idea is if you&#8217;re hired, can you come up with solutions to problems. And more importantly, can the interviewer work with you during the job, which mostly depends on how well you give and take feedback throughout the discussion.</p></blockquote><p>A subpart of requirements is NFR. Don&#8217;t throw <strong>random words</strong> for sake of completion (because you&#8217;ve seen bunch of videos on SD interviews). The NFRs such as highly available, scalable, reliable and fault tolerant are included into the discussion without much thought. </p><p>If you say the system should be highly available, then be ready to answer: </p><ul><li><p>What does available mean? </p></li><li><p>Why do you need system to be available? </p></li><li><p>How much availability?  </p></li><li><p>What considerations you&#8217;ll take later to make sure the system is actually available? </p></li></ul><p>This set of questions applies to every NFR you suggest. Most people can&#8217;t differentiate available and reliable, don&#8217;t be that person. If you say the application is fault tolerant, make a point during architecture discussion for what components are included (or decisions are taken) in the system ensuring fault tolerance.</p><p>Ok, moving on the next step once you&#8217;re all cleared up with the requirements; Scale.</p><h2>Scale</h2><p>Scale is again similar to NFR discussion. Most people include scale because they have seen a few videos or read some blog posts with mention of scale in system design interviews. What is scale and why does it matter?  </p><p>Scale is one of the term, another popular term used is <strong>Back-of-the-envelope Estimation</strong>. In this step, you determine various aspects such as traffic numbers, network bandwidth, storage calculations, etc.</p><p>The numbers can&#8217;t be perfect and could be based on assumptions. The recommendation is clarify with the interviewer and what kind of scale we&#8217;re looking at? Scale matters because the system design depends on the scale numbers. The design varies by a magnitude if a system needs to support 1 million users vs 100 million users.</p><p>If you agreed on certain scale numbers in initial discussion, bring them up again during design decision making for why particular choice makes sense.</p><p>Expanding on the Facebook example from previous section, don&#8217;t just say you&#8217;ll build newsfeed and then discuss those two approaches of push vs pull published on every system design blog post. Clarity is very important, which approach works and which not depends on the scale. </p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share System Design From Scratch&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://systemdesignfromscratch.org/?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share System Design From Scratch</span></a></p><p>System requirements and scale discussion both are part of requirements gathering. Try to limit the discuss under 10 minutes for both of these steps. After scope clarity, we move on to actual design of the system.</p><h2>Start with the Design</h2><p>I generally start on my system design thinking from how customers access the system. What&#8217;s the first point of interactions for the customers? From there take a very high level picture of entire system (10000 ft) and then break into components as needed. </p><p>Don&#8217;t forget to check out my books with O&#8217;Reilly for building system design thought process.</p><ul><li><p><a href="https://msdeepsingh.com/books/system-design-on-aws/">System Design on AWS</a> </p></li><li><p><a href="https://msdeepsingh.com/books/system-design-from-scratch/">System Design From Scratch</a> (in progress)</p></li></ul><p>and subscribe to <a href="https://www.youtube.com/@MsDeepSingh">YouTube @MsDeepSingh</a> for detailed discussions.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!g0RT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfaeee5a-761b-448d-bbe0-45b57f7dc71f_1241x385.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!g0RT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfaeee5a-761b-448d-bbe0-45b57f7dc71f_1241x385.png 424w, https://substackcdn.com/image/fetch/$s_!g0RT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfaeee5a-761b-448d-bbe0-45b57f7dc71f_1241x385.png 848w, https://substackcdn.com/image/fetch/$s_!g0RT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfaeee5a-761b-448d-bbe0-45b57f7dc71f_1241x385.png 1272w, https://substackcdn.com/image/fetch/$s_!g0RT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfaeee5a-761b-448d-bbe0-45b57f7dc71f_1241x385.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!g0RT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfaeee5a-761b-448d-bbe0-45b57f7dc71f_1241x385.png" width="1241" height="385" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cfaeee5a-761b-448d-bbe0-45b57f7dc71f_1241x385.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:385,&quot;width&quot;:1241,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:705250,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://systemdesignfromscratch.org/i/214326021?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfaeee5a-761b-448d-bbe0-45b57f7dc71f_1241x385.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!g0RT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfaeee5a-761b-448d-bbe0-45b57f7dc71f_1241x385.png 424w, https://substackcdn.com/image/fetch/$s_!g0RT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfaeee5a-761b-448d-bbe0-45b57f7dc71f_1241x385.png 848w, https://substackcdn.com/image/fetch/$s_!g0RT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfaeee5a-761b-448d-bbe0-45b57f7dc71f_1241x385.png 1272w, https://substackcdn.com/image/fetch/$s_!g0RT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfaeee5a-761b-448d-bbe0-45b57f7dc71f_1241x385.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Once you&#8217;ve a high level picture, how should you proceed further? The SD interview is a live discussion so there is no strict format. The interview can take different directions based on communication between interviewer and interviewee. Some of the pointers include:</p><ul><li><p>API design</p></li><li><p>Monolithic setup or Microservices</p></li><li><p>If Microservices, what all services and how the boundary is defined?</p></li><li><p>Database choices and schema</p></li><li><p>Networking protocols</p></li><li><p>Design choices such as sync vs async</p></li><li><p>Failure handling, etc.</p></li></ul><p>Sometimes discussing algorithms is important such as how will you shorten the URL and other times the algorithms could be too low level detail. As I said, this is live discussion so there is no strict format. </p><p>Let&#8217;s take an example of another pitfall which I&#8217;ve seen during interviews. To resolve any scaling bottleneck, people right away suggest a new micro-service without clarifying how it actually solves the problem. For any new feature introduction, always ask yourself.</p><ul><li><p>Do you really need a new service?</p></li><li><p>Can the existing service be extended?</p></li></ul><p><strong>Trade-off analysis</strong> is key for system design discussion. So there is no right answer or an answer with 100% upsides. The decision will depend on the requirements, scale and multiple other factors. So proper upsides and downsides for each approach helps to figure out which fits best for the given use case.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>The next recommendation is to avoid memorising the solutions. Example, I&#8217;ve heard multiple times if it&#8217;s latency intensive system, you can&#8217;t use queues, it has to be synchronous system and vice versa. For all the readings you do on internet or watch videos, always try to think on your own, why particular decisions are being made. Recommendation is to read company blogs for insights on actual production systems.</p><p>A general discussion that comes up during interviews is database choices, let&#8217;s discuss it in more details.</p><h3>Database Choice</h3><p>Database choice discussion is among the popular ones in SD interviews. The low level schema is mostly deferred for high level design interviews but are important for low level design interviews.  How will you choose a database for give problem statement?</p><p>The recommendation is to avoid phrases like, </p><ul><li><p>because there are 100 million customers or huge dataset, I&#8217;ll use non-relational database. </p></li><li><p>because there is transactional data storage requirements, I&#8217;ll use relational databases.</p></li></ul><p>The choice of database should be derived based on similar factors as how we gather requirements for overall systems. There is a more detailed blog on database choices, please read - </p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;c17b26b3-478a-4ace-9e40-62da6f87f0e7&quot;,&quot;caption&quot;:&quot;Which database is the right choice for my use case? This is very common question that&#8217;s brought up for System Design interviews as well as while actually building systems. The decision depends on lot of factors, let&#8217;s discuss a very high level view.Thanks for reading The Scalability Times! Subscribe for free to receive new posts and support my work.&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;showDescription&quot;:true,&quot;showImage&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Which database makes sense?&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:231816531,&quot;name&quot;:&quot;Mandeep Singh Shekhawat&quot;,&quot;bio&quot;:&quot;Software Engineer | O'Reilly Author \&quot;System Design on AWS\&quot; and \&quot;System Design From Scratch\&quot; | YouTube @MsDeepSingh&quot;,&quot;photo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!C1xZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F281a9bed-8be5-42e2-a328-ad1ec6aeb3e0_1056x1056.png&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2026-05-09T11:50:47.000Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!aNcu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://systemdesignfromscratch.org/p/which-database-makes-sense&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:196777274,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:1,&quot;comment_count&quot;:0,&quot;publication_id&quot;:2597599,&quot;publication_name&quot;:&quot;System Design From Scratch&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!hyee!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b5863-6e28-4ece-85b0-5aa8fe2632cc_608x608.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p>The choice of database is highly dependent on the query patterns. You store the data in such a way such that it&#8217;s retrieval is faster. Other factors include cost (operations and infrastructure), ACID compliance, previous expertise, etc. The discussion could further move to database scaling, so you should be prepared to answer accordingly.</p><blockquote><p>Relational databases such as MySQL or PostgreSQL solves most of the use cases. If you don&#8217;t know which database to pick, start with relational databases.</p></blockquote><p><span>System health is another important discussion which holds good value during the system design interviews. Let&#8217;s focus on system health next.</span></p><h3>System Health</h3><p>System health means system is working as per the expectations and there is no degradation. Here are a couple of things to consider. </p><ul><li><p>Failures and faults happen in live systems. This could be API failures or system in whole. The system should be able to handle these scenarios gracefully.</p></li><li><p>What if certain components in the system break, ways for graceful degradation. It involves discussion around if the components are decoupled enough.</p></li><li><p>Monitoring, logging and alerts are important to monitor the health of the system. The combination of three is often referred to as Observability. This helps you to figure out if something goes wrong so never skip this part.</p></li></ul><p>This is all for today&#8217;s discussion. Let&#8217;s summarise.</p><h1>Closing Thoughts&#8230; </h1><p>Remember, no architecture is final or best architecture. Every decision in designing systems holds trade-offs. You should clearly specify why a particular decision makes sense for a specific scenario. Think before you answer to certain question, your capability to ask right questions matters a lot. If you&#8217;re asked to improved database performance, then don&#8217;t directly say I&#8217;ll use cache. First analyse why the bottleneck exist, introducing a cache might help or not.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>If possible, take examples from your previous projects if any trade-off analysis matches the situation. Personal experience adds a lot of value. There are some lesser focused upon topics in SD interviews due to time constraints and you can consider depending on time and problem statements. The topics include security, application deployments and managing operational overhead (in addition to observability).</p><p>Here is the complimentary video on YouTube discussing &#8220;How to win System Design interviews&#8221; : </p><div id="youtube2-JzUX4Q7NqZ8" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;JzUX4Q7NqZ8&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/JzUX4Q7NqZ8?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><p>With all these TIPS, I&#8217;ll leave you with your preparation. Best of luck :) Apart from self-preparation, try mock interviews with your friends (or anyone) and analyse on what went wrong (and right).</p><p>For any questions, you can comment here or DM on <a href="https://www.linkedin.com/in/msdeep14/">LinkedIn</a>.</p>]]></content:encoded></item><item><title><![CDATA[How to System Design?]]></title><description><![CDATA[Guidelines on designing better systems]]></description><link>https://systemdesignfromscratch.org/p/how-to-system-design</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/how-to-system-design</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Sun, 23 Aug 2026 14:42:26 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!shNT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>There are a lot of recommendations floating around for how to build systems. Some of the example include follow domain-driven design and build stateless application servers. No recommendation is good or bad, any every choice has a trade-offs. Today&#8217;s blog covers some of the guidelines or suggestions for designing better and useful systems. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Assume you&#8217;ve to build a payments application supporting multiple payment options such as UPI, credit card. Each of these payment option state is synced using callbacks and synchronous APIs with the payment providers.</p><h3>Guideline of Isolation: Build it Modularly</h3><p>The system should be built as modules with each module being independent on its own. This helps with maintainability and reusability of modules.</p><p>Example includes keeping independent modules for different payment methods and separate module for callback processing. You can keep the common stuff in common module which can be imported as needed.</p><h3>Guideline of Simplicity: Keep it Simple, Silly</h3><p>You should always avoid unnecessary components. Only build what&#8217;s really needed. Iterate over the implementation - always test and improve. </p><p>Examples include trying to support a lot of payment methods in the beginning or thinking of going global on day zero. This could create extra churn and gets the project delayed.</p><p><em><strong>** </strong></em>The NOTES in this blog are taken from Chapter 01 of System Design on AWS. Explore the <a href="https://msdeepsingh.com/books/system-design-on-aws/">book</a>:</p><p>&#128213; O&#8217;Reilly: https://oreil.ly/ruQbc</p><p>&#128213; Amazon.in: https://amzn.to/4jExkte</p><p>&#128213; Amazon.com: https://amzn.to/3D3BIBJ</p><h3>Guideline of Performance: Metrics Don&#8217;t Lie</h3><p>Metrics (observability) are really important. They helps in debugging as well as how well your system is doing. </p><p>Example metrics include time taken for payment processing and payment failure rates.</p><h3>Guideline of Trade-offs: There is no such thing as Free Lunch</h3><p>Every choice has trade-offs. There are pros and cons with every approach. Choose what makes sense for your business use case and to your product&#8217;s scale. Take inspiration from others but don&#8217;t follow blindly. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Example, thinking of independent micro-services from day one because you can scale them independently. Well yes, but who will manage this?</p><h3>Guideline of Use-cases: It Always Depends</h3><p>The design of system can depend on a lot of factors. Some of the factors include system requirements, user needs, expertise, budget and regulations.</p><p>Reiterating from previous point, choose what works for you. Here is summary image (generated with Grok AI)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!shNT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!shNT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg 424w, https://substackcdn.com/image/fetch/$s_!shNT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg 848w, https://substackcdn.com/image/fetch/$s_!shNT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!shNT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!shNT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg" width="1168" height="784" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:784,&quot;width&quot;:1168,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:311790,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://systemdesignfromscratch.org/i/212412647?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!shNT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg 424w, https://substackcdn.com/image/fetch/$s_!shNT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg 848w, https://substackcdn.com/image/fetch/$s_!shNT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!shNT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45ea5eac-1032-4bfb-a952-596e8f514590_1168x784.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Happy Building!</strong></p>]]></content:encoded></item><item><title><![CDATA[Compute? Virtual Machines or Containers or Serverless Functions]]></title><description><![CDATA[Choosing compute is hard choice, let's try to simplify.]]></description><link>https://systemdesignfromscratch.org/p/compute-virtual-machines-or-containers</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/compute-virtual-machines-or-containers</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Sun, 16 Aug 2026 10:31:04 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!oXbw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The word<strong><span data-color="#741b47" style="color: rgb(116, 27, 71);"> </span><span data-color="rgb(230, 0, 14)" style="color: rgb(230, 0, 14);">Compute</span> </strong>basically means where the application is deployed and running. This could be your personal computer, serverless functions (e.g. AWS Lambda), virtual machines (e.g. Amazon EC2) or container services (e.g. AWS ECS/EKS).</p><h2>General Thoughts on Compute Selection</h2><ul><li><p>If you&#8217;re working in a company, the selection of compute is generally influence by what&#8217;s being already being used in other projects/services. This is because the team already has experience managing certain technology. Introducing new services brings in learning curve and extra operational burden.</p></li><li><p>For reference, the comparison of services is corresponding to AWS cloud but they hold across the cloud providers.</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Let&#8217;s start the discussion, starting with virtual machines.</p><h2>Elastic Compute Cloud (EC2)</h2><p>There are two options with Amazon EC2. A shared tenancy or dedicated tenancy. The idea is you wish to buy the entire physical server or just a part of it. Most of needs are served with shared tenancy, don&#8217;t worry the customers workloads are properly isolated.</p><p>Once you decided on the tenancy (default is shared), the second choice you&#8217;ve to make is instance type. This depends on a variety of factors such as:</p><ul><li><p>Hardware and performance characteristics of an instance such as CPU, disk, memory and network.</p></li><li><p>Type of workloads such as huge AI training workflows vs running a web application.</p></li></ul><p>The third selection choice you&#8217;ve to make is billing model. There are three types, reserved, on-demand and spot instances. The default selection is an on-demand instance.</p><ul><li><p>Reserved: If you&#8217;re aware of scaling needs, you can pre-order the number of instances needed. The reserved instances are available at a discounted price.</p></li><li><p>On-Demand: You spawn the instances when needed and terminate once done. This is default pricing model. </p></li><li><p>Spot: For less critical workloads where uptime is not a hard requirement, spot instances could be chosen. You can bring up an instance but AWS can terminate it at anytime they wish.</p></li></ul><p>The content of this blog is influenced by <strong>Chapter 11</strong> of O&#8217;Reilly book <strong>System Design on AWS</strong>. Checkout the book at <a href="https://msdeepsingh.com/books/system-design-on-aws/">https://msdeepsingh.com/books/system-design-on-aws/</a>.</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!31Wh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc654fec-b99b-4a1d-99be-66ff5cd59226_1584x396.png 424w, https://substackcdn.com/image/fetch/$s_!31Wh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc654fec-b99b-4a1d-99be-66ff5cd59226_1584x396.png 848w, https://substackcdn.com/image/fetch/$s_!31Wh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc654fec-b99b-4a1d-99be-66ff5cd59226_1584x396.png 1272w, https://substackcdn.com/image/fetch/$s_!31Wh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc654fec-b99b-4a1d-99be-66ff5cd59226_1584x396.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!31Wh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc654fec-b99b-4a1d-99be-66ff5cd59226_1584x396.png" width="1456" height="364" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cc654fec-b99b-4a1d-99be-66ff5cd59226_1584x396.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:364,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1102236,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://systemdesignfromscratch.org/i/211293645?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc654fec-b99b-4a1d-99be-66ff5cd59226_1584x396.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!31Wh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc654fec-b99b-4a1d-99be-66ff5cd59226_1584x396.png 424w, https://substackcdn.com/image/fetch/$s_!31Wh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc654fec-b99b-4a1d-99be-66ff5cd59226_1584x396.png 848w, https://substackcdn.com/image/fetch/$s_!31Wh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc654fec-b99b-4a1d-99be-66ff5cd59226_1584x396.png 1272w, https://substackcdn.com/image/fetch/$s_!31Wh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc654fec-b99b-4a1d-99be-66ff5cd59226_1584x396.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Let&#8217;s move to second compute option, containers.</p><h2>Containerisation Services</h2><p>The major problem that occurs in development is &#8220;it works on my machine&#8221;. The development environment could vary from engineer to engineer, from local setup to production environment and so on. This problem is solved via containers.</p><p>Another problem addressed via containers is optimising the resource usage on EC2 machines.</p><p>You package the application binary with all the dependencies and the same container can run on any machine. You can deploy these container images and manage them on your own but it&#8217;s hard job. So there are multiple orchestration tools built on top to manages the containers at scale, such as Kubernetes.</p><p>AWS offers two container orchestration services, namely Elastic Container Service (ECS) and Elastic Kubernetes Service (EKS).</p><p>Both of these services comes with two forms of deployment, either we can choose to deploy via EC2 or let AWS manage everything behind the scenes (serverless), called as Fargate. Let&#8217;s move on to next choice, Function-as-a-Service.</p><h2>Serverless Functions</h2><p>You just write functions and don&#8217;t worry about underlying infrastructure at all, everything is managed by the cloud provider. For example, AWS Lambda.</p><p>The code you write in functions can be invoked with the help of a trigger. For example, whenever there is new object uploaded to S3 bucket, read the object and perform some analysis.</p><h2>Decision Framework</h2><p>From earlier blog on this newsletter on choosing a database, the factors are applicable for compute selection as well.</p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;046c466c-2dbc-4546-a0d3-d4c9df7e9df0&quot;,&quot;caption&quot;:&quot;Which database is the right choice for my use case? This is very common question that&#8217;s brought up for System Design interviews as well as while actually building systems. The decision depends on lot of factors, let&#8217;s discuss a very high level view.Thanks for reading The Scalability Times! Subscribe for free to receive new posts and support my work.&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;showDescription&quot;:true,&quot;showImage&quot;:true,&quot;size&quot;:&quot;sm&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Which database makes sense?&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:231816531,&quot;name&quot;:&quot;Mandeep Singh Shekhawat&quot;,&quot;bio&quot;:&quot;Software Engineer | O'Reilly Author \&quot;System Design on AWS\&quot; | YouTube @MsDeepSingh&quot;,&quot;photo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!C1xZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F281a9bed-8be5-42e2-a328-ad1ec6aeb3e0_1056x1056.png&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2026-05-09T11:50:47.000Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/$s_!aNcu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://systemdesignfromscratch.org/p/which-database-makes-sense&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:196777274,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:1,&quot;comment_count&quot;:0,&quot;publication_id&quot;:2597599,&quot;publication_name&quot;:&quot;System Design From Scratch&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/$s_!hyee!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b5863-6e28-4ece-85b0-5aa8fe2632cc_608x608.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p> The decision factors include:</p><ul><li><p>Solves the use case</p></li><li><p>Previous Expertise</p></li><li><p>Cost</p></li><li><p>Battle-tested software</p></li><li><p>Cloud Managed vs Self Managed (Operational Overhead)</p></li><li><p>Time to Market</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>With all this information, let&#8217;s conclude our discussion.</p><h2>Closing Remarks&#8230;</h2><p>Use the below table as reference for selection of compute along with some decision factors discussed in previous section.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oXbw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oXbw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png 424w, https://substackcdn.com/image/fetch/$s_!oXbw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png 848w, https://substackcdn.com/image/fetch/$s_!oXbw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png 1272w, https://substackcdn.com/image/fetch/$s_!oXbw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png 1456w" sizes="auto, 100vw"><img src="https://substackcdn.com/image/fetch/$s_!oXbw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png" width="826" height="530" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:530,&quot;width&quot;:826,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:114831,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://systemdesignfromscratch.org/i/211293645?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!oXbw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png 424w, https://substackcdn.com/image/fetch/$s_!oXbw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png 848w, https://substackcdn.com/image/fetch/$s_!oXbw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png 1272w, https://substackcdn.com/image/fetch/$s_!oXbw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a05e01c-d521-46b4-af3d-476c11e21c80_826x530.png 1456w" sizes="auto, 100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>In summary:</p><ul><li><p>All compute options can work at high scale. Evaluate on what works for you. Do PoC if you&#8217;ve money and resources.</p></li></ul><p>Iterate on design if you require more control over time.</p><ul><li><p>Example started with EKS Fargate</p></li><li><p>Move to EKS EC2</p></li><li><p>Migrate away from managed offering and deploy your own EKS cluster to manage containers EC2 instances.</p></li></ul><p>Taking an example of Amazon Prime video monitoring architecture. The distributed architecture involved multiple AWS Lambda functions orchestrated via AWS Step Functions. This led to lot of operational overhead with extra dollars to spend. The team rearchitected the system by migrating to ECS. This saved cost plus network latency between the components of distributed system.</p><p>See you next week! Don&#8217;t forget to subscribe :)</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://systemdesignfromscratch.org/subscribe?"><span>Subscribe now</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Thundering Herd Explained]]></title><description><![CDATA[What is Thundering Herd and How to fix?]]></description><link>https://systemdesignfromscratch.org/p/thundering-herd-explained</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/thundering-herd-explained</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Sun, 09 Aug 2026 10:53:04 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!hyee!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b5863-6e28-4ece-85b0-5aa8fe2632cc_608x608.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>What will happen to a food item if a large group of animals (a herd) starts running towards it, all at once?</p><h2>Problem Statement</h2><p>Now think of a same scenario for a system or a component of a system. If a large number of requests arrives at once trying to acquire a resource, the system will be overloaded if not handled well. The sudden traffic spike can cause issues like high CPU utilisation, memory leaks, etc.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Thundering Herd is often used in-relation to cache and databases. For a cache-miss scenario, all the requests trying to access same item will be routed to the database. This overloads the database if database is not scaled to handle this load. This causes a cascading failure in the system bringing down the entire system.</p><h2>Resolution</h2><p>The resolution has two directions, one is mitigation (come out of situation if thundering herd occurs) and other is prevention (system is designed in a way so thundering herd doesn&#8217;t occur). Let&#8217;s explore both of these directions.</p><h3>Thundering Herd Mitigation</h3><p>It&#8217;s really hard to come out of Thundering Herd situation. This can cause cascading failures and bring the entire infrastructure down. The best is dropping the user requests. This could be for all the users or a percentage of users depending on the situation.</p><p>The database might have queued up all the requests, so restart the database. Same applies to other infra components.</p><h3>Thundering Herd Prevention</h3><p>The system can be designed in a way ensuring it can come out of these situations easily if they happen and enhancements ensuring this situation doesn&#8217;t happen.</p><h4>Discard Requests</h4><p>The first solution is load shedding. Serving some requests is always better than serving none of them. This is the idea behind load shedding because an overloaded system can cause cascading failures. </p><p>Here are few suggestions on discarding requests:</p><ul><li><p>Discard lower priority requests. This could be some back-office jobs that can be scheduled for later point of time.</p></li><li><p>Discard % of user requests. If above doesn&#8217;t help, the system should drop some percentage of user requests.</p></li><li><p>Keep a request buffer. The requests are put in a queue for certain time and served if capacity is available (or system recovers).</p></li></ul><p>Watch the dive deep on Uber&#8217;s Load Shedding Framework <a href="https://www.youtube.com/watch?v=Owia_s0B74E">QALM</a> (QoS Load Management Framework) and Cinnamon architecture (<a href="https://youtu.be/OxTXcs5qJCM">Part I</a>, <a href="https://youtu.be/2nT2La3uoqU">Part II</a>, <a href="https://youtu.be/rv0dI_oxxOA">Part III</a>) for discussion on how these systems are built.</p><h4>Jitter in Retries</h4><p>If a request fails, what you do? Hit the refresh button. The retry could be user enforced (such as refresh) or system invoked on request failures. Retries are great to recover from transient failures but this can overload the system in case of thundering herd scenarios.</p><p>If the system is not able to process the requests, and all the users retried at the same time. This makes the situation even worse. Introducing Jitter means there is random lag between the retries ensuring not all requests arrive at the same time.</p><p>Exponential backoff in retries is only good if applied with Jitter else it doesn&#8217;t solve the problem it is supposed to. In summary, don&#8217;t retry at fixed intervals. Jitter is must, exponential backoff is good to have.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h4>What&#8217;s Important Should Stay Alive?</h4><p>Big software architecture has a lot of components (or services). Each component does some job and might depend on other components for part of the job. There are also some good have components. Take an example of video feed generated by Netflix, it&#8217;s customised for an user. </p><p>In overloaded system scenarios, it&#8217;s ok to reflect same video feed to all users and stop the work from recommendation system. This is good to have and not critical. The critical component is video play. The video should start once user clicks on play button. </p><p>The recommendation is clear division between the services. General criteria followed by many companies is tier strategy. Tier 1 service is most critical, Tier 2 is less critical and so on. </p><p>The chaos and stress testing should focus majorly on Tier 1 services ensuring system operations in unknown scenarios.</p><h4>Scaling</h4><p>Automated Scaling is one of suggestions that floats around to unburden the servers from this load. For thundering herd, it doesn&#8217;t help much. Bringing up a server takes some time (even with light-weight application binaries and low startup time).</p><p>Pre-scaling is one recommendation if you&#8217;re aware of some upcoming event and loosening up the auto-scaling thresholds so the system doesn&#8217;t wait for hit upper bounds can help.</p><h4>Request Coalescing</h4><p>We discussed thundering herd occurs if a huge number of requests are trying to access the same resource. Can we deploy a mechanism so as only one request is processed and others wait for for its results, see Figure 1. </p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NqaY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e11883-751c-4491-9337-d3600c1cd1bc_470x232.png 424w, https://substackcdn.com/image/fetch/$s_!NqaY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e11883-751c-4491-9337-d3600c1cd1bc_470x232.png 848w, https://substackcdn.com/image/fetch/$s_!NqaY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e11883-751c-4491-9337-d3600c1cd1bc_470x232.png 1272w, https://substackcdn.com/image/fetch/$s_!NqaY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e11883-751c-4491-9337-d3600c1cd1bc_470x232.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NqaY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e11883-751c-4491-9337-d3600c1cd1bc_470x232.png" width="470" height="232" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/68e11883-751c-4491-9337-d3600c1cd1bc_470x232.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:232,&quot;width&quot;:470,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:61574,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://systemdesignfromscratch.org/i/210311331?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e11883-751c-4491-9337-d3600c1cd1bc_470x232.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!NqaY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e11883-751c-4491-9337-d3600c1cd1bc_470x232.png 424w, https://substackcdn.com/image/fetch/$s_!NqaY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e11883-751c-4491-9337-d3600c1cd1bc_470x232.png 848w, https://substackcdn.com/image/fetch/$s_!NqaY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e11883-751c-4491-9337-d3600c1cd1bc_470x232.png 1272w, https://substackcdn.com/image/fetch/$s_!NqaY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68e11883-751c-4491-9337-d3600c1cd1bc_470x232.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>Figure 1 Request Coalescing</p><p> All the requests are trying get(x), only one request actually fetch the result and rest of them use the same. This shields the backend systems, resolving thundering herd issue. At the caching layer, this problem is solved with a cache promise.</p><p>Cache Promise works on the similar concept, it stores a promise till the results are retried by the primary query and other requests wait for this promise. Once the promise is fulfilled, all requests are served.</p><p>Interested in practical implementation of these concepts, STAY TUNED. Something exciting is coming &#8212; <a href="https://msdeepsingh.com/books/">https://msdeepsingh.com/books/</a></p><h2>Further&#8230;</h2><ul><li><p><a href="https://youtu.be/Pd3dt37A0yU">How to avoid thundering Herd?</a></p></li><li><p><a href="https://youtu.be/f-06wUzZf58">Instagram Architecture: Solving Thundering Herd with Cache Promise</a></p></li></ul><p></p>]]></content:encoded></item><item><title><![CDATA[Writing a Technical Book: Why I Did It and How You Can Too]]></title><description><![CDATA[Writing a technical book is a huge project, but it is one of the best things you can do for your career. If you are curious about what it takes to write a book, or if you are thinking about writing on]]></description><link>https://systemdesignfromscratch.org/p/writing-a-technical-book-why-i-did</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/writing-a-technical-book-why-i-did</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Sat, 25 Jul 2026 05:03:07 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Brsc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1><span>Motivation</span></h1><p><span>The primary motivation for writing a technical book should not be money. If it is, you should probably reconsider. Technical books have a highly niche audience. With the rise of AI tools, fewer people rely on books for technical answers.</span></p><p><span>Financial gain was never the motivation for me, so what inspired me to write &#8220;System Design on AWS&#8221;?</span></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><ul><li><p><strong>Personal Growth:</strong><span> Taking a complex idea and translating it for beginners forces you to deepen your own understanding.</span></p></li><li><p><strong>The Communication Challenge:</strong><span> Having deep technical knowledge is common, but delivering it effectively is rare. Writing the book was a test of communication and documentation skills. I credit much of this to the writing culture at Amazon.</span></p></li><li><p><strong>Building Trust:</strong><span> Being an author with a respected publisher like O&#8217;Reilly acts as a powerful credential. Much like having a top-tier university or top company on your resume.</span></p></li></ul><h2><span>Is It Really Worth It?</span></h2><p><span>Absolutely, but the ROI is in your network, not your bank account. As the saying goes, &#8220;Your network is your net worth.&#8221; Publishing the book opened doors to connect with industry leaders, CTOs, and senior engineers. I&#8217;ve been invited to multiple conferences to share my insights so it has been my way of giving back to the community. The connections allow you to learn from other leaders&#8217; failures, successes, and decision-making processes.</span></p><p><span>Adding to above, it&#8217;s not like you&#8217;ll make nothing. The idea is not setting high expectations on monetary terms.</span></p><h1><span>Project Initiation</span></h1><p><a href="https://www.linkedin.com/in/msdeep14/"><span>Me</span></a><span> and my co-author </span><a href="https://jaykmr.com/"><span>Jayanth Kumar</span></a><span> took close to 2.5 years to finish the project. The details outlined as part of this blog are specific to O&#8217;Reilly but it&#8217;s similar with other technical publishers as well. I&#8217;ll divide the process into multiple phases from initial thought process to hard copies in my hands.</span></p><h2><span>Proposal Submission</span></h2><p><span>Starting out is always hard. Jayanth shared this idea with me and had some details already put up in the proposal. We brainstormed among ourselves on the structure of the book so as readers are hooked to the content throughout.</span></p><p><span>You can find all the details on the O&#8217;Reilly </span><a href="https://www.oreilly.com/work-with-us.html"><span>Work With Us</span></a><span> page regarding different ways you can contribute.</span></p><h3><span>The Proposal Details</span></h3><p><span>Here is the high level description of what you need to fill in the proposal (make a copy of proposal from </span><a href="https://docs.google.com/document/d/16B8ZmpEj-DULGNb8X2NjpQPUnZMWUn5kM1ZBaN7pSUs/copy"><span>here</span></a><span>).</span></p><ul><li><p><strong>Book title and subtitle:</strong><span> The title of the book. For subtitles, you can also suggest multiple subtitles and decide later what works best.</span></p></li><li><p><strong>About the Author:</strong><span> This is basically an author biography and why do you feel you&#8217;re the best person to write the book on a particular topic. You can include your past work such as your industry experience, previous technical books/blogs/videos, speaking at conferences, etc.</span></p></li><li><p><strong>Marketing Description:</strong><span> This is something you find on the back cover of the book. You&#8217;re basically pitching to buy the book to a potential reader.</span></p></li><li><p><strong>About the topic:</strong><span> This section explains the book title in detail and why it&#8217;s important.</span></p></li><li><p><strong>Audience:</strong><span> Who will read this book?</span></p></li><li><p><strong>What the reader will learn:</strong><span> There is always some end goal if you&#8217;re selling a product. If the reader finishes the book, what kind of knowledge gain happens and how/where the reader will apply this knowledge.</span></p></li><li><p><strong>Competing titles:</strong><span> If there are similar titles in the market, how this book differs from them and what new values this book specifically offers.</span></p></li><li><p><strong>Book outline:</strong><span> Here you include a detailed chapter-wise table of contents.</span></p></li><li><p><strong>Schedule:</strong><span> How much time will you take to finish the first two chapters, half manuscript and full manuscript. Keep in mind that life happens and if you&#8217;re working on the book writing along with your full-time job then keep a buffer.</span></p></li></ul><p><span>Balancing the content takes effort, what you go into the book and what should be skipped is the decision you&#8217;ve to make. Be ready to spend so much time on choosing topics to be included as part of the book and then again striking them off because you found other things which are more important. Once the draft was ready, we directly emailed one the Content Acquisition Editors from O&#8217;Reilly.</span></p><h3><span>Proposal Submission Timeline</span></h3><p><span>We were hopeful of the proposal approval as we firmly believed this is a unique book and solves a lot of gaps in the content already available in the market. Good things happen if you&#8217;re hopeful, and we received a positive response to the proposal. At this point, it&#8217;s not 100% approved but the acquisitions editor will work with you to modify some details as needed. For example:</span></p><ul><li><p><span>We had a lot of discussion if Part II of the book (AWS specific content) should be included or not. The point being made was there is already a lot of AWS documentation available on the internet, so what new value does the book bring? We finally agreed to keep it so readers can find everything at single place and they are able to follow along from Chapter 1 to Chapter 21. You don&#8217;t want to ask the reader to go read on internet about a specific AWS service and then come back to the book on how it&#8217;s used practically.</span></p></li><li><p><span>We had 15 chapters in Part III of the book in the initial proposal which was trimmed down to 8 later. As I was saying earlier, you&#8217;ll have to balance the content.</span></p></li></ul><p><strong>TIP:</strong><span> We also wrote one chapter from Part III and shared after proposal submission on how we&#8217;re envisioning the content. I later scrapped it off and wrote it from scratch but if you can, it&#8217;s a good idea to have some content ready from the chapters.</span></p><p><span>After all this communications, the proposal was officially approved and we were presented with a contract to sign. Once signed, the actual work started.</span></p><h1><span>Book Writing Process</span></h1><p><span>You&#8217;re assigned a development editor to work with you throughout the book after contract signing. In the first meeting, the development editor shares details like:</span></p><ul><li><p><strong>Writing tool:</strong><span> You can either write in Google Docs or O&#8217;Reilly has an in-house tool called Atlas.</span></p></li><li><p><strong>Development Schedule:</strong><span> You agree on a chapter-wise schedule on when the chapters will be ready.</span></p></li><li><p><strong>Writing Style:</strong><span> Details around illustrations, writing style, content structuring, etc.</span></p></li></ul><p><span>Once you finish a chapter, you share the chapter with the development editor. The role of development editor is to share feedback on the first draft. You work on the shared feedback and it becomes a continuous loop for all the chapters.</span></p><p><span>After development review is done and feedback is addressed, the chapters are published to O&#8217;Reilly platform in early release form. The good thing is people can read chapters early and share reviews on the platform. It&#8217;s much similar launching a product MVP, gathering feedback and improving on it before the final launch of the product.</span></p><p><span>In parallel, the book chapters also goes through technical reviews. For technical reviews, O&#8217;Reilly has their own reviewers and you can also suggest from your network. The technical reviews are phased into generally 3 parts, first two chapters, then half manuscript and then full manuscript.</span></p><p><span>After development and technical review completion of the chapter, the next step is the production phase.</span></p><h1><span>Book Production Phase</span></h1><p><span>A production editor walks you through the book production timelines and different stages as part of this process. Here are few things taken care of as part of this phase:</span></p><ul><li><p><strong>Copy Editing:</strong><span> A copy editor goes through the entire manuscript to make sure it matches the O&#8217;Reilly style guidelines. This stage generally doesn&#8217;t require too much input from your end. This is divided into two parts, QC1 and QC2. You can suggest anything as part of QC1 and that is addressed as part of QC2.</span></p></li><li><p><strong>Illustrations:</strong><span> In parallel to copy editing, an illustrator works through the images and recreates them as per O&#8217;Reilly style. You can work through the illustrations for any suggestions from your end.</span></p></li><li><p><strong>Index:</strong><span> An indexer is assigned to the project responsible to create the final index of the book.</span></p></li></ul><p><span>The book is ready to go to print after all these steps as part of the production phase. The final version of the book is available within a week on O&#8217;Reilly platform and it generally takes 3-4 weeks for physical copies to be printed out.</span></p><p><span>Let&#8217;s talk a little about the book I wrote with O&#8217;Reilly - </span><em><strong>System Design on AWS</strong></em><span>.</span></p><h1><span>System Design on AWS</span></h1><p><strong>System Design on AWS</strong><span> was written with a clear philosophy: to be useful both &#8220;during the interview and after the interview.&#8221; It is designed to take your knowledge beyond basic whiteboard theory so you can make effective long-term architectural decisions when building actual products.</span></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Brsc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Brsc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png 424w, https://substackcdn.com/image/fetch/$s_!Brsc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png 848w, https://substackcdn.com/image/fetch/$s_!Brsc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png 1272w, https://substackcdn.com/image/fetch/$s_!Brsc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Brsc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png" width="1456" height="920" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:920,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1732564,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://systemdesignfromscratch.org/i/208417478?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Brsc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png 424w, https://substackcdn.com/image/fetch/$s_!Brsc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png 848w, https://substackcdn.com/image/fetch/$s_!Brsc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png 1272w, https://substackcdn.com/image/fetch/$s_!Brsc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a9e5ee7-dbba-45f4-b548-145c0ddf65cf_2218x1402.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2><span>Book Content</span></h2><ul><li><p><strong>Part 1 - Fundamentals:</strong><span> Covers core distributed building blocks like load balancers, caching layers, databases, network protocols, containerisation and general architecture patterns.</span></p></li><li><p><strong>Part 2 - AWS Services:</strong><span> Maps out the specific AWS services available across different operational domains (compute, databases, networking, event-driven, observability, big data, machine learning etc.).</span></p></li><li><p><strong>Part 3 - Practical Implementation:</strong><span> Focuses on real-world system design philosophy. It walks through building complex applications from scratch such as a stock broker platform or a hotel reservation system. From gathering initial requirements to deploying the actual AWS components. It emphasizes that drawing boxes on a whiteboard is not enough; you need to know how to actually run the system.</span></p></li></ul><p><span>You can find everything about the book on </span><a href="https://msdeepsingh.com/books/"><span>https://msdeepsingh.com/books/</span></a></p><h2><span>Get System Design on AWS</span></h2><p><span>&#128213; O&#8217;Reilly: </span><a href="https://learning.oreilly.com/library/view/system-design-on/9781098146887/"><span>https://learning.oreilly.com/library/view/system-design-on/9781098146887/</span></a></p><p><span>&#128213; Amazon.in: </span><a href="https://amzn.to/4jExkte"><span>https://amzn.to/4jExkte</span></a></p><p><span>&#128213; Amazon.com: </span><a href="https://amzn.to/3D3BIBJ"><span>https://amzn.to/3D3BIBJ</span></a></p><p><span>&#128213; Amazon.co.uk: </span><a href="https://amzn.to/3QW6Fvf"><span>https://amzn.to/3QW6Fvf</span></a></p><p><span>&#128213; Shroff Publishers (Indian Subcontinent): </span><a href="https://www.shroffpublishers.com/books/9789355428035/"><span>https://www.shroffpublishers.com/books/9789355428035/</span></a></p><p><span>Before closing, I want to share my opinions on the choice of publisher.</span></p><h1><span>Self Publishing or Publishing House?</span></h1><p><span>Self publishing means you&#8217;re already well-known in the industry and people will buy the book looking at your name as author. If you&#8217;re a first time author like me, you&#8217;ve to give some reason to readers so they can trust you. O&#8217;Reilly solved this problem for me. O&#8217;Reilly is a trusted name and they don&#8217;t publish random jargon, the book goes through a strict process so readers clear the first barrier of buying the book.</span></p><p><span>Also, we were not aware of the overall process. You&#8217;ve to spend some additional time on marketing, content reviews, copy editing, etc which are taken care of by O&#8217;Reilly in-house. Given we both had full time jobs, O&#8217;Reilly was the preferred choice and I&#8217;m very glad we pursued this project.</span></p><p><span>On a closing note, writing a technical book may not make you a millionaire, but it will sharpen your communication, expand your professional network and strengthen your domain expertise.</span></p><p><span>Best of Luck!!!</span></p><p><span>You can reach out to me on </span><a href="https://www.linkedin.com/in/msdeep14/"><span>LinkedIn</span></a><span> for specific queries.</span></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading System Design From Scratch! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Which database makes sense?]]></title><description><![CDATA[Choosing database for your next project]]></description><link>https://systemdesignfromscratch.org/p/which-database-makes-sense</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/which-database-makes-sense</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Sat, 09 May 2026 11:50:47 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!aNcu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Which database is the right choice for my use case? This is very common question that&#8217;s brought up for System Design interviews as well as while actually building systems. The decision depends on lot of factors, let&#8217;s discuss a very high level view.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading The Scalability Times! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>Decision Flowchart</h2><p>Let me take a reference from my O&#8217;Reilly book &#8220;<a href="https://oreil.ly/ruQbc">System Design on AWS</a>&#8221; Chapter 3. Figure 1 shows a flow chart on how can you navigate through the choice of database over multiple options available in the market.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!aNcu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!aNcu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png 424w, https://substackcdn.com/image/fetch/$s_!aNcu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png 848w, https://substackcdn.com/image/fetch/$s_!aNcu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png 1272w, https://substackcdn.com/image/fetch/$s_!aNcu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!aNcu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png" width="690" height="684" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:684,&quot;width&quot;:690,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:257539,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://msdeep14.substack.com/i/196777274?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!aNcu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png 424w, https://substackcdn.com/image/fetch/$s_!aNcu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png 848w, https://substackcdn.com/image/fetch/$s_!aNcu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png 1272w, https://substackcdn.com/image/fetch/$s_!aNcu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d3ca9c7-ed0a-4b96-8ac6-3fadde3de18c_690x684.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Figure 1 Decision Flowchart for Database Choice</p><p>The question that comes to your mind, can I follow this flowchart blindly to answer database choice questions? The answer is NO. In Software Architecture and design decisions, there are always trade-offs with any direction you go with. So saying, a particular database is perfect is wrong. In addition to the above flowchart, database choice should be combination of below factors:</p><h3>Business Requirements</h3><p>The most important decision criteria is that the database choice should meet the requirements. All other things comes later.</p><p>You can start by looking at data access patterns. The databases such as DynamoDB only makes sense if you know the access patterns. If there so many joins required, and you don&#8217;t what kind of queries will be there, relational database is better choice. This can very much happen for a new project or a startup; relational database is good choice to start with.</p><p>Don&#8217;t forget to checkout the &#8220;System Design on AWS&#8221; book for detailed dive deep on relational, non-relational databases and how best to use them.</p><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hkD-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026a807c-91b8-446c-81a4-964fc2c210c5_1024x1366.png 424w, https://substackcdn.com/image/fetch/$s_!hkD-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026a807c-91b8-446c-81a4-964fc2c210c5_1024x1366.png 848w, https://substackcdn.com/image/fetch/$s_!hkD-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026a807c-91b8-446c-81a4-964fc2c210c5_1024x1366.png 1272w, https://substackcdn.com/image/fetch/$s_!hkD-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026a807c-91b8-446c-81a4-964fc2c210c5_1024x1366.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hkD-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026a807c-91b8-446c-81a4-964fc2c210c5_1024x1366.png" width="166" height="221.44140625" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/026a807c-91b8-446c-81a4-964fc2c210c5_1024x1366.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1366,&quot;width&quot;:1024,&quot;resizeWidth&quot;:166,&quot;bytes&quot;:905382,&quot;alt&quot;:&quot;System Design on AWS&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://msdeep14.substack.com/i/196777274?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026a807c-91b8-446c-81a4-964fc2c210c5_1024x1366.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="System Design on AWS" title="System Design on AWS" srcset="https://substackcdn.com/image/fetch/$s_!hkD-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026a807c-91b8-446c-81a4-964fc2c210c5_1024x1366.png 424w, https://substackcdn.com/image/fetch/$s_!hkD-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026a807c-91b8-446c-81a4-964fc2c210c5_1024x1366.png 848w, https://substackcdn.com/image/fetch/$s_!hkD-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026a807c-91b8-446c-81a4-964fc2c210c5_1024x1366.png 1272w, https://substackcdn.com/image/fetch/$s_!hkD-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F026a807c-91b8-446c-81a4-964fc2c210c5_1024x1366.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></div></figure></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://msdeepsingh.com/books/&quot;,&quot;text&quot;:&quot;Everything about \&quot;System Design on AWS\&quot;&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://msdeepsingh.com/books/"><span>Everything about "System Design on AWS"</span></a></p><h3>Previous Expertise</h3><p>If you already have expertise with some technology then you know how to use it in the best way possible. If something meets the requirements and you also have previous working experience, nothing beats this combination.</p><p>In case you&#8217;re new to databases or your use case is totally new, try to stick with battle-tested software. If a lot of people have used something at scale already, you&#8217;ll get ton of support from community. </p><h3>Cost</h3><p>You should be able to afford something to use it. Cost is important consideration, this is mostly applicable to managed offerings. When it comes to cost, I recommend to look at total cost of operations and not just the monthly bill paid to the provider.</p><p>See,</p><ul><li><p>How much time you&#8217;re saving in launching your product by leveraging managed offering. This is also applicable to other solutions as well and not just databases.</p></li><li><p>How much operational burden it takes off from your plate.</p></li></ul><p>With this, let&#8217;s conclude the discussion.</p><h2>Conclusion</h2><p>Always consider trade-offs for any decision you make, what are the pros and cons for any choice being made. Also, there is thin line between database features these days. There are a lot of managed relational database offerings with horizontal scaling support so you don&#8217;t have to implement this in-house. There are a lot of non-relational database offerings with transactional support.</p><p>I&#8217;ll recommend to choose non-relational only if you know you need it. Else stick to relational databases, they solves most of the requirements. Happy Building!</p><p><strong>Check out the YouTube video for the discussion with the community -</strong> </p><div id="youtube2-9nXYR3vt6f0" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;9nXYR3vt6f0&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/9nXYR3vt6f0?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div>]]></content:encoded></item><item><title><![CDATA[Designing Data-Intensive Applications Book Summary]]></title><description><![CDATA[Don't have time to read the entire book, read the summary instead]]></description><link>https://systemdesignfromscratch.org/p/designing-data-intensive-applications</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/designing-data-intensive-applications</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Sat, 14 Feb 2026 11:01:30 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!hyee!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b5863-6e28-4ece-85b0-5aa8fe2632cc_608x608.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Designing Data-Intensive Applications, often referred to as DDIA, is popular and recommended book in Software Engineering domain. I personally read this book and it contains mix of theoretical and practical knowledge. Completing the book definitely requires time and concentration. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading The Scalability Times! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><p>As I was going through the book, I created chapter-wise short notes and YouTube videos as a summary.</p><div class="file-embed-wrapper" data-component-name="FileToDOM"><div class="file-embed-container-reader"><div class="file-embed-container-top"><image class="file-embed-thumbnail-default" src="https://substackcdn.com/image/fetch/$s_!0Cy0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack.com%2Fimg%2Fattachment_icon.svg"></image><div class="file-embed-details"><div class="file-embed-details-h1">DDIA Chapter 1-12 Notes</div><div class="file-embed-details-h2">70.1MB &#8729; PDF file</div></div><a class="file-embed-button wide" href="https://msdeep14.substack.com/api/v1/file/0a69db6d-b47c-4472-93ba-a77e99d3161c.pdf"><span class="file-embed-button-text">Download</span></a></div><div class="file-embed-description">Chapter-wise summary of Designing Data-Intensive Applications book</div><a class="file-embed-button narrow" href="https://msdeep14.substack.com/api/v1/file/0a69db6d-b47c-4472-93ba-a77e99d3161c.pdf"><span class="file-embed-button-text">Download</span></a></div></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.youtube.com/watch?v=BDxGNhnZaEc&amp;list=PLGPe9uvn5fMZ1__Z6yrvcMqiyo5SEeSqP&amp;index=1&quot;,&quot;text&quot;:&quot;Watch on YouTube&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://www.youtube.com/watch?v=BDxGNhnZaEc&amp;list=PLGPe9uvn5fMZ1__Z6yrvcMqiyo5SEeSqP&amp;index=1"><span>Watch on YouTube</span></a></p><h3>Should you read the book?</h3><p>An excerpt from the O&#8217;Reilly around usefulness of the book</p><blockquote><ul><li><p>Peer under the hood of the systems you already use, and learn how to use and operate them more effectively</p></li><li><p>Make informed decisions by identifying the strengths and weaknesses of different tools</p></li><li><p>Navigate the trade-offs around consistency, scalability, fault tolerance, and complexity</p></li><li><p>Understand the distributed systems research upon which modern databases are built</p></li><li><p>Peek behind the scenes of major online services, and learn from their architectures</p></li></ul></blockquote><h3>Where can I get a copy?</h3><ul><li><p><a href="https://amzn.to/3O6laOU">amazon.com</a></p></li><li><p><a href="https://amzn.to/3O4uzGA">amazon.in</a></p></li><li><p><a href="http://oreillymedia.pxf.io/ZVbdLq">O&#8217;Reilly online</a></p></li><li><p><a href="https://www.scylladb.com/wp-content/uploads/ScyllaDB-Designing-Data-Intensive-Applications.pdf">ScyllaDB sponsored chapters</a> for free</p></li></ul><p> </p><p></p><p></p>]]></content:encoded></item><item><title><![CDATA[The WHY of Databases?]]></title><description><![CDATA[Why do I need a Database if I can directly store data in files?]]></description><link>https://systemdesignfromscratch.org/p/the-why-of-databases</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/the-why-of-databases</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Mon, 09 Feb 2026 17:03:57 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tE9n!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Back in 2nd year of my college, I built a train-ticket booking application (somewhat similar to IRCTC in India). The application was built in C++ with Qt framework. Not sure if you heard about this framework but it&#8217;s good and get&#8217;s the job done. The below image is the landing page:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tE9n!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tE9n!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png 424w, https://substackcdn.com/image/fetch/$s_!tE9n!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png 848w, https://substackcdn.com/image/fetch/$s_!tE9n!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png 1272w, https://substackcdn.com/image/fetch/$s_!tE9n!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tE9n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png" width="1366" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:1366,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:869646,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://msdeep14.substack.com/i/186725224?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tE9n!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png 424w, https://substackcdn.com/image/fetch/$s_!tE9n!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png 848w, https://substackcdn.com/image/fetch/$s_!tE9n!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png 1272w, https://substackcdn.com/image/fetch/$s_!tE9n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe195cdb9-9cfa-4adb-9539-b58ed8b45bff_1366x768.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Figure 1. Train booking application</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>There was something interesting about the project. There was no underlying database. The data was directly dumped to files, including login details, train details, booking details, etc. Example, train details for sun stored in <a href="https://github.com/msdeep14/IRCTC/blob/master/sun.txt">sun.txt</a>. Checkout code on Github - <a href="https://github.com/msdeep14/irctc">https://github.com/msdeep14/irctc</a></p><pre><code>1 2 12956 jp-pune_exp 3:20PM 51 587
2 1 12957 jp-pune_exp 9:15AM 87 501
20 21 19876 goa_exp 5:00PM 54 709
3 2 10786 jhelum 5:25PM 112 654
1 9 11760 jp-mumbai-exp 2:00PM 67 543
1 2 34561 premium 11:00AM 45 1700</code></pre><p>So I think I&#8217;m eligible to answer the question; why do we need database if you can store data in files?</p><h2>Bottlenecks</h2><p>If there is already classic file storage available, what&#8217;s the need for all kind of databases? Let&#8217;s take an quick example, you wish to get all the trains from Jaipur to Pune:</p><ul><li><p>The code snippet above shares trains availability as per source to destination. The beginning two numbers are keys mapped to locations.</p></li><li><p>Essentially, you&#8217;ll pick the file for a day and find the train.</p></li><li><p>What if there is no direct trains? It constructs a graph from file data and finds the trains matching to source and destination.</p></li></ul><p>It&#8217;s works all great for college project because there is not much data but soon it will face problems:</p><ul><li><p>Increased latency</p></li><li><p>Supporting different query patterns</p></li></ul><h2>Introducing Databases </h2><p>At a very high level, databases offers structured way of accessing the data. Depending on the use case, the data is stored in a way that it&#8217;s retrieval is fast. There are different kind of databases depending on the requirements. Chapter 2, 3 &amp; 10 of O&#8217;Reilly title &#8220;System Design on AWS&#8221; explores multiple databases with their architectures.</p><p>Here is a diagrammatic representation:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qehK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd45b63f8-23a7-41b4-b0c1-a8e142f5f2fa_690x684.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qehK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd45b63f8-23a7-41b4-b0c1-a8e142f5f2fa_690x684.png 424w, https://substackcdn.com/image/fetch/$s_!qehK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd45b63f8-23a7-41b4-b0c1-a8e142f5f2fa_690x684.png 848w, https://substackcdn.com/image/fetch/$s_!qehK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd45b63f8-23a7-41b4-b0c1-a8e142f5f2fa_690x684.png 1272w, https://substackcdn.com/image/fetch/$s_!qehK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd45b63f8-23a7-41b4-b0c1-a8e142f5f2fa_690x684.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qehK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd45b63f8-23a7-41b4-b0c1-a8e142f5f2fa_690x684.png" width="690" height="684" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d45b63f8-23a7-41b4-b0c1-a8e142f5f2fa_690x684.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:684,&quot;width&quot;:690,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:257539,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://msdeep14.substack.com/i/186725224?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd45b63f8-23a7-41b4-b0c1-a8e142f5f2fa_690x684.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qehK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd45b63f8-23a7-41b4-b0c1-a8e142f5f2fa_690x684.png 424w, https://substackcdn.com/image/fetch/$s_!qehK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd45b63f8-23a7-41b4-b0c1-a8e142f5f2fa_690x684.png 848w, https://substackcdn.com/image/fetch/$s_!qehK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd45b63f8-23a7-41b4-b0c1-a8e142f5f2fa_690x684.png 1272w, https://substackcdn.com/image/fetch/$s_!qehK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd45b63f8-23a7-41b4-b0c1-a8e142f5f2fa_690x684.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image buttonBase-GK1x3M"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" class="icon-noB79L"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image buttonBase-GK1x3M"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2 icon-noB79L"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Figure 2 Decision Flowchart for Database selection</p><p>Let&#8217;s take an example from train ticket booking. Instead of storing the data in the files, if it&#8217;s stored in relational database such as PostgreSQL then it makes easier. For the query pattern, get all the trains from Jaipur to Pune. The point of consideration was how can we skip the reading all the records. The database indexes can be created location and time wise, reducing the data footprint.</p><p>Figure 2 offers some clarity on decisions can be made. Further, database choice is not just the use case, it&#8217;s combination of all below factors. This is also covered in YouTube channel video.</p><ul><li><p>Solves the use case (read/write access patterns)</p></li><li><p>Previous Expertise with the database</p></li><li><p>Cost</p></li><li><p>Battle-tested software</p></li><li><p>Cloud Managed vs Self Managed (Operational Overhead)</p></li><li><p>Time to Market</p></li></ul><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://youtu.be/9nXYR3vt6f0&quot;,&quot;text&quot;:&quot;Watch on YouTube&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://youtu.be/9nXYR3vt6f0"><span>Watch on YouTube</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Facebook Architecture From 2005]]></title><description><![CDATA[Early architecture of Facebook]]></description><link>https://systemdesignfromscratch.org/p/facebook-architecture-from-2005</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/facebook-architecture-from-2005</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Wed, 21 Jan 2026 13:54:58 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!hyee!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b5863-6e28-4ece-85b0-5aa8fe2632cc_608x608.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://systemdesignfromscratch.org/subscribe?"><span>Subscribe now</span></a></p><p>The architecture evolves over time and the idea should always be we&#8217;re able to iterate over it. </p><ul><li><p>It&#8217;s nice when you get stuff right the first time but we don&#8217;t need to</p></li><li><p>As long as you get the architecture as right as possible; the implementation stuff isn&#8217;t going to be big of a deal</p></li></ul><p>This article captures the very early architecture of Facebook, how it started and challenges faced with scaling.</p><h3>Initial Architecture</h3><p>Facebook was launched in February 2004 with focus on connecting people for one school</p><h4>Tech Stack</h4><ul><li><p>Programming Language: PHP</p></li><li><p>Database: MySQL</p></li><li><p>Apache Web server</p></li></ul><div class="captioned-image-container"><figure><div class="image-link image2" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hEwM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17c35a72-8561-4549-bc0a-196da341d77f_316x118.png 424w, https://substackcdn.com/image/fetch/$s_!hEwM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17c35a72-8561-4549-bc0a-196da341d77f_316x118.png 848w, https://substackcdn.com/image/fetch/$s_!hEwM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17c35a72-8561-4549-bc0a-196da341d77f_316x118.png 1272w, https://substackcdn.com/image/fetch/$s_!hEwM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17c35a72-8561-4549-bc0a-196da341d77f_316x118.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hEwM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17c35a72-8561-4549-bc0a-196da341d77f_316x118.png" width="316" height="118" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/17c35a72-8561-4549-bc0a-196da341d77f_316x118.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:118,&quot;width&quot;:316,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:16178,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://msdeep14.substack.com/i/185182416?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17c35a72-8561-4549-bc0a-196da341d77f_316x118.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hEwM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17c35a72-8561-4549-bc0a-196da341d77f_316x118.png 424w, https://substackcdn.com/image/fetch/$s_!hEwM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17c35a72-8561-4549-bc0a-196da341d77f_316x118.png 848w, https://substackcdn.com/image/fetch/$s_!hEwM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17c35a72-8561-4549-bc0a-196da341d77f_316x118.png 1272w, https://substackcdn.com/image/fetch/$s_!hEwM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17c35a72-8561-4549-bc0a-196da341d77f_316x118.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></div></figure></div><p>                                             Figure 1 Early Facebook Architecture</p><p>The simple architecture served well for single school, but soon there were challenges with more interest and increasing scale.</p><h3>Scaling Challenges</h3><p>Let&#8217;s discuss few of the challenges faced due to architecture limitations:</p><ul><li><p>Privacy: Data and feed separation between the schools</p></li><li><p>Traffic Distribution: </p><ul><li><p>How the data should be distributed for different schools</p></li><li><p>Some schools have heavier usage as compared to others.</p></li></ul></li><li><p> Figure out friends connections with higher degree (friend-of-friend or friend-of-friend-of-friend)</p></li></ul><p>Let&#8217;s discuss on the improvements in the architecture to handle the bottlenecks. </p><h3>Improving Architecture</h3><p>The key aspect is hiring more and more smart people and give them independence to work on the improvements.</p><h4>Onboarding More Schools</h4><p>The first thing that comes to mind for handling more traffic is adding more machines. </p><ul><li><p>We mentioned web server and MySQL coupled on same machine, so the idea is to decouple the storage from application server and introduce load balancing between the machines. </p></li><li><p>This also removed single point of failure. Consistent database layer ensures traffic can be served from any operational machine.</p></li></ul><h4>Handling Friend-Of-Friend</h4><p>If you wish to figure out friend of a person, it&#8217;s a direct query to database. For friend-of-friend:</p><ul><li><p>Retrieve friend list of a person</p></li><li><p>Iterate over this list and get friend list of all the items</p></li><li><p>This becomes n*n operation.</p></li></ul><p>For friend-of-friend-of-friend, it becomes n*n*n operation; so it&#8217;s compute-intensive. The current architecture uses dedicated graph database, but back then: </p><ul><li><p>Split the database and create one instance of mysql database for each school in the network</p></li><li><p>How does this help? Now you&#8217;ve to compute n*n*n for 10k (approximate number of people signed up from one school) instead of n*n*n over 6 million (all people across the schools)</p></li></ul><p>The above is in addition to decoupling application servers and database compute. This helped a lot but further the traffic was reaching 100 Million pages/day, a query approximately takes 2-4 milliseconds. The problem lies in each page repeating on the same queries.</p><h4>Improving Database Performance</h4><p>What comes to mind to solves the same query problem? Cache the results to avoid hitting the database. Facebook introduced Memcached as caching layer; this brought down query performance to 0.3-0.5 milliseconds.</p><p>There were couple of issues though with the distributed architecture of memcached instances; If a memcached instances go down: </p><ul><li><p>There is no redundancy on information.</p></li></ul><ul><li><p>Cache miss occurs; and all the traffic routes to database.</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">We&#8217;ll discuss more on scaling memcached in future posts.  Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Facebook introduced photo sharing feature, let&#8217;s discuss on how it&#8217;s implemented.</p><h4>Photo Storage</h4><p>From early stage, Facebook chose to smaller machines instead of one big machine. The disk is relatively slow but stable, to overcome the slowness:</p><ul><li><p>High RAM Caching machines to hold most of the thumbnails and frequently accessed images.</p></li></ul><p><strong>The space consumed by photos is on higher side, some issues uncovered:</strong></p><ul><li><p>If you wish to upload a photo album with 30 photos (3 MB each), then 90MB is total size; Networking issues with slow internet. </p></li><li><p>Router used was built to support 1GB at a time.</p></li></ul><p><strong>Solution:</strong></p><ul><li><p>Built Java applet and ActiveX control to couple the choosing of photos</p></li><li><p>Compression at client side.</p></li></ul><p><strong>It helps:</strong></p><ul><li><p>Upload photos quickly</p></li><li><p>Resource optimisation - less server CPU utilisation</p></li></ul><p>Even with caching machines, transferring images to users takes time. So the solution is to move caching near to users, aka, Content Delivery Networks (CDNs).</p><h3>Conclusion</h3><p>Follow Iterative Design Process; Remember you don&#8217;t have built it right (or perfect) the first time. Happy Building!</p><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading The Scalability Times! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Coming soon]]></title><description><![CDATA[This is System Design From Scratch.]]></description><link>https://systemdesignfromscratch.org/p/coming-soon</link><guid isPermaLink="false">https://systemdesignfromscratch.org/p/coming-soon</guid><dc:creator><![CDATA[Mandeep Singh Shekhawat]]></dc:creator><pubDate>Sun, 05 May 2024 14:14:38 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!hyee!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F678b5863-6e28-4ece-85b0-5aa8fe2632cc_608x608.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This is System Design From Scratch.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://systemdesignfromscratch.org/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://systemdesignfromscratch.org/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item></channel></rss>