<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Zico Deng on Medium]]></title>
        <description><![CDATA[Stories by Zico Deng on Medium]]></description>
        <link>https://medium.com/@zicodeng?source=rss-75421a2cc2fb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Y39-cLDPCxAb8H8QU-rh5w.jpeg</url>
            <title>Stories by Zico Deng on Medium</title>
            <link>https://medium.com/@zicodeng?source=rss-75421a2cc2fb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 14:54:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zicodeng/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Zico.README (My Personal README for Colleagues)]]></title>
            <link>https://zicodeng.medium.com/zico-readme-my-personal-readme-for-colleagues-d15269dcb576?source=rss-75421a2cc2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d15269dcb576</guid>
            <category><![CDATA[readme]]></category>
            <category><![CDATA[management-and-leadership]]></category>
            <category><![CDATA[personal-introduction]]></category>
            <category><![CDATA[careers]]></category>
            <dc:creator><![CDATA[Zico Deng]]></dc:creator>
            <pubDate>Sun, 07 Aug 2022 16:51:34 GMT</pubDate>
            <atom:updated>2022-08-17T05:09:06.307Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GYxxS1NoRjPz7IxNVcqisQ.png" /></figure><p>It’s very likely that you have read or written a <a href="https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-readmes">project README</a> at some point in your career, especially if you are a software engineer working in the tech industry. But this README is totally different. Unlike a project README whose intention is to communicate important information about a project, this personal README (a.k.a. “How I like to work” doc) aims to introduce my mind and work style so that we can skip the whole “get to know yourself” warm-up phase and jump straight into a productive working relationship 😉</p><h3>My Jobs</h3><h4>Write Code and Ship It</h4><p>As a software engineer, half of my time is hopefully spent on writing code. My code can sometimes be crappy and break things (trying to get better at it every day 😆), but I always admit and own my mistakes (by fixing bugs 🐛 quickly).</p><h4>Bring Energy and Happiness to the Team</h4><p>Generally speaking, I am a very passionate human being. I love smiling and bringing energy to work. I am a happy man and trying to make people around me happy as well 😃</p><h4>Foster Team Culture</h4><p>Even though I am not a manager, I would love to work with the manager or the team to brainstorm and organize various team-building activities. I firmly believe that a healthy, diverse, and inclusive team culture fosters collaboration and communication, which ultimately enables the highly engaging team to achieve business-wide goals faster.</p><h4>Learn and Share</h4><p>I used to dream of becoming a high school teacher. Don’t get me wrong, I wouldn’t say I like lecturing my teammates, but I truly enjoy sharing knowledge with the team.</p><h4>Bring Out the Best in Others (#BOBO)</h4><blockquote>We create an inclusive environment and invest in people so that everyone has the opportunity to do their best work. We make each other better by celebrating great work, sharing feedback, assuming positive intent, and being authentic.</blockquote><p>#BOBO was one of my favorite <a href="https://convoy.com/values/">company values</a> when I worked at Convoy. I was heavily influenced by this value, and it has now become my north star principle when interacting with people and building trust. Let’s help each other become the best version of ourselves.</p><h3>1:1s</h3><h4>Frequency</h4><p>Manager: Preferably a 30-minute session once a week.</p><p>Teammate:</p><ul><li>If you work remotely, I suggest setting up a 15-minute chat once a week.</li><li>If you come to the office regularly, we should do a quick 15-minute catch-up every other week. This is because I am guaranteed to drag you into a random conversation if you sit next to me in the office (hope you don’t find me annoying 😛).</li></ul><h4>Location</h4><p>Let’s find a fun place to chat, shall well (ordered by preference): Nature &gt; a place with a great view (e.g. rooftop) &gt; a coffee shop downstairs &gt; a cool place in the office (IMHO, a meeting room is not considered as cool) &gt; Zoom</p><h4>Topic</h4><p>I am happy to chat anything, whether it’s work related or not. Don’t know what to discuss? Check the list below for inspiration:</p><ul><li>Life</li><li>Mutual feedback</li><li>Help needed</li><li>Career goals</li><li>Important company, org, team-level update I should know</li><li>Project status update (let’s talk about this one last if there is still time left)</li></ul><h4>Notes &amp; AIs</h4><p>I’ve got a very bad memory, so let’s create a doc to capture notes and action items.</p><h3>Communication</h3><h4>Communication Channels</h4><p>My favorite channels ordered by preference: Face-to-face in-person &gt; Zoom (with video on &gt; off) &gt; Slack &gt; Email &gt; Phone &gt; Mail</p><p>For some reason, Slack feels less distant than Email to me, even though they are both internet-based virtual communication channels.</p><h4>After-Hours Communication</h4><p>Not everyone is a 9–5 person. I understand that some people tend to work early in the morning while others tend to perform the best at night. With WFH (Work From Home) becoming a norm and teammates potentially working across different time zones, please be transparent about your work schedule and share with me your normal working hours.</p><p>I will try my best to not disturb you outside of your normal working hours. If there is an urgent matter, I will DM (Direct Message) you via Slack. If I ever ping you in a Slack channel or thread during off-hours, it’s probably not that urgent, so feel free to leave it until the next working day (apologies in advance I still need to ping you because I might forget about it when I wake up the next day 😆)</p><p>Similarly, If you need me during my off-hours, please DM me and explicitly state its urgency.</p><h3>Feedback</h3><p>Positive feedback makes me happy, and negative feedback makes me grow (and eventually be happy when negative feedback turns into positive once I address it 😛).</p><p>I love feedback to the extreme. Feel free to give me feedback at any time, place, or via any means (face-to-face is preferred). Please don’t wait to provide me feedback till the annual review at the end of every year. Even though the annual review is a great opportunity to write formal feedback to each other, I will potentially miss an entire year to improve myself!</p><h3>Interests and Hobbies</h3><p>I love all kinds of things and enjoy a variety of funs: Music 🎶, DJ, anime, drawing 🎨, UI&amp;UX, hiking 🥾, snowboarding 🏂, traveling, writing ✍️, dogs 🐶, cats 🐱, and more. Let me know if we have shared interests and hobbies!</p><h3>Nuances and Quirks</h3><p>My favorite personal motto is “<strong>Be brave enough to suck at something new</strong>”. I get excited when I am learning new things.</p><p><strong>Please be on time for our 1:1s</strong>. I understand that sometimes things can happen (e.g. last important meeting may run over), please DM me in advance if that’s the case. I am more than happy to reschedule if needed.</p><p>Apologize in advance if I ask too many “why” questions in meetings. <strong>Personally, knowing why behind a task or an action is more important than knowing what and how</strong>.</p><p>I am not a native speaker. My thoughts can get lost while speaking too fast or under pressure. <strong>If I am not being clear to you, please interrupt my murmuring and ask me to slow down, relax, and reiterate</strong>.</p><p><strong>My favorite emoji is 💯 (or its variants)</strong>. I would really appreciate it if you could give me 💯 via DM or respond to my Slack messages with 💯 when you believe I am doing a great job.</p><h3>References</h3><p>The truth is I didn’t invent this great idea. I learned it by reading others’ READMEs. Strangely, most examples I found online are written by managers 🤔 I still strongly recommend reading them even if you are an IC. They are quite inspiring!</p><ul><li><a href="https://hypercontext.com/blog/modern-manager-community/how-to-set-expectations-with-your-team">How to Set Expectations With Your Team: Introducing the &quot;How I like to work&quot; doc</a></li><li><a href="https://hypercontext.com/blog/management-skills/49-manager-readmes">49 Manager ReadMes from Slack, Netflix, Google and more (a lot more)</a></li><li><a href="https://hackernoon.com/12-manager-readmes-from-silicon-valleys-top-tech-companies-26588a660afe">12 &quot;Manager READMEs&quot; from Silicon Valley&#39;s Top Tech Companies | HackerNoon</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d15269dcb576" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Redirect Your Website From Non-WWW to WWW URL Using AWS S3 + CloudFront + Route 53]]></title>
            <link>https://zicodeng.medium.com/redirect-your-website-from-non-www-to-www-url-using-aws-s3-cloudfront-route-53-2650127b08dc?source=rss-75421a2cc2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/2650127b08dc</guid>
            <category><![CDATA[cloudfront]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[route-53]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[tricks]]></category>
            <dc:creator><![CDATA[Zico Deng]]></dc:creator>
            <pubDate>Fri, 03 Sep 2021 20:03:18 GMT</pubDate>
            <atom:updated>2022-08-07T16:52:43.699Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cSxnYJfN1A0fjwvx.png" /></figure><p>I am a lazy person. I never type www in front of any URL 😆 For example, when I want to Google something, I just type google.com instead of <a href="http://www.google.com./">www.google.com.</a></p><p>Not surprisingly, a lot of people are like me. We don’t like typing those extra 3 letters. Fortunately, most companies respect our laziness and have found a way to successfully redirect us to their websites even without explicitly typing www.</p><p>So how is this achieved 🤔</p><h3>Goal</h3><p>This post will guide you to set up non-www to www URL redirection for your website using AWS S3, CloudFront, and Route 53. As an example, I will be setting up example.com to <a href="http://www.example.com/">www.example.com</a> redirection.</p><h3>Setup</h3><h4><strong>S3</strong></h4><p>Step 1: create a new S3 bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*6t11P1jcFqgALvG8-ktAlg.png" /></figure><ul><li>Bucket name should be the non-www version of your URL.</li></ul><p>Step 2: enable static website hosting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*XqwF9cU_jGgOCoFrNvwf1g.png" /></figure><ul><li>For hosting type, select “Redirect requests for an object”.</li><li>For host name, type the www version of your URL.</li></ul><p>Step 3: edit bucket policy.</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;PublicRead&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: &quot;*&quot;,<br>            &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::example.com/*&quot;<br>        }<br>    ]<br>}</pre><ul><li>Open the bucket policy editor. Copy and paste the above policy.</li><li><a href="https://stackoverflow.com/a/53497106/7124935">If you encounter access denied error when saving changes even as a root user, you can temporarily deselect all block public access options.</a></li></ul><h4>CloudFront</h4><p>Step 1: create a new CloudFront distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*5R0KozVaz_qepDCi_GlqcQ.png" /></figure><ul><li>For origin domain, please do <strong>NOT</strong> select any option from the auto-populated dropdown, because those options are in S3 REST API format. However, in our use case, we want <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteEndpoints.html">website endpoints</a>. We need to type it manually here.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*MD1lvSpRwVN29NmCIQcYgQ.png" /></figure><ul><li>For view protocol policy, select “Redirect HTTP to HTTPS”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*IIvOc0g24GLYljxW9bpMDw.png" /></figure><ul><li>For alternative domain name (CNAME), type the non-www version of your URL.</li><li>For custom SSL certificate, select the certificate associated with this domain.</li></ul><h4>Route 53</h4><p>Step 1: create a new type A record.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FN14oCypT6MKx9w3VMs9Pw.png" /></figure><ul><li>For record name, just leave it empty.</li><li>For record type, select A.</li><li>For route traffic to, toggle “Alias” first. Then you should see the input box become a dropdown. Select “Alias to CloudFront distribution” option. Lastly, in the distribution dropdown (there should be only one), select the CloudFront distribution URL associated with this domain.</li></ul><h3>Conclusion</h3><p>That’s it! You are only a few steps away to keep your website viewers lazy 🤣</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2650127b08dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS S3 + CloudFront + Custom Domain/SSL + Signed URL]]></title>
            <link>https://zicodeng.medium.com/aws-s3-cloudfront-custom-domain-ssl-signed-url-260a0fac3545?source=rss-75421a2cc2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/260a0fac3545</guid>
            <category><![CDATA[signed-urls]]></category>
            <category><![CDATA[aws-certificate-manager]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[cloudfront]]></category>
            <dc:creator><![CDATA[Zico Deng]]></dc:creator>
            <pubDate>Wed, 24 Feb 2021 07:02:32 GMT</pubDate>
            <atom:updated>2022-08-07T17:00:50.661Z</atom:updated>
            <content:encoded><![CDATA[<p>I know there are many tutorials out there about these topics, but it still took me +3 hours to configure them correctly 😂 I have read and watched every individual topic, but when it came to actually setting them up, I just couldn’t get it right 😭</p><p>I hope it is not a shame to blame the fact that most of the tutorials focus on diving deep into a single topic, definitely not a combination of S3, CloudFront, custom domain with Certificate Manager and Route 53, and signed URL. More importantly, AWS&#39;s “user-friendly” and “aesthetically pleasing” console dashboard just confounds me (please forgive me, I switched from Digital Ocean where the UI/UX is just amazing) 😵</p><h3>Goal</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*f0d8wrZrCfoa6Kz3a3BXhw.png" /></figure><p>At the end of the post, we should be able to achieve uploading a file to S3 via a <strong>signed URL</strong> and viewing that file <strong>ONLY</strong> via a <strong>custom domain</strong> served over <strong>HTTPS </strong>whose certificate is managed by AWS <strong>Certificate Manager</strong>.</p><p>This post is all about steps, no topic deep dive.</p><h3>Setup</h3><h4>S3</h4><p>Step 1: create a new bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8OOKjfFsd2gDx6SDidJ2hQ.png" /></figure><p>Step 2: go with default for the rest configurations, especially “Block Public Access” settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vb6ua8Xfolu9n1W1wBw3CQ.png" /></figure><ul><li>We want to block all public access (default) because this prevents anyone from accessing our bucket or content in the bucket directly.</li></ul><p>Step 3: add CORS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*VxiPsezOK1i9gNhNm_r4Zw.png" /></figure><ul><li>Once S3 bucket is created successfully, navigate to the bucket “Permissions“ settings.</li><li>Scroll all the way to the bottom where we should find CORS settings.</li><li>Click “Edit” and copy and paste the following JSON (feel free to tweak it to meet your app security requirement).</li></ul><pre>[<br>    {<br>        &quot;AllowedHeaders&quot;: [<br>            &quot;*&quot;<br>        ],<br>        &quot;AllowedMethods&quot;: [<br>            &quot;PUT&quot;<br>        ],<br>        &quot;AllowedOrigins&quot;: [<br>            &quot;*&quot;<br>        ],<br>        &quot;ExposeHeaders&quot;: [],<br>        &quot;MaxAgeSeconds&quot;: 3000<br>    }<br>]</pre><h4>Certificate Manager</h4><p>Prerequisite: On the Certificate Manager dashboard, please make sure we are on region <strong>us-east-1</strong>. If not, switch to this region before proceeding with the following steps.</p><p>Step 1: add domain names.</p><ul><li>This domain name will be the alternative domain name to access CloudFront.</li></ul><p>Step 2: select validation methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ot8N0smOHE97apOLHL2naA.png" /></figure><ul><li>Make sure to select <strong>DNS validation</strong> if the domain is owned by you (I guess yes).</li></ul><p>Step 3: add tags (skip if not necessary).</p><p>Step 4: review.</p><p>Step 5: validation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GHQs_nqWTtV6hL0u1bgeeQ.png" /></figure><ul><li>Expand the domain dropdown.</li><li>Click that “Create record in Route 53” blue button.</li><li>Once the modal pops up, click the “Create” button.</li></ul><p>Step 6: verification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bK7R_-DhcUShVnx398sN0Q.png" /></figure><ul><li>Navigate back to the Certificate Manager home page.</li><li>We should see the status change from “Pending” to “Issued”.</li><li>This process may take around 10 minutes, so be patient 🙃</li></ul><h4>CloudFront</h4><p>Step 1: configure “Origin Settings”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UpgjhcKUtJMskVjwWoBPQg.png" /></figure><ul><li>Pay attention to settings circled in green because we need to change their values.</li><li>Origin Domain Name: select the S3 bucket we just created. IMPORTANT: I’d recommend adding the <strong>S3 region</strong> in the auto-populated option to avoid <a href="https://stackoverflow.com/questions/56993266/illegallocationconstraintexception-on-cloudfront-for-s3"><em>IllegalLocationConstraintException issue</em></a>. So it will end up looking like this: &lt;bucket&gt;.s3.&lt;region&gt;.amazoneaws.com.</li><li>Origin ID: auto-filled once “Origin Domain Name” is selected.</li><li>Restrict Bucket Access: select “Yes”.</li><li>Origin Access Identity: select “Create a new Identity”.</li><li>Comment: auto-filled when we select “Create a new Identity”.</li><li>Grant Read Permissions on Bucket: select “Yes, Update Bucket Policy”.</li></ul><p>Step 2: configure “Default Cache Behavior Settings”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*Ev-rI1bdXb1nuN2spuIL_Q.png" /></figure><ul><li>Viewer Protocol Policy: select “Redirect HTTP to HTTPS”.</li></ul><p>Step 3: configure “Distribution Settings”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KpmPN5lczt8SYrQbBRVg5Q.png" /></figure><ul><li>Alternative Domain Names (CNAMEs): the domain name typed here should be identical to what we have added when we set up the Certificate Manager.</li><li>SSL Certificate: select “Custom SSL Certificate”, and in the input box below, select the certificate we have created. If this option is greyed out, it probably means the certificate is not created in <strong>us-east-1 </strong>(pay attention to the prerequisite for Certificate Manager setup).</li></ul><p>Step 4: click the “Create Distribution” blue button.</p><ul><li>Deploying a new CloudFront will take a while, so just be patient here :)</li></ul><p>Step 5: verify it is ready.</p><ul><li>Go back to the CloudFront home page. We should be seeing our new distribution created successfully.</li></ul><p>Troubleshooting:</p><ul><li>New S3 objects return 403 forbidden error: <a href="https://www.youtube.com/watch?v=GsP0xDmnzi0">https://www.youtube.com/watch?v=GsP0xDmnzi0</a></li></ul><h4>Route 53</h4><p>Step 1: go to Route 53 dashboard and click the “Hosted zones” link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*TJjhWi-B9eoa7HLiuzxsJg.png" /></figure><p>Step 2: on the hosted zone page, click your domain name.</p><p>Step 3: create an A record.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z8szHSQmOj3NymRAbBaVbQ.png" /></figure><ul><li>Record name: just need to fill in the subdomain.</li><li>Record type: select “A” record.</li><li>Alias: toggle it on.</li><li>Route traffic to: select “Alias to CloudFront distribution”.</li><li>Then in the last dropdown box, select the CloudFront distribution domain name created earlier. If not sure, we can always go back to the CloudFront home page to verify it.</li></ul><h3>Test</h3><p>I hope the above steps take you less than 30 mins. Now it is time to test our setup.</p><h4>Upload a File via Signed URL</h4><p>Simply run the file below, we should be able to upload any file to S3 via a signed URL.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ac39db97410d8e19c395f0f622bc99e/href">https://medium.com/media/4ac39db97410d8e19c395f0f622bc99e/href</a></iframe><h4>View the File via Direct S3 URL</h4><p>Since we blocked all public access to the bucket and its content, we should see an access denied error if we try to access the file via a direct S3 URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*ml0FUY0eqW8wNbOvoFE6-w.png" /></figure><h4>View the File via CloudFront URL</h4><p>Expected to see the file.</p><h4>View the File via Custom Domain URL</h4><p>Expected to see the file.</p><h3>Conclusion</h3><p>🥳 Congrats! You made it! I hope you had fun navigating the AWS console and clicking the “grey” and “blue” buttons 😏</p><p>Give it some 👏 and share it with others if this step-by-step tutorial helped you! Much appreciated ❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=260a0fac3545" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Gentle Introduction to a Distributed Streaming Platform, Kafka]]></title>
            <link>https://zicodeng.medium.com/a-gentle-introduction-to-a-distributed-streaming-platform-kafka-e2355148dda0?source=rss-75421a2cc2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2355148dda0</guid>
            <category><![CDATA[message-queue]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[messaging-system]]></category>
            <category><![CDATA[streaming-platforms]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Zico Deng]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 19:25:48 GMT</pubDate>
            <atom:updated>2020-07-09T04:44:37.478Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, I was exposed to Kafka at my workplace. I have heard of it a while ago, knowing it is a very popular distributed streaming platform, but I never had a chance to learn it. With my little experience in the traditional messaging system, RabbitMQ, I somehow tend to think of Kafka is just yet another variation created by LinkedIn.</p><p>If you are like me, having a little background knowledge of a message queue, and hoping to learn Kafka, this article is for you. I will first discuss why this technology is created, walkthrough some basic concepts of Kafka, and finally talk about how it differs from other traditional messaging systems.</p><h3>The Problem</h3><p>Before diving into Kafka, let’s talk about why a messaging system exists in the first place. What problem are they trying to solve?</p><h4>👎 Scalability</h4><p>In modern software architecture, engineers are obsessed with the idea of microservice, breaking down a giant monolithic service into many self-contained, independent, and loosely-coupled tiny services. The communication between these microservices is traditionally done by REST API calls. This is fine until one day, a heavily used microservice gets burned out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N5AU2aD-nk0u3SsBFlRcnw.png" /><figcaption>Service A Sweating 💦💦💦</figcaption></figure><p>As we can see from the diagram above, service B, C, D all rely on service A. This means service A has to handle an overwhelming number of requests during high traffic hours. Putting too much pressure on it can lead to the server crash.</p><p>As microservices grow in number, the communication between them increases too. It is common to send a large number of API requests from different microservices to the same destination microservice, which can cause the reusable microservice to burn out. Having that said, direct communication between microservices is not a scalable approach.</p><h4>❌ Message Durability</h4><p>When API requests and responses between services are communicated over the network, there is no guarantee that they are always fulfilled. Because servers are typically stateless, once messages are sent, they are gone. In case of network failure or server downtime, messages can get lost. Even if the server will eventually restart, it never knows about how many messages are lost during downtime, thus not able to reprocess them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q3zjw-5rQwIS5vjOq_ht3A.png" /><figcaption>Service A on Fire 🔥🔥🔥</figcaption></figure><p>As the diagram is shown above, service A is down because of too many requests. When it restarts and brings itself back online, service A is not able to catch up with the missing messages because they are just gone.</p><h4>Synchronous Communication</h4><p>When a source service sends an API request to a destination service, the source service will eventually get a response back. Even though the network operation is asynchronous, meaning the source service can perform other operations during the wait time for a response, the communication is considered as synchronous because the source service needs to wait for the message to be processed by the destination service.</p><h4>Coupled Architecture</h4><p>When services directly interact with each other over the network, they are tightly coupled. When a source service sends an API request, it waits for a response. The length of the wait time is highly dependent on the business logic happening in the destination service. Imagine the destination service needs to perform a complex computation which can take a few minutes, the source service has to wait for that amount of time to get a response.</p><h3>The Solution — Message Broker</h3><p>A message broker is just an intermediary program (a middleware) that deals with incoming messages from producers and outgoing messages to consumers.</p><p>It can be responsible for the following tasks (not necessarily all of them):</p><ul><li>Store messages</li><li>Route messages</li><li>Monitor messages</li><li>Manage messages</li></ul><p>Before getting into details, let’s make sure we understand some basic terminologies:</p><ul><li><strong>Producer/Publisher</strong>: a service/application that produces/publishes messages to a broker (can be thought as a source service in the traditional communication model).</li><li><strong>Consumer/Subscriber</strong>: a service/application that consumes/subscribes messages from a broker (can be thought as a destination service in the traditional communication model).</li></ul><p>Now, let’s see how a message broker addresses problems in direct communication between services.</p><h4>👍 Scalability</h4><p>By introducing a middleman, message broker, we can easily achieve scalability. Brokers are designed to be scaled both vertically and horizontally. No more pressure on our highly reusable service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a_FEOLYOJrQfxWJgAH1EQA.png" /><figcaption>Service A Relaxing 😊😊😊</figcaption></figure><p>The diagram above shows Service B, C, D are talking to brokers instead of directly communicating with service A. The producers are still producing the same number of messages, but this time, the consumer can handle messages at its own comfortable pace.</p><h4>✅ Message Durability</h4><p>With a message broker, messages are never lost because they will be persisted by the broker either in memory or disk until consumers acknowledge they have been processed. Some message brokers even allow messages to be persisted for a configurable amount of time. That means messages can be kept around forever if we want to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fnqXf4kGru5iO7BgLVxPtA.png" /><figcaption>Service A Down ☠️☠️☠️</figcaption></figure><p>In the above diagram, destination service A is down, but source services B, C, D are still operating and producing more messages. Fortunately, our broker in the middle will make sure unread messages are persisted.</p><h4>Asynchronous Communication</h4><p>Because a source service now only communicates with a broker, it does not have to wait for a destination service to finish processing messages and send back a response. This enables truly asynchronous communication.</p><h4>Decoupled Architecture</h4><p>When source services and destination services no longer depend on each other, we end up having a loosely coupled architecture.</p><h3>Kafka</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JqZxEoSo1nTsfxqfXRg1Sg.png" /><figcaption><a href="https://kafka.apache.org/intro">The Almighty Kafka, Single Source of Truth for All Your Data</a></figcaption></figure><p>Finally, we are here. It’s time to talk about Kafka. I apologize it took me so long to explain the problem and solution, but it is worth knowing the background of why a particular technology emerges.</p><p>Created and open-sourced by LinkedIn, Kafka is a scalable, fault-tolerant, and distributed streaming platform.</p><h4>Pros</h4><p>Kafka excels at the following areas:</p><ul><li><strong>Excellent horizontal scalability</strong>: Kafka can easily scale to 100 message brokers and millions of messages per second.</li><li><strong>High performance</strong>: latency could be less than 10ms, which can be considered as real-time.</li><li><strong>Highly trusted</strong>: the technology is trusted by many top tech companies such as LinkedIn, Airbnb, and Netflix.</li></ul><h4>Applications</h4><p>Although Kafka can be used in a lot of different ways, there are two major categories of application:</p><ul><li><strong>Transfer data</strong>: move data between microservices.</li><li><strong>Transform data</strong>: process an input stream and produce an output stream.</li></ul><p>We have just learned what Kafka really is, what benefits it provides, and how it can be used in the real world. Now, let’s dive into its core concepts.</p><h4>Topic</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WlnwoC6fw3XtDx4XPA6wfg.png" /><figcaption><a href="https://kafka.apache.org/intro">Anatomy of a Topic</a></figcaption></figure><p>A topic is an ordered collection of events (a stream of records) stored in a durable way (data is written to disks) for a configurable amount of time (could be days, months, or years).</p><p>There is no limit on how big a topic should be. It could be small or enormous, depending on the amount of data.</p><p>Consumers can subscribe to different topics for different categories of data.</p><h4>Partition</h4><p>In a nutshell, a partition is just a subset of data on a topic.</p><p>Why is a topic divided into multiple partitions?</p><ul><li>Because a server has a limit on disk size, partition allows a topic to grow infinite in size, theoretically storing an infinite amount of data. Imagine a topic that has terabyte size of data that cannot fit into one server. This can be solved by breaking that topic into multiple subsets and store them on different servers.</li><li>It allows consumers to access a topic in parallel.</li></ul><p>To ensure high availability, each partition is also replicated for fault tolerance in case of system failure.</p><p>While more partitions give us higher throughput, more parallel read/write units, and increased storage limit, they can also cost us more open file handles (each partition maps to a file directory and requires one file handle), more memory in the client(the producer buffers messages per partition), and higher end-to-end message delivery latency (replicating data across all in-sync replicas and committing messages now takes longer).</p><h3>Traditional Messaging Systems vs Kafka</h3><p>You probably have noticed that I describe Kafka as a distributed streaming platform, but how is it different from traditional messaging systems such as RabbitMQ?</p><p>I will compare the two attribute by attribute.</p><h4>Payload (Message vs Stream)</h4><p>What is moving around in the system?</p><p>In a traditional messaging system, a single <strong>message</strong>, or a piece of data, is considered as payload. We can think of it as a drop of water.</p><p>In Kafka, a payload can be a <strong>stream</strong> or a continuous flow of data over the network. A good analogy would be a flow of water.</p><h4>Core (Queue vs Commit Log)</h4><p>What is the core idea behind each system?</p><p>A traditional messaging system leverages a <strong>queue</strong> to deal with incoming and outgoing messages. Messages are kept in the queue until they are processed by consumers. Each message is processed only once by a single consumer.</p><p>At its core, Kafka is a big<strong> distributed and replicated</strong> <strong>commit log</strong>. It is worth noting that the log here has nothing to do with an application log. Instead, it is similar to a transaction log maintained by DBMS. A commit log is actually an <strong>append-only, totally-ordered (typically by time) data structure</strong>. Once messages are written to the log, they cannot be modified nor deleted by consumers. This log is important because it records the entire history of what happened to the system and when.</p><h4>Read Receipt (Acknowledgement Message vs Cursor)</h4><p>How does a message broker know if a message is successfully delivered and read by a consumer?</p><p>In a traditional messaging system, once a consumer successfully receives a message, it will send an <strong>acknowledgment message</strong> to the broker.</p><p>In Kafka, a consumer does not need to send anything to the broker. Instead, the consumer is responsible for keeping track of a <strong>cursor</strong> of its last processed message position. This also allows going back in time to query old messages and giving full ability to read the complete history.</p><h4>Delivery Mechanism (One vs Many)</h4><p>How is a message delivered?</p><p>A broker in a traditional messaging system can only deliver a message to only <strong>one consumer</strong>.</p><p>A Kafka broker can send a message to <strong>all consumers</strong>.</p><h4>Durability (In-Memory vs Disk)</h4><p>Messages in both systems are durable to ensure consumers can read unprocessed messages after they restart from unexpected server shutdown. However, because messages are stored differently, data retention time is different as well.</p><p>In a traditional messaging system, messages are stored <strong>in memory</strong> and they are deleted from the queue upon successful delivery.</p><p>In Kafka, messages are persisted in <strong>disk</strong> for a configurable amount of time. They can be kept forever if wanted.</p><h3>Conclusion</h3><p>As a microservice-oriented and event-driven software architecture becomes increasingly more popular, a new technology to ensure reliable and scalable communication between services is needed. To solve this problem, the emergence of message brokers allows us to further decouple our architecture, removing dependencies between services, and improving scalability. Kafka, being one of the most popular distributed streaming platforms, can be used as a <strong>single source of truth</strong> for all of our application events.</p><p>I hope you enjoyed reading this article! If you like it and learned something new, give it some claps 👏👏👏 Really appreciated 🙏🙏🙏</p><h3>References</h3><p><a href="https://kafka.apache.org/intro">Apache Kafka</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F06iRM1Ghr1k%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D06iRM1Ghr1k&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F06iRM1Ghr1k%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/48b4777c71e5b1442b1b09e1e5a3e85d/href">https://medium.com/media/48b4777c71e5b1442b1b09e1e5a3e85d/href</a></iframe><p><a href="https://medium.com/swlh/understanding-kafka-a-distributed-streaming-platform-9a0360b99de8">Understanding Kafka — A Distributed Streaming Platform</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2355148dda0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Ultimate Guide to Local Development Setup]]></title>
            <link>https://zicodeng.medium.com/the-ultimate-guide-to-local-development-setup-fe0bf02b266c?source=rss-75421a2cc2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe0bf02b266c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[local-development]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Zico Deng]]></dc:creator>
            <pubDate>Wed, 19 Jun 2019 05:29:18 GMT</pubDate>
            <atom:updated>2022-08-07T17:02:03.006Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*ureg0w9ISlitYSrgym5uhQ.jpeg" /></figure><p>Every developer knows how crucial local development setup is. A good local development setup should make it super easy to run the app locally with just one or few commands, e.g. yarn start, but a bad one…</p><blockquote>The new guy: yo! I just joined the company. How can I run the app locally?</blockquote><blockquote>The lead: yoooo! check out our contributing guide!</blockquote><blockquote>The new guy: word!</blockquote><blockquote>After an hour…</blockquote><blockquote>The new guy: WTF! Am I reading a contributing guide or an academic paper with 2000+ word count. I need to download xxx first, then xxx, and then xxx…</blockquote><blockquote>After three hours…</blockquote><blockquote>The new guy: finally, got everything installed and set up. Let me try running the app…</blockquote><blockquote>The coolest app: invalid ELF header :(</blockquote><blockquote>The new guy: Wut! I just did exactly what the contributing guide told me to do. Damn, already 5pm, time to go home.</blockquote><p>You got the story, and unfortunately, it happens very frequently.</p><p>In this post, I will walk you through three different levels of local development setups, from newbie to journeyman, and finally expert.</p><h3>The Newbie Setup</h3><h4>Manually link external stylesheets and scripts in HTML</h4><p>Wut? what do you mean by setting up local development? Why can’t we just link external stylesheets and scripts in HTML by using &lt;link&gt; and &lt;script&gt; tags? Uhm…this is totally valid approach. However, there are a few problems:</p><ul><li>How would you manage hundreds of dependencies? A simple application might only have a few dependencies, but a complicated one can have hundreds. Would you still want to manually link them one by one in HTML?</li><li>How would you control dependency orders? Dependency orders matter for both JavaScript modules and CSS stylesheets. You wouldn’t want to encounter undefined variables or styles being overridden unexpectedly.</li><li>How would you test new changes in the browser? With this approach, the only way to pick up new changes is by refreshing the entire page. What if your application is huge and reloading might take close to a minute?</li></ul><h3>The Journeyman Setup</h3><h4>Module bundlers</h4><p>Module bundlers can transform, bundle, or package modules with dependencies into static assets for browser usage.</p><p><a href="https://webpack.js.org/"><strong>Webpack</strong></a> is currently the most popular module bundler for building modern web applications. However, working with Webpack is not that straightforward. Some basic knowledge of configuration is often needed.</p><p>Below are some commonly used <strong>loaders</strong> for Webpack:</p><ul><li><a href="https://github.com/babel/babel-loader"><strong>babel-loader</strong></a>: transpiles advanced JavaScript syntax with <a href="https://babeljs.io/">Babel</a>.</li><li><a href="https://github.com/TypeStrong/ts-loader"><strong>ts-loader</strong></a>: transpiles TypeScript to JavaScript.</li><li><a href="https://github.com/webpack-contrib/sass-loader"><strong>sass-loader</strong></a>: compile SASS to CSS.</li><li><a href="https://github.com/postcss/postcss-loader"><strong>postcss-loader</strong></a>: processes CSS with PostCSS plugins.</li><li><a href="https://github.com/webpack-contrib/css-loader"><strong>css-loader</strong></a>: takes CSS files and generates JavaScript modules that exports our CSS code.</li><li><a href="https://github.com/webpack-contrib/style-loader"><strong>style-loader</strong></a>: takes output from css-loader and creates &lt;style&gt; tags for our CSS and injects them into HTML &lt;head&gt;. style-loader is often chained with css-loader and postcss-loader/sass-loader.</li><li><a href="https://github.com/webpack-contrib/file-loader"><strong>file-loader</strong></a>: allows us to import files such as images, videos, and fonts in JavaScript. It works by resolving a file import into a url and emitting the file into the output directory.</li><li><a href="https://github.com/webpack-contrib/thread-loader"><strong>thread-loader</strong></a>: runs expensive loaders in a separate process.</li><li><a href="https://github.com/webpack-contrib/cache-loader"><strong>cache-loader</strong></a>: caches result of expensive loaders on disk. Often used together with thread-loader, they can potentially improve Webpack build time if configured correctly.</li></ul><p>In addition to loaders, we also need to configure various Webpack <strong>plugins</strong>. Here are some commonly used ones:</p><ul><li><a href="https://github.com/jantimon/html-webpack-plugin"><strong>html-webpack-plugin</strong></a>: Even a newbie knows that to make our app show up in the browser, we have to link to external stylesheets and scripts with correct filenames in HTML. However, when we are working with loaders mentioned above, most of them output filenames with hashes. Who wants to manually inject those files with hashed names into HTML every time when Webpack rebuilds? Fortunately, we have html-webpack-plugin come to rescue. It smartly inserts those files for us when Webpack rebuilds.</li><li><a href="https://github.com/Realytics/fork-ts-checker-webpack-plugin"><strong>fork-ts-checker-webpack-plugin</strong></a>: runs TypeScript type checking on a separate process. Only useful when we are working with TypeScript loaders such as ts-loader. This plugin can potentially improve build time because TypeScript loaders are by default responsible for two things: type checking and transpiling TypeScript. However, by using this plugin, we can delegate type checking on a separate process so that TypeScript loaders now only need to focus on transpiling TypeScript to JavaScript.</li><li><a href="https://github.com/webpack-contrib/mini-css-extract-plugin"><strong>mini-css-extract-plugin</strong></a>: takes output of css-loader and extracts CSS into separate files. It is recommended to only use this plugin and loader for production. Use style-loader instead for development. (Note: this plugin only works with Webpack4).</li><li><a href="https://github.com/mrsteele/dotenv-webpack"><strong>dotenv-webpack</strong></a>: load environment variables from .env files into our application.</li><li><a href="https://github.com/jantimon/favicons-webpack-plugin"><strong>favicons-webpack-plugin</strong></a>: generates favicons for iOS, android devices and browsers for a given .png file.</li><li><a href="https://github.com/gregnb/filemanager-webpack-plugin"><strong>filemanager-webpack-plugin</strong></a>: process files before and after Webpack build.</li></ul><p>Webpack is not only for generating development bundles but for production bundles as well. Check out these <strong>plugins for optimization</strong>:</p><ul><li><a href="https://github.com/webpack-contrib/terser-webpack-plugin"><strong>terser-webpack-plugin</strong></a>: minifies JavaScript for production build</li><li><a href="https://github.com/NMFR/optimize-css-assets-webpack-plugin"><strong>optimize-css-assets-webpack-plugin</strong></a>: optimizes and minifies CSS for production build</li></ul><p>Oh…what it takes to become a journeyman is not as easy as expected. One last thing we need to know about Webpack is <a href="https://github.com/webpack/webpack-dev-server"><strong>webpack-dev-server</strong></a>. This library spins up a development server with <strong>live reloading</strong>! We are no longer newbies who only know manually refreshing the browser when source code changes.</p><h4>Linters</h4><p>A linter is a program that walks through our source code and <strong>checks potential programmatic and stylistic errors</strong>. It often consists of two categories of rules:</p><ul><li><strong>Formatting</strong> <strong>rules</strong>: concerns how consistent code style looks. E.g. limiting lines of code to 80 characters.</li><li><strong>Code quality rules</strong>: concerns how good code quality is written. These type of rules actually help us catch bugs. E.g. variables that are declared but not used are forbidden.</li></ul><p>Linters are usually language-specific:</p><ul><li><a href="https://eslint.org/"><strong>ESLint</strong></a>: linter for JavaScript.</li><li><a href="https://palantir.github.io/tslint/"><strong>TSLint</strong></a>: linter for TypeScript.</li><li><a href="https://github.com/stylelint/stylelint"><strong>Stylelint</strong></a>: linter for CSS.</li></ul><h4>Formatters</h4><p>A formater, as the name suggests, is a program that formats our source code in a consistent style. This especially useful when we are working with other programmers. Everyone has his or her own style writing code. For example, someone might prefer using space than tab. With formatters, we no longer need to argue with co-workers why they use space instead of tab. Formatters will make sure our code conforming to a consistent style.</p><p>Currently, the most popular formatter is <a href="https://prettier.io/"><strong>prettier</strong></a>. Check it out, and set it up correctly, your code will look amazing (just stylistically)!</p><h4>Enforcing linting and formatting source code before committing them to codebase</h4><p>Linters and formatters are great only if we use them. There are some cases when people forget to lint and format code, and bad code just sneaks into codebase :( Fortunately, we have tools that help us enforce linting and formatting before committing code.</p><ul><li><a href="https://github.com/typicode/husky"><strong>husky</strong></a>: allows us to easily create Git hooks. A git hook is just a script that will be executed by Git before and after events such as commit and push. In our case, we want to enforce running linters and formatters in pre-commit stage.</li><li><a href="https://github.com/okonet/lint-staged"><strong>lint-staged</strong></a>: setting up Git hooks with husky alone is not enough because after code is linted and formatted, the new changes will not be automatically added to Git stage. This is where lint-staged is needed. It allows us to run linters and formatters on staged files.</li></ul><h3>The Expert Setup</h3><h4>Docker</h4><p>Docker is a technology for running application software in isolated, secure, and reusable containers. Docker is not just for production. It can be extremely helpful for development as well.</p><p>If you recall the story in the intro section, the new guy encountered <strong>invalid ELF header</strong> error. This is usually caused by when a <strong>binary module</strong> is created on one OS (MacOS) but used on a different OS (Linux). Now we know the root cause of this error, but how can we avoid it? The solution it to create identical environment for testing, development, stage, and production across different machines. The old way to do this is to spin up a virtual machine (using <a href="https://www.vagrantup.com/">Vagrant</a> or <a href="https://www.virtualbox.org/">VirtualBox</a> for example), and it definitely works. But this is not the best solution. Why? because there is too much overhead for creating a virtual machine. Moreover, compared to VMs, containers are more portable, efficient, take less space, and can start almost instantly.</p><p>By running our application in an isolated container that has identical environment (e.g. Linux) across different machines, we can be confident that the app runs well on my machine should also run well on your machine.</p><h4>Modify default host database</h4><p>If we know our app will be served on example.com in production stage.example.com in stage, would it be great if we can test our app locally on dev.example.com instead of localhost? It is actually very easy to make this happen. Every computer keeps a default <strong>host database </strong>in /etc/hosts. Domain names and associated IP addresses in this database have the highest priority, meaning our computer will firstly look for answers in this file before DNS lookups during DNS resolution. With this knowledge in mind, we can customize entries in this database. For example, adding a new entry 127.0.0.1 dev.example.com will allow us to type dev.example.com in our browser, and it will resolve to 127.0.0.1, which has the same effect as typing localhost.</p><p>I hope after reading this post, you are on your way becoming a local development setup expert :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe0bf02b266c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Write Awesome Documentation for UI Components with Docz and Ztopia Theme!]]></title>
            <link>https://zicodeng.medium.com/write-awesome-documentation-for-ui-components-with-docz-and-ztopia-theme-dcc8acb36abb?source=rss-75421a2cc2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcc8acb36abb</guid>
            <category><![CDATA[ui-component]]></category>
            <category><![CDATA[documentation]]></category>
            <category><![CDATA[docz]]></category>
            <category><![CDATA[storybook]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[Zico Deng]]></dc:creator>
            <pubDate>Wed, 12 Jun 2019 06:04:06 GMT</pubDate>
            <atom:updated>2022-08-07T16:58:51.738Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*NulPEsO0KZYst47Xq6ucTQ.gif" /><figcaption><a href="http://docz-theme-ztopia.surge.sh/">http://docz-theme-ztopia.surge.sh/</a></figcaption></figure><h3><strong>Why Docz?</strong></h3><p><em>It’s never been easier to document your things!</em></p><p>Let’s all admit the fact that most engineers do not like writing documentation, needless to say writing awesome documentation. We cannot really blame on them for being lazy nor too smart to write some dummy text instead of code. Given the fact that engineers are always too busy with rushing projects to production, fixing regression bugs, arguing with coworkers, it is vital to have a documentation tool that requires no additional effort and time to write awesome documentation. <a href="https://www.docz.site/">Docz</a> is by far my favorite UI documentation tool that makes me as a writer efficient and you as a reader happy</p><p>You might be wondering: how is Docz better than <a href="https://storybook.js.org/">Storybook</a>? Don’t get me wrong. Storybook can surely be a powerful UI documentation tool as well, only if your team members and you know how to configure and use it properly. See, this is the biggest difference between Docz and Storybook: engineers firstly need to learn how to configure and use Storybook properly before they can write awesome documentation, whereas Docz fully leverages <a href="https://mdxjs.com/">MDX</a>, allowing us to directly import UI components in markdown, making the documenting experience truly great. Personally, I feel like writing documentation with Storybook is more like writing JavaScript tests, whereas writing documentation with Docz is more like writing kindergarten journals</p><p>Secret, don’t tell anyone else: the company I am working for moved away from Storybook to Docz!</p><h3><strong>Why Ztopia Theme?</strong></h3><p>For a long time, Docz has been lonely with just one look, <a href="https://github.com/pedronauck/docz/tree/master/core/docz-theme-default">the default theme</a>. Now, let’s embrace its new look with the Ztopia theme! Well, creating a new look is just one of many reasons I want to start this project. Below are more reasons why you should switch to the <a href="http://docz-theme-ztopia.surge.sh/">Ztopia theme</a>:</p><h4><strong>Aesthetically pleasing design</strong></h4><p>Inspired by <a href="https://ant.design/docs/react/introduce">Ant Design React</a> and <a href="https://material-ui.com/">Material UI</a>, 40% of my time was devoted to the Ztopia UI&amp;UX when I built this theme. Why? because I believe great UI&amp;UX can attract people reading documentation :)</p><h4><strong>One theme, two looks</strong></h4><p>Ztopia theme comes with light and dark mode. You can click the light bulb in top right corner to see the difference. If your component also supports light and dark theme, you can import ThemeConsumer from this library, and use it to theme your components. See <a href="https://github.com/zicodeng/docz-theme-ztopia/blob/master/example/Button.mdx">Button.mdx</a> for an example</p><h4><strong>Gracefully handle complex prop shape</strong></h4><p>It is common to have component props that accept complex shapes. Inlining them as plain text like this PropTypes.shape({ firstName: PropTypes.string.isRequired, lastName: PropTypes.string.isRequired}) is probably not a best way to show. Fortunately, Ztopia handles complex shapes automatically for you.Whenever you see Shape type in props table, it means you can hover it and see your complex shape. Check out examples in <a href="http://docz-theme-ztopia.surge.sh/docs/design">Design </a>page</p><h4><strong>Description with inline code</strong></h4><p>When you write descriptions for props, you can embed inline code like this /** This is `code` */</p><h4><strong>Playground with built-in iframe support</strong></h4><p>The default Docz &lt;Playground&gt; is really cool, but it does not serve your components in an <strong>isolated browsing context</strong>. This makes developers hard to test component responsiveness and lead to possible CSS collisions between Docz default theme style and component style. There is a <a href="https://github.com/pedronauck/docz/issues/789">GitHub issue</a> discussing about it. With the above reasons in mind, Ztopia theme &lt;Playground&gt; is built with &lt;iframe&gt; support in mind, so that you can build your components in isolation. See <a href="http://docz-theme-ztopia.surge.sh/components/button">Button</a> page for an example. (If you are not thinking about switching to Ztopia theme, but still need &lt;iframe&gt; Playground support, check out this <a href="https://github.com/zicodeng/docz-iframe-playground">plugin</a> I wrote)</p><h4><strong>Live editing, preview, and error</strong></h4><p>Turn on the editor mode and tweak your components on the fly</p><h3><strong>Star Ztopia Theme on GitHub</strong></h3><p>This project is completely open source and free of charge. If you like it, <a href="https://github.com/zicodeng/docz-theme-ztopia"><strong>star Ztopia theme</strong></a> on GitHub. Your support is my biggest motivation :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcc8acb36abb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How VPN Works?]]></title>
            <link>https://zicodeng.medium.com/how-vpn-works-b7549dcc6ce4?source=rss-75421a2cc2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7549dcc6ce4</guid>
            <category><![CDATA[internet]]></category>
            <category><![CDATA[vpn]]></category>
            <category><![CDATA[computer-networking]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Zico Deng]]></dc:creator>
            <pubDate>Sat, 08 Sep 2018 00:56:25 GMT</pubDate>
            <atom:updated>2021-05-20T23:13:58.337Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Before delving into the topic, I want to say a huge thanks to <a href="https://www.linkedin.com/in/cbuechler/"><strong>Chris Buechler</strong></a> (co-founder of pfSense and current principal engineer at Ubiquiti Networks) and <a href="https://www.linkedin.com/in/clintonjcampbell/"><strong>Clinton Campbell</strong></a> (guest lecturer at University of Washington) for helping me improve the quality and accuracy of this post.</blockquote><p>Almost every internet user has heard of or somehow used VPN before. We can use VPN for hiding our IP address so that we can surf the internet pseudo-anonymously (it is not entirely anonymous because your VPN provider still knows about you, but your ISP does not. After all, how can you be truly anonymous if you are on the internet?). We can also use VPN for protecting our web traffic from government censorship so that we can access any website even in certain restricted regions. For company employees, they can use VPN for safely sharing private data in remote locations through the public network. The benefits of using VPN to surf the internet are numerous and amazing. However, there are also two noticeable downsides. Once we connect to VPN server, our internet speed and bandwidth are directly affected by the physical location and capability of the server. Another downside is that big-name VPN providers tend to attract all kinds of bad actors. If those people perform something bad with the IP address provided by the VPN service (such as insulting someone on Reddit), this IP address will be blacklisted by the Reddit server. When we, the good actors, connect to this IP address and try to post something on Reddit, we simply got blacklisted as well.</p><p>In most cases, we just need to download software and a VPN connection is magically established. What is VPN really? How does it really work? Why is it so secure? Is it perfectly secure? In this post, I will try to answers those questions, and hopefully you, as VPN users, can gain a more basic understanding of the service you have been using.</p><h4>What is VPN?</h4><p>VPN stands for Virtual Private Network. To better understand this concept, we can divide this terminology into two parts: virtual and private network. Virtual means not physically existing, but made by software to appear so. A private network is the opposite of a public network. Specifically speaking, a private network is a non-routable network that mostly consumes a private IP address (it does not have to be a private IP address, but this is the most common circumstance due to IPv4 scarcity) and thus cannot be reached on the internet. It is generally much more secure than a public network because a private network typically restricts connections to certain groups of people such as company employees, and data transferred on the private network cannot be easily snooped by hackers sitting on the public network. So together virtual private network is a technology that allows devices on the public network to securely connect to devices on a private network. Data is actually still transferred on a public network, but the technology makes the connection so secure as if the data is transferred on a private network.</p><h4>Different Types of VPN</h4><p>Generally speaking, we can categorize VPN into two types based on how the connection is established.</p><p><strong><em>Remote Access VPN</em></strong></p><p>Remote access VPN is established when a single device connects to a remote network. This is probably the case for most VPN home users. We download VPN software on our smartphones or computers, log in with our credentials, and select a VPN server to connect. Remote access VPN can also benefit company employees who need access to company resources when working at home.</p><p><strong><em>Site-To-Site VPN</em></strong></p><p>Site-to-site VPN is common for companies that have offices in different geographical locations. It connects a network of one office to a network of another, which allows two different offices to share private resources securely over the internet. Site-to-site VPN largely differentiates itself from remote access VPN in that it creates a private link between two different networks instead of a single device and a network.</p><h4><strong>Different Types of VPN Protocols</strong></h4><p>The history of VPN protocols can be traced back to 1996 when a Microsoft software engineer named Gurdeep Singh-Pall invented PPTP (Point-to-Point Tunneling Protocol). As people are becoming more and more concerned with their online privacy and security, a number of VPN protocols are recently devised. In this post, I will focus on VPN protocols that are recently created and widely used today.</p><p>To create a secure VPN connection, generally speaking, there are three components that need to be considered: key exchange, tunneling, and encryption. Some protocols only take care of one component. Some protocols take care of two or more. So the actual implementation of VPN might require multiple protocols to ensure the connection is secured.</p><p><strong><em>IPsec (Internet Protocol Security)</em></strong></p><p>IPsec is an extension of IP (Internet Protocol) and is comprised of multiple protocols. It secures VPN connection by ensuring data confidentiality and integrity. Data traveling across the internet is confidential because the content is encrypted and turned to ciphertext. If a packet is snooped by hackers in the middle, all they can see is a bunch of gibberish rather than the actual content. Integrity ensures no packet can be manipulated by unauthorized parties during the transmission. This is achieved by hashing original data on the sender side and re-hashing received data and comparing results with the received hash on the recipient side. IPsec also provides authentication between two different hosts (e.g. VPN client and server) by requiring them to prove their identity first. Before communication happens, two hosts must establish a SA (Security Association) which is negotiated by IKE (Internet Key Exchange) protocol. Host computers will then modify every packet sent to each other based on SA parameters. IPSec comes with two modes: transport mode only secures packet payload by encrypting content; tunnel mode encapsulates the entire packet in a new packet.</p><p><strong><em>IKE (Internet Key Exchange)</em></strong></p><p>IKE protocol is typically used in conjunction with IPsec to produce a symmetrical key known as shared secret (Diffie-Hellman key) for two communicating parties (VPN client and server). The key will be used to encrypt and decrypt packets. The outcome of an IKE negotiation is SA (Security Association) which defines a number of parameters for securing network traffic.</p><p><strong><em>L2TP (Layer 2 Tunneling protocol)</em></strong></p><p>The main purpose of L2TP is to tunnel private data traveling across the untrusted public network by encapsulating a packet inside another packet. The source and destination IP addresses are often modified during the process of encapsulation. The packet appears to the public as a normal packet, but it actually carries a private and sensitive payload. However, the protocol itself does not provide any encryption mechanism. Therefore, it is often used in conjunction with IPsec to provide VPN security.</p><p><strong><em>SSL/TLS (Secure Socket Layer/Transport Layer Security)</em></strong></p><p>We have all viewed websites that are protected by SSL/TLS. We can verify a trusted website if the connection is HTTPS, and it has a green and secure icon on the left of the browser address bar. SSL/TLS is an encryption protocol that guarantees data confidentiality. In the OSI model, SSL/TLS takes place at the application layer (some people also say it takes place at the session layer). It protects the connection between a web browser and a web server. Unlike IPsec VPN, SSL/TLS VPN does not require users to install specialized client-side VPN software because most web browsers nowadays support SSL/TLS by default.</p><h4><strong>How Does VPN Work?</strong></h4><p>To better understand how VPN really works, I have drawn diagrams to show the life of an IP packet with and without VPN.</p><p><strong><em>What is an IP Packet?</em></strong></p><p>To understand IP packet, we need to talk about PDU (Protocol Data Unit) first. PDU is a unit of data specified in the protocol of a given OSI layer. It is a relevant concept in terms of OSI layers. In layer 3 (network layer), PDU is often called packet, but in layer 2 (data link layer), it is called frame. Generally speaking, any data such as files and images is broken down into smaller chunks called packets during transmission. This ensures efficiency for routing because each individual packet can travel different routes to reach a designated destination.</p><p><strong><em>Life of an IP Packet Without VPN</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BzqVizrr5ZiL90ho" /><figcaption>Life of an IP Packet Without VPN</figcaption></figure><p><strong><em>Step 1</em></strong>: the user opens the webpage whatismyipaddress.com and sends a request to the whatismyipaddress.com server. The packet is initiated from the user’s PC so the packet has source IP address 10.19.190.132, which is the private IP address of the user’s PC (assuming the router is using DHCP to assign private IP address 10.19.190.132 to the user’s PC). Because this request is sent to the whatismyipaddress.com server. So the packet has destination address 128.95.120.1 (assuming whatismyipaddress.com DNS record is cached locally in the user’s PC).</p><p><strong><em>Step 2</em></strong>: when the packet from the user’s PC arrives at the router, the router modifies the packet’s source IP address and replaces it with its own public address 205.175.106.121 before it sends out the packet (sometimes source port is also modified in case of one-to-many relationship). How does the router know which connected devices this packet belongs to if its source IP address and port are changed? The answer is NAT (Network Address Translation) protocol. The router will keep a NAT forwarding table that maps IP addresses on an internal network to IP addresses to an external network. For the case in the diagram, the router might generate a record like this (simplified version):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NUwKoLCRM7UE5Fz-JwJj3g.png" /><figcaption>NAT Forwarding Table</figcaption></figure><p>When a packet with the destination IP address 205.175.106.121 and port 1234 arrives at the router from another router, the router will look up the NAT forwarding table, and forwards that packet to the connected device with private IP address 10.19.190.132, which is the user’s PC. It is also important to know that on this step packet actually gets routed to ISP directly without going through any other routers (this can be verified by using the traceroute command). Our connection to the internet strictly speaking starts at our ISP. In another word, we reach the world internet through ISP.</p><p><strong><em>Step 3</em></strong>: the diagram simplifies the journey of the packet from ISP to the whatismyipaddress.com server. In reality, the packet usually needs to go through multiple routers to reach the server. The trip from one router to another is called a hop. So the packet needs to take multiple hops. There might be millions of routers between ISP and whatismyipaddress.com server, which means there might be millions of paths for the packet to take. How does a router know which path is the fastest? The answer is a routing table. It is typically stored in a router and contains rules for determining the best route.</p><p><strong><em>Step 4</em></strong>: this step is very similar to step 3 but in the opposite direction. The source and destination IP addresses are switched, and the packet contains payload sent from the whatismyipaddress.com server.</p><p><strong><em>Step 5</em></strong>: ISP sends the packet directly to our home router.</p><p><strong><em>Step 6</em></strong>: when the packet from ISP reaches its destination, the user’s home router, the router will look up the NAT table to forward this packet to a correct connected device (the user’s PC). The packet is modified again. But this time, the destination IP address is replaced with the private IP address of the user’s PC 10.19.190.132 based on the record found in the NAT table. the packet gets forwarded correctly to the user’s PC based on the modified destination address in step 5.</p><p>The diagram above illustrates the life of an IP packet without VPN. It explains why whatismyipaddress.com shows an address that is different from our PC’s address because the address displayed on whatismyipaddress.com is actually the router’s public address rather than our PC’s private address. The diagram also exposes vulnerabilities of the internet such as privacy and security. If a man in the middle intercepts our packet in any step, the hacker would know where this packet comes from and what payload it contains (if we are not viewing the HTTPS website). This is where VPN comes to the rescue.</p><p><strong><em>Life of an IP Packet With VPN</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X9ylouL2AO0E3VZb" /><figcaption><em>Life of an IP Packet With VPN</em></figcaption></figure><p><strong><em>Step 1</em></strong>: if the user’s computer has client-side VPN software installed, the packet will be encapsulated first. Encapsulation is really just a process of wrapping the original packet inside another packet created by client-side VPN software. Everything in the original packet is encrypted by a VPN client and can only be read by a VPN server. To the public, this is still a valid packet and will be routed as normal. Noted that the destination address becomes the VPN server’s IP address 206.189.234.44.</p><p><strong><em>Step 2</em></strong>: this step is very similar to step 2 in the case without VPN. Source IP address is replaced with the router’s public IP address and NAT record is generated to keep track of the associations.</p><p><strong><em>Step 3</em></strong>: ISP is responsible for sending this packet to the designated destination: the VPN server. Best routes will be dynamically selected based on routing protocols and routing tables.</p><p><strong><em>Step 4</em></strong>: once the VPN server receives the packet, it unwraps the outer packet and then uses its symmetrical key to decrypt the content of the inner packet (original packet). Next, the VPN server sends the packet to where it is destined: whatismyipaddress.com server.</p><p><strong><em>Step 5</em></strong>: this step is the same as step 4 in the case without VPN.</p><p><strong><em>Step 6</em></strong>: the VPN server encrypts the packet payload and encapsulates the packet before sending it out.</p><p><strong><em>Step 7</em></strong>: this step is the same as step 5 in the case without VPN.</p><p><strong><em>Step 8</em></strong>: this step is very similar to step 6 in the case without VPN. Once the user’s computer receives this packet, the client-side VPN software will unwrap it first and then decrypt the inner packet with its symmetrical key.</p><p>The diagram above illustrates the life of an IP packet with VPN. As we can tell from the diagram, VPN adds two important security factors: packet encapsulation and encryption. Most of the time, the original packet is hidden due to encapsulation. If we visit whatismyipaddress.com with VPN, it would show 206.189.234.44 (IP address of the VPN server) rather than 205.175.106.201 (IP address of the router). This the reason why VPN allows users to surf the internet anonymously. VPN also helps us bypass government censorship on certain websites because it hides our packets’ intended destination address and replaces it with our VPN server’s IP address. For example, our ISP could prohibit us from visiting whatismyipaddress.com by dropping all traffic that has destination address 128.95.120.1 (IP address of whatismyipaddress.com server). If we have a VPN on, we would still be able to visit the website because our ISP would never see our traffic with destination address 128.95.120.1 (IP address of whatismyipaddress.com server). Instead, it sees 206.189.234.44 (IP address of the VPN server). Therefore, our traffic will not be blocked by ISP. Furthermore, VPN dramatically enhances our online security. If our packets are intercepted at step 1, 2, 3, 6, 7, or 8, the hackers would not be able to read our privacy information because they could not unwrap the packets. Even if they do manage to penetrate the VPN tunnel, unwrap the outer packets, and access the original packets, all they would see is a bunch of gibberish because they do not have the keys to decrypt the content.</p><h4>Is VPN Perfectly Secure?</h4><p>If we pay for VPN service, does it mean we will never be vulnerable to malicious attacks? Well, the answer is that nothing is perfect. Depending on how VPN is set up, the level of security might be different. The diagram above demonstrates remote access VPN. Although it helps us hide our identities, bypass government censorships, and protect our traffic from most malicious attacks, this type of VPN setup still has some security flaws. For example, hackers can still intercept our packets at step 4 or 5 in the diagram. Traffic traveling between the VPN server and whatismyipaddress.com server is actually not protected by VPN, and thus IP packets are not encapsulated and encrypted. If we are online shopping at a non-secure website (websites that use normal HTTP connections are generally considered as non-secure and highly vulnerable to malicious attacks such as snooping/interception), hackers can still intercept our traffic and illegally obtain our credentials and personal information. Therefore, it is not recommended to share our personal information with non-secure websites even if we are using VPN. The last point I want to make might sound a little bit scary. Shopping at an HTTPS website only means we are connecting to a legitimate server that owns the associated certificate, however, there is no way for us to know what the server is going to do with our payment information. It may send it to a third-party payment processing company via an unprotected connection. Who knows?</p><h4>References</h4><p>“A Brief History of VPNs | Golden Frog.” <em>Golden Frog Blog</em>, 22 June 2016, <a href="http://www.goldenfrog.com/blog/brief-history-of-vpns.">www.goldenfrog.com/blog/brief-history-of-vpns.</a></p><p>Eaton, Nick. “Should Microsoft Have Patented Its VPN in the ‘90s?” <em>The Microsoft Blog</em>, 13 Mar. 2010, blog.seattlepi.com/microsoft/2010/03/13/should-microsoft-have-patented-its-vpn-in-the-90s/.</p><p>“IPsec &amp; IKE.” <em>Configuring Remote Access VPN</em>, sc1.checkpoint.com/documents/R77/CP_R77_VPN_AdminGuide/13847.htm.</p><p>“What Is Internet Key Exchange (IKE)? — Definition from WhatIs.com.” <em>SearchSecurity</em>, searchsecurity.techtarget.com/definition/Internet-Key-Exchange.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7549dcc6ce4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Explore the Magic Behind Google Chrome]]></title>
            <link>https://zicodeng.medium.com/explore-the-magic-behind-google-chrome-c3563dbd2739?source=rss-75421a2cc2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3563dbd2739</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[web-browser]]></category>
            <category><![CDATA[architectural-design]]></category>
            <category><![CDATA[google-chrome]]></category>
            <category><![CDATA[chromium]]></category>
            <dc:creator><![CDATA[Zico Deng]]></dc:creator>
            <pubDate>Wed, 21 Mar 2018 05:54:17 GMT</pubDate>
            <atom:updated>2018-03-21T05:59:42.809Z</atom:updated>
            <content:encoded><![CDATA[<p>Web browser has been regarded as the most popular software to users and an indispensable part of a modern computer. <a href="http://gs.statcounter.com/browser-market-share">Around 60% of people in the world use Google Chrome in their daily life</a>. Chrome is a proprietary software largely based on <strong>Chromium</strong>, which is an <strong>open source</strong> software developed and maintained by <strong>The Chromium Project</strong>. The primary goal of this project is to build a <strong>faster, safer, more stable</strong> <strong>browser engine</strong> for better internet surfing experience. This post attempts to analyze architectural styles of Chromium and explore the magic behind this popular web browser.</p><p>Back in the old days, if the user accidentally opens a misbehaving web page, the browser will crash the tab that contains this web page. A crash in tab will often lead to crash to the entire browser. That means the user has to re-open the browser again and all of the previously opened tabs are lost. This is considered as bad user experience. To solve this kind of issue, Chromium now adopts what is known as <strong>multi-process architecture</strong>. The diagram below shows the high level architectural overview of Chromium.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ABs1VRduCJs4rZ_p." /><figcaption><a href="https://www.figma.com/file/KBTjp1Xe9ejFHChmq1El31zf/Chromium-Architecture">Chromium Multi-Process Architectural Overview</a></figcaption></figure><p>There are two primary types of processes in Chromium multi-process architecture : <strong>the</strong> <strong>browser process</strong> and <strong>the render process</strong>. Generally speaking, there can be only one browser process and multiple render processes. I will give them more detailed discussions below.</p><h3><strong>The Browser Process</strong></h3><h4><strong>What is the browser process?</strong></h4><p>The Browser process is also known as <strong>the browser</strong> for short (this is not the same idea as the Browser we generally speak of, which refers to an program on your computer that allows to interact with information from internet). This process is mainly responsible for <strong>managing all render processes and displaying UI</strong>.</p><h4><strong>What are in the browser process?</strong></h4><p>The browser process maintains two threads: <strong>main/UI thread</strong> and <strong>I/O thread</strong>. Main/UI thread is largely responsible for rendering web pages on screen. I/O thread takes care of IPC communication between the browser process and render processes, and any network communication is also handled in this thread. Each thread runs several different objects. In the section below, I will explain details of all major objects categorized by the thread they belong to.</p><h4><strong>Objects in the main/UI thread</strong></h4><p><strong>RenderProcessHost</strong>: the browser process might have more than one RenderProcessHost. Each one connects to a render process with one-to-one relationship. The primary responsibility of RenderProcessHost is to dispatch view-specific messages to RenderViewHost and digest the rest non-view-specific messages. This object is also needed to uniquely identify a RenderView along with a RenderView Id because a render process might have more than one RenderView and the Id is only unique inside a render process but not within the browser process.</p><p><strong>RenderViewHost</strong>: as I mentioned above, RenderViewHost receives view-specific messages from RenderProcessHost. The relationship between RenderProcessHost and RenderViewHost is one-to-many because a render process might generate more than one RenderView (e.g. a web page and a popup in the same tab) and RenderProcessHost needs to pass that information to corresponding RenderViewHost. This object is responsible for navigational commands, receiving input events, and painting web pages.</p><p><strong>WebContents</strong>: this object represents a tab with a web page in it. It is responsible for displaying a web page in a rectangular view.</p><p><strong>Browser</strong>: this object represents a browser window and might contain multiple WebContents.</p><h4><strong>Objects in the I/O thread</strong></h4><p><strong>Channel</strong>: this object defines methods for communicating across pipes. Its main responsibility is to communicate with render processes over IPC.</p><p><strong>ResourceDispatcherHost</strong>: this object is responsible for sending network request to the internet. It acts as a gate to the internet. If a render process wants to send a request to the wild, it needs to send this request to RenderProcessHost first. Then RenderProcessHost forwards this request to ResourceDispatcherHost to actually send the request.</p><h3><strong>The Render Process</strong></h3><h4><strong>What is the render process?</strong></h4><p>The render process is also known as <strong>the renderer</strong> for short. This process maintains two thread: main thread and render thread, and is <strong>responsible for constructing a web page</strong>.</p><h4><strong>What are in the render process?</strong></h4><p>The render process maintains two threads: <strong>main thread</strong> and <strong>render thread</strong>. Main thread has only one object RenderProcess whose solely responsibility is to facilitate cross-thread communication between render thread in which RenderView lives and I/O thread of the browser process. Render thread, on the other hand, takes care of generating web pages. In the section below, I will illustrate major objects in the render process.</p><h4>Objects in the main thread</h4><p><strong>RenderProcess</strong>: as I mentioned above, RenderProcess is mainly used for facilitating cross-thread communication.</p><h4>Objects in the render thread</h4><p><strong>ResourceDispatcher</strong>: sometimes a web page needs to make request to server to fetch content. The render process does not have access to the internet. It has to rely on ResourceDispatcher to forward a request to the browser via IPC.</p><p><strong>Webkit</strong>: this is the rendering engine used in Chromium. It is used for constructing DOM and laying out web pages. Webkit consists of two primary components: WebCore which contains core layout functionality and JavaScriptCore where JavaScript interpreter V8 lives.</p><h3><strong>Components Communication</strong></h3><p>So far, I have discussed some major components in Chromium Architecture. In this section, I am going to to briefly talk about major connectors or communication pathways in the system.</p><p><strong>IPC</strong>: the communication between the browser process and multiple render processes is via<strong> inter-process communication</strong>, which is based on the asynchronous named pipe created for each render process. The pipe serves as a communication bridge for passing messages between Channel in the browser and RenderProcess in the renderer. Because the communication is often bidirectional, the provided and required interfaces can be both IPC Listener interface. This kind of communication is achieved through <strong>implicit invocation</strong> because messages are sent to the system, and the system will invoke appropriate function on another component.</p><p><strong>ChannelProxy</strong>: messages from and to the render process is not communicating directly on the main/UI thread of the browser process. Instead, it delegates the work to ChannelProxy which sits on I/O thread. This is because Channels are not thread safe. The ChannelProxy provides safety for the cross-thread communication between main/UI thread and I/O thread when sending and receiving messages. This ChannelProxy also has a MessageFilter that intercepts any resource requests (e.g. network requests) and forward them directly to the ResourceDispatcherHost. With this ChannelProxy, all of the performance critical messages are handled entirely on I/O thread and thus will not have any negative impact on main/UI thread of the browser process.</p><p><strong>LPC</strong>: local procedure call is probably the most used connectors in the Chromium multi-process architecture. A number of components communicate via LPC. For example, Browser stores references to many WebContents which stores references to many RenderViewHost, when a function is invoked in the Browser, it sends messages to all of its referenced components by invoking functions on them. The provided and required interfaces are often parameters and arguments on a specific invoked function.</p><h3><strong>Information Flow</strong></h3><p>How does information flow move through various components and connectors? To answer this question, I am going to take a life of a “mouse click” message from Chromium official documentation as an example. When a mouse click event is received by main/UI thread of the browser process, it sends to RenderViewHost, which in turn tells RenderProcessHost to send the message to ChannelProxy. Then, ChannelProxy will proxy the message to I/O thread of the browser process and send it to the render process via IPC pipe. In the render process, the message is received by RenderView, which in turns hand this message to WebKit. Finally, WebKit JavaScriptCore will trigger appropriate callback function that handles this mouse click event.</p><h3><strong>Architecture Analysis</strong></h3><h4><strong>What dominant architectural style does the multi-process architecture employ?</strong></h4><p><strong>Client-Server Architecture</strong>:<strong> </strong>If we zoom out and look at the overall multi-process architecture from a higher level perspective, it primarily consists of one browser process and many render processes. The browser process can communicate to render processes via IPC, but there is no communication between render processes. The browser process does not really care about details of a render process as long as it follows certain requirements. These are core characteristics in client-server architecture. The server is the browser process; the clients are the render processes; the connector is IPC instead of HTTP.</p><p><strong>Layered Architecture</strong>:<strong> </strong>From the perspective of how a web page is generated, the multi-process architecture can also fit to layered architecture. The architecture can be roughly divided into 7 application layers: WebKit, RenderView, RenderProcess, RenderProcessHost, RenderViewHost, WebContents, and Browser (bottom-to-up order). Each layer has its own responsibility. Layers do not have knowledge or dependent on any higher-level layers.</p><h4><strong>What qualities or attributes does the </strong>multi-process architecture<strong> engender?</strong></h4><p>With multi-process architecture, each render process is sandboxed and thus has restricted access to system resources. If a render process wants to make a network request, it has to communicate with the browser process first. This sandbox technique engenders better <strong>security</strong> because even if a render process is compromised, it limits the damage that attackers can cause to the operating system. Sandboxing each render process also results in better <strong>stability</strong> because a crash in one render process (tab) will not have any impact on other render processes (tabs). Because multi-process architecture is client-server like from a high level perspective, it also engenders qualities of client-server architecture such as <strong>scalability</strong>, and <strong>maintainability</strong>.</p><h4><strong>How does the </strong>multi-process architecture<strong> impact the ability to modify the software?</strong></h4><p>The most noticeable benefit of multi-process architecture is the ability to modify the entire software easily. This is partially resulted from the client-server architecture where the render process represents the client and the browser process represents the server. More importantly, it is the event-driven system that largely contributes to the modifiability. The browser process and the render process communicate via IPC. Specifically speaking, components involved in this communication are equipped with the IPC Channel Listener interface. This decouples sender component from listener component because they do not need to know the existence of each other. The sender component can just broadcast the message to the system. The message bus will then hand it to any components who are interested in this message. With this event-driven system, we can easily add or remove render processes.</p><h3><strong>References</strong></h3><p>Chromium multi-process architectural overview: <a href="https://www.figma.com/file/KBTjp1Xe9ejFHChmq1El31zf/Chromium-Architecture">https://www.figma.com/file/KBTjp1Xe9ejFHChmq1El31zf/Chromium-Architecture</a></p><p>“Browser Market Share Worldwide.” <em>StatCounter Global Stats</em>,</p><p><a href="http://gs.statcounter.com/browser-market-share">http://gs.statcounter.com/browser-market-share</a>.</p><p>“The Chromium Projects.” <em>The Chromium Projects</em>, <a href="http://www.chromium.org/">www.chromium.org/</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3563dbd2739" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>