<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Headstart-System-Design on Ravi Vats</title>
    <link>https://ravivats.github.io/tags/headstart-system-design/</link>
    <description>Recent content in Headstart-System-Design on Ravi Vats</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 25 Dec 2020 00:00:00 +0800</lastBuildDate>
    <atom:link href="https://ravivats.github.io/tags/headstart-system-design/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>HeadStart System Design — Part 2 — My AWS Certified Solutions Architect Associate Journey</title>
      <link>https://ravivats.github.io/blog/headstart-system-design-p02-aws-solution-architect-design/</link>
      <pubDate>Fri, 25 Dec 2020 00:00:00 +0800</pubDate>
      <guid>https://ravivats.github.io/blog/headstart-system-design-p02-aws-solution-architect-design/</guid>
      <description>How to prepare for the exam and the things learned through it.</description>
      <content:encoded><![CDATA[<p><img alt="headstart-system-design" loading="lazy" src="/images/headstart-system-design.png#center"></p>
<p>AWS offers various certification programs aimed towards Software Development, Solution Architecture, Machine Learning Engineering, Cyber Security, etc.</p>
<p>Taking these certifications is a good idea if:</p>
<ol>
<li>You are someone who has been using AWS services as a part of the solution in the tech stack you are working on for more than a year</li>
<li>Or, you are someone who wants to learn more about cloud tech and the services offered and how to use them for your working domain (ML, Cyber Security, Solution Architecture, etc.)</li>
</ol>
<p>Since I checked both of the above points, I decided to sign up for the certification and cleared it in Dec 2020.</p>
<h2 id="how-i-prepared-for-my-aws-certifications">How I prepared for my AWS certifications</h2>
<p>There are many different paths available.</p>
<p><em><strong>1. You can head to the AWS <a href="https://aws.amazon.com/certification/certification-prep">certification page</a> and choose the exam that you want to prepare for. Preparation included:</strong></em></p>
<p><img alt="headstart-system-cert-prep-homepage" loading="lazy" src="/images/2020-12-25/aws-certification-prep.png#center"></p>
<p>Source: <a href="https://aws.amazon.com/certification/certification-prep">AWS Certification Prep Homepage</a></p>
<p>a. Reading standard white-papers illustrating solutions for a given type of business problem.</p>
<blockquote>
<p>This gives an idea about general patterns of solutions you are expected to come up with during the examination.</p>
</blockquote>
<p>b. Reading up about common services using AWS Documentation (more about it in point 2).</p>
<p>c. Solving sample questions, previous exam questions, and taking a practice exam.</p>
<p>d. You can take AWS Certification online training given by their experts also.</p>
<p><em><strong>2. For the various services offered by AWS for your domain, browsing into AWS documentation for those services, to understand things like:</strong></em></p>
<p><img alt="headstart-system-cert-prep-homepage" loading="lazy" src="/images/2020-12-25/aws-cloudfront-docs.png#center"></p>
<p>Source: <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html">AWS CloudFront Documentation</a></p>
<ul>
<li>
<p>How is this service priced? What are the different types of variants of the service available?</p>
</li>
<li>
<p>Is this service auto-scalable? Is this service serverless?</p>
</li>
<li>
<p><em><strong>Hands-on labs</strong></em> -&gt; Setting up the service in your developer account (in free tier) and trying out requests and checking the responses from the service.</p>
</li>
<li>
<p>Comparing the service to its alternative offerings. I.e. RDS for MySQL vs. Aurora for MySQL -&gt; Which service should be used when? What are the pros and cons of the service when compared to its alternatives?</p>
</li>
<li>
<p>Understanding where does this service fits in the whole flow. I.e.</p>
<ul>
<li>AWS Cloudfront fits in the flow whenever some content needs to be available to the public at low latencies.</li>
<li>AWS DynamoDB and DAX (DynamoDB Accelerator) fits in the flow whenever highly scalable E-commerce, web applications need a highly scalable DB for micro-second latencies.</li>
</ul>
</li>
</ul>
<p><em><strong>3. You can also choose to go through a comprehensive certificate preparation course with all of the above-mentioned things (documentation, white-papers, general patterns, sample questions, hands-on labs, etc.) collected in one place.</strong></em></p>
<p>Some good courses are (in my case, for AWS Solutions Architect Associate Certification):</p>
<ol>
<li><a href="https://acloudguru.com/course/aws-certified-solutions-architect-associate-saa-c02">A Cloud Guru Solutions Architect Associate</a></li>
<li><a href="https://www.pluralsight.com/courses/aws-certified-solutions-architect-associate">Pluralsight: AWS Certified Solutions Architect — Associate</a></li>
<li><a href="https://www.udemy.com/course/aws-certified-solutions-architect-associate-saa-c02">Ultimate AWS Certified Solutions Architect Associate 2021</a> by <a href="https://twitter.com/stephanemaarek">Stéphane Maarek</a></li>
</ol>
<ul>
<li>(In addition to the official AWS websites, I purchased and used this one to prepare)</li>
<li>Instead of watching the videos. I went through the slides provided for all the videos in this course.</li>
<li>After completing the slides for one section (i.e. EC2), I would solve the quiz provided for the section.</li>
<li>After completing going through all slides and quizzes, I would go through sample solution architectures in the course and on the AWS website.</li>
<li>At last, I solved a full practice paper with 65 questions and a 130-minute time limit, like in the real exam for practice.</li>
</ul>
<h2 id="things-i-learned-from-the-certification">Things I learned from the certification</h2>
<p>Apart from learning in detail about the AWS services when doing the certification prep, one also learns a lot about system design and how to come up with solution architectures for various business needs.</p>
<p>Most of these concepts are cloud-platform agnostic and help build a foundational understanding of system design, things to consider while designing a new solution, or suite of microservices, or any other web/cloud components talking to one another.</p>
<p><strong>These concepts are wrapped around general cloud platform agnostic (is for any cloud provider Like AWS, Azure, Google Cloud , etc.) questions. For example:</strong></p>
<ol>
<li>What is meant by scalability? (i.e. Horizontal scalability vs vertical scalability, What is auto-scaling, on which metrics can we scale in or out (CPU %, Network in, Network out, etc.)</li>
<li>What are the different ways of storing data? Structured (SQL), semi-structured (NoSQL, JSON), unstructured (Files in NFS, tapes, etc.)</li>
<li>What is load balancing? Different types like Load Balancing on Application layer vs. Network Layer?</li>
<li>What is rate-limiting? And why it is important? What are its different levels (Rate limit on the gateway vs. Rate limit per microservice vs. Rate limit per instance vs. Rate limit per client)</li>
<li>What is a firewall? Why is it necessary? How does it prevent internal services from DDoS attacks, etc.?</li>
<li>What are the common ports used on different protocols and applications? I.e. Port 22 is for SSH, Port 80 is for HTTP, Port 443 is for HTTPS, Port 3306 is for MySQL, etc.</li>
<li>What is caching? Why it is important for performance and saving compute? How to optimally do cache invalidation?</li>
<li>Write-through vs. Write-back for writing cache values to DB.</li>
<li>Why are CDNs important? How does caching work in CDNs? How does having servers at the edge helpful in reducing latencies to serve consumers?</li>
<li>What is serverless architecture? Why is it so popular nowadays? What is a typical serverless alternative to a 3 tier normal cloud architecture having a Gateway, Load Balancer, Scaling Group, Computer Instances, and DB Instances?</li>
<li>When to use pub-sub mechanism vs. when to use queues? How these two messaging channels can be used to decouple systems from one another? What is the fan-out architecture?</li>
<li>What is the difference between OLTP DB (like Aurora) vs. OLAP DB (like Redshift)? Why are OLAP DBs having columnar storage, unlike OLTP DBs which are row based?</li>
<li>How are graph DBs (i.e. Neptune) different from OLTP, OLAP, or NoSQL DBs and when should they be used?</li>
<li>How being multi-region or multi-availability helps in being highly available and DR (i.e Disaster recovery) compatible? How does failover happen when one region goes down? (Hint: Based on health checks of the instances)</li>
<li>For DBs, how does having read-replicas help in increasing DB performance? Can we couple read replicas and caching for a DB?</li>
<li>What is encryption at rest vs. encryption in transit? What is symmetric vs. asymmetric encryption? What is server-side vs. client-side encryption?</li>
<li>What is authentication and how it is different from authorization? Why is the least needed privilege ideal for authorization? How to scale authorization using entities like users, groups, roles, and policies? What are the common standards for auth like the OAuth API flow? What is MFA and why is it recommended nowadays days?</li>
<li>What is the difference between SDK, framework, and library? And when to provide which of these to the clients?</li>
<li>What is whitelisting? What is inbound IP vs. outbound IP whitelisting?</li>
</ol>
<p>Thanks for reading till the last bit! Wishing you the best with your cloud certification journey!</p>
]]></content:encoded>
    </item>
    <item>
      <title>HeadStart System Design — Part 1 — Design Pattern Intuitions</title>
      <link>https://ravivats.github.io/blog/headstart-system-design-p01-design-pattern-intuitions/</link>
      <pubDate>Sun, 16 Aug 2020 00:00:00 +0800</pubDate>
      <guid>https://ravivats.github.io/blog/headstart-system-design-p01-design-pattern-intuitions/</guid>
      <description>Intuitions about which design pattern to use based on the input you provide and the state and functionality you want.</description>
      <content:encoded><![CDATA[<p><img alt="headstart-system-design" loading="lazy" src="/images/headstart-system-design.png#center"></p>
<p>The other day, a friend asked me on how I go about choosing a design pattern in a given scenario, because it was not always very clear.</p>
<p>Some design patterns are similar in terms of functionality (i.e. factory vs. builder)</p>
<p>I presented my intuitions via chat, and at the end of the discussion we both realized that with these intuitions for some of the design patterns in mind, choosing next time among them will be easier.</p>
<p>Hence, I thought of documenting and sharing it with everyone.</p>
<h2 id="factory"><a href="https://en.wikipedia.org/wiki/Factory_method_pattern">Factory</a></h2>
<p>Say that you are shopping from a factory outlet of a clothing company. You will only get t-shirts based on the size grades i.e. S, M, L, XL etc.</p>
<p>Hence, single input from our side i.e. S, M, L, XL etc. will define the whole t-shirt.</p>
<blockquote>
<p>Similarly, when you want to specify a single input argument like a keyword or an <strong><em>ENum</em></strong>, and get a variation of the main <strong><em>abstract class/interface TShirt</em></strong> created for you like <strong><em>SmallSizeTShirt</em></strong>, then you should go with <strong><em>Factory</em></strong> pattern.</p>
</blockquote>
<p>Similar example is covered here, with <strong><em>abstract class/interface Person</em></strong> and its custom variations <strong><em>Villager</em></strong> and <strong><em>CityPerson</em></strong> created for use that are created on the basic of a single input, the <strong><em>enum PersonType</em></strong>.</p>
<p><img alt="headstart-system-design-factory-design-pattern-example" loading="lazy" src="/images/2020-08-16/factory-design-pattern.png#center"></p>
<p>Factory Design Pattern in C#. Source: <a href="https://en.wikipedia.org/wiki/Factory_method_pattern">Wikipedia</a></p>
<h2 id="builder"><a href="https://en.wikipedia.org/wiki/Builder_pattern">Builder</a></h2>
<p>Now say that instead of going to a factory outlet, you want to have something that fits you better, so you went to a tailor for custom tailored shirt.</p>
<p>Now, the tailor will take note of various other inputs like your chest size, your arm length, your shoulder length etc.</p>
<p>Hence, you can see that the tailor doesn’t have grades based on only one input like size, instead he has a number of input parameters and is makes unique shirts for each customer based on the input values for each of them.</p>
<p>Here, tailor is synonymous with a <strong><em>builder</em></strong>.</p>
<blockquote>
<p>Hence, when there are multiple inputs from your side to construct a variation of the main <strong><em>abstract class/interface Shirt</em></strong>, use <strong><em>ShirtBuilder</em></strong> to return a <strong><em>CustomShirt</em></strong> for you based on various inputs.</p>
</blockquote>
<p>Similar example is covered here, with ICarBuilder using various inputs like <strong><em>NumDoors</em></strong>, <strong><em>Colour</em></strong>, <strong><em>BrandName</em></strong> and <strong><em>ModelName</em></strong> and some code logic to construct a Ferrari 488 Spider Car.</p>
<p><img alt="headstart-system-design-builder-design-pattern-example" loading="lazy" src="/images/2020-08-16/builder-design-pattern.png#center"></p>
<p>Builder Design Pattern in C#. Source: <a href="https://en.wikipedia.org/wiki/Builder_pattern">Wikipedia</a></p>
<h2 id="singleton"><a href="https://en.wikipedia.org/wiki/Singleton_pattern">Singleton</a></h2>
<p>Suppose, you have a DB connection to initialize, and you want this DB connection to be established with your DB, and then every time you want to query for some data in a function, you get the <strong><em>same Connection object in establishedConnection state</em></strong> returned, to quickly query data.</p>
<blockquote>
<p>In such scenarios where, not only do you want the same type of object to be returned, but you also want it to have a given state always, and for it to be a <strong><em>static method call</em></strong> to get that object, then you use the <strong><em>Singleton</em></strong> pattern.</p>
</blockquote>
<blockquote>
<p><strong><em>Additional feature</em></strong>: <em>A thread safe singleton can be created so that singleton property is maintained even in multi-threaded environment.</em>
<em>To make a singleton class thread-safe,</em> <strong><em>getInstance()</em></strong> <em>method is made synchronized so that one one thread can access it at a time.</em></p>
</blockquote>
<p><img alt="headstart-system-design-singleton-design-pattern-example" loading="lazy" src="/images/2020-08-16/singleton-design-pattern.png#center"></p>
<p>Singleton Design Pattern supporting multi-threading in Java. Source: <a href="https://en.wikipedia.org/wiki/Singleton_pattern">Wikipedia</a></p>
<h2 id="mixins"><a href="https://en.wikipedia.org/wiki/Mixin">Mixins</a></h2>
<p>Suppose you are being told to make a system to accept pizza orders for a restaurant.</p>
<p>Here, <strong><em>class Pizza</em></strong> itself has many variations like <strong><em>ThinCrust</em></strong>, <strong><em>ThickCrust</em></strong>, <strong><em>ExtraCheese</em></strong> etc.</p>
<p>And, on-top of pizza you have a extra class like <strong><em>class Topping</em></strong> which has variations like <strong><em>Mushroom</em></strong>, <strong><em>BlackOlives</em></strong>, <strong><em>Pineapple</em></strong> etc.</p>
<p>Here, any <strong><em>Topping</em></strong> can go with any <strong><em>Pizza</em></strong> and vice versa.</p>
<blockquote>
<p>Hence, for this kind of multiple inheritance requirement where:</p>
<ol>
<li>You want to provide a lot of optional features for a class.</li>
<li>You want to use one particular feature in a lot of different classes.</li>
</ol>
<p>For cases like these, you can use the <strong><em>Mixin</em></strong> pattern.</p>
<p><strong>Note</strong>: <em>Mixins only exist in languages that support multiple-inheritance. You can’t do a mixin in Java or C#.</em></p>
</blockquote>
<p><img alt="headstart-system-design-mixin-design-pattern-example" loading="lazy" src="/images/2020-08-16/mixin-design-pattern.png#center"></p>
<p>Mixin Design Pattern (Pizza-Topping Example) in Python</p>
<p><img alt="headstart-system-design-mixin-design-pattern-example-output" loading="lazy" src="/images/2020-08-16/mixin-design-pattern-output.png#center"></p>
<p>Output for above example</p>
<h2 id="adapter"><a href="https://en.wikipedia.org/wiki/Adapter_pattern">Adapter</a></h2>
<p>Suppose that you have to build an app interface for users to orders food from different restaurants. Here, menu shown to the user on your app is same for every restaurant, but the order information that each restaurant gets in slightly different.</p>
<blockquote>
<p>In cases like these, where one common input has to be mapped to different kinds to input or actions taken we should use the <strong><em>Adapter</em></strong> Pattern.</p>
<p><strong><em>Intuition</em></strong> is that adapters like charging adapter in real world do exactly the same thing. They send normal AC current coming at a fixed voltage-current range from the main socket into different charger pins for different devices like camera, phone, usb charger pin etc., all with their own voltage-current range.</p>
</blockquote>
<p>Similar example is covered here, where different charging styles for <strong><em>LightningPhone</em></strong> and <strong><em>MicroUsbPhone</em></strong> are defined via interfaces.</p>
<p>Class <strong><em>IPhone</em></strong> implements only <strong><em>LightningPhone</em></strong> interface (it can only be charged via Lightning) and class <strong><em>Android</em></strong> implements only <strong><em>MicroUsbPhone</em></strong> interface (it can only be charged via Micro USB).</p>
<p>Now, the class <strong><em>LightningToMicroUsbAdapter</em></strong> helps to implement <strong><em>MicroUsbPhone</em></strong> interface and helps charge class <strong><em>Android</em></strong> with that, which otherwise was not possible.</p>
<p><img alt="headstart-system-design-adapter-design-pattern-example" loading="lazy" src="/images/2020-08-16/adapter-design-pattern.png#center"></p>
<p>Adapter Design Pattern in Java. Source: <a href="https://en.wikipedia.org/wiki/Adapter_pattern">Wikipedia</a></p>
<h2 id="reference-links">Reference Links</h2>
<ul>
<li><a href="https://en.wikipedia.org/wiki/Factory_method_pattern">Factory pattern</a></li>
<li><a href="https://en.wikipedia.org/wiki/Builder_pattern">Builder pattern</a></li>
<li><a href="https://en.wikipedia.org/wiki/Singleton_pattern">Singleton pattern</a></li>
<li><a href="https://en.wikipedia.org/wiki/Mixin">Mixin Pattern</a>: <a href="https://stackoverflow.com/questions/533631/what-is-a-mixin-and-why-are-they-useful">Forum Discussion</a>, <a href="https://www.residentmar.io/2019/07/07/python-mixins.html">Blog</a></li>
<li><a href="https://en.wikipedia.org/wiki/Adapter_pattern">Adapter Pattern</a></li>
<li>Other design patterns and their categories:
<ul>
<li><a href="https://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional-ebook/dp/B000SEIBB8">GangOfFour</a> (Classical book on Design Patterns)</li>
<li><a href="https://refactoring.guru/design-patterns/catalog">Blog</a></li>
</ul>
</li>
</ul>
<p>Thanks for reading till the last bit! Cheers to learning! :)</p>
]]></content:encoded>
    </item>
  </channel>
</rss>
