Wednesday, March 23, 2022

System design interview links - Go through one by one quickly in two weeks

 

System design interviews

In system design interviews, you are usually given a very vague design problem (like design Twitter), and you need to share your approach in about 45 minutes. The purpose of this interview is to test your experience working with real software systems, and how much you know about these systems in general. Usually, interns and new grads don't get this type of interviews, but otherwise you may expect it at every big tech company.

Here is a list of material you absolutely need to check:

Here are some videos that I found helpful:

I think one of the best ways to prepare for system design interviews is to expose yourself to as much information about designs of the real systems as possible, so here are lots of links to the blog posts, articles, videos and papers I found useful:

Pragmatic System Design

March 23, 2022

Here is the link.  


Youtube channel: Cloud With Raj

March 23, 2022

Udemy - system design course using AWS 


Educative.io: Web Application and Software Architecture 101

March 23, 2022

Here is the link.


Round-robin DNS

 From Wikipedia, the free encyclopedia

Jump to navigationJump to search

Round-robin DNS is a technique of load distribution, load balancing, or fault-tolerance provisioning multiple, redundant Internet Protocol service hosts, e.g., Web server, FTP servers, by managing the Domain Name System's (DNS) responses to address requests from client computers according to an appropriate statistical model.[1]

In its simplest implementation, round-robin DNS works by responding to DNS requests not only with a single potential IP address, but with a list of potential IP addresses corresponding to several servers that host identical services.[2][3] The order in which IP addresses from the list are returned is the basis for the term round robin. With each DNS response, the IP address sequence in the list is permuted.[4] Traditionally, IP clients initially attempt connections with the first address returned from a DNS query,[5] so that on different connection attempts, clients would receive service from different providers, thus distributing the overall load among servers.

Some resolvers attempt to re-order the list to give priority to numerically "closer" networks. This behaviour was standardized during the definition of IPv6, and has been blamed for defeating round-robin load-balancing.[6][7][8] Some desktop clients do try alternate addresses after a connection timeout of up to 30 seconds.[2]

Round-robin DNS is often used to load balance requests among a number of Web servers. For example, a company has one domain name and three identical copies of the same web site residing on three servers with three IP addresses. The DNS server will be set up so that domain name has multiple A records, one for each IP address. When one user accesses the home page it will be sent to the first IP address. The second user who accesses the home page will be sent to the next IP address, and the third user will be sent to the third IP address. In each case, once the IP address is given out, it goes to the end of the list. The fourth user, therefore, will be sent to the first IP address, and so forth.

A round-robin DNS name is, on rare occasions, referred to as a "rotor" due to the rotation among alternative A records.

Migrating Millions of Concurrent Websockets to Envoy | 10 minutes reading

March 23, 2022

Here is the article. 

Slack has a global customer base, with millions of simultaneously connected users at peak times. Most of the communication between users involves sending lots of tiny messages to each other. For much of Slack’s history, we’ve used HAProxy as a load balancer for all incoming traffic. Today, we’ll talk about problems we faced with HAProxy, how we solved them with Envoy Proxy, the steps involved in the migration, and what the outcome was. Let’s dive in!

Websockets at Slack

To deliver messages instantly, we use a websocket connection, a bidirectional communications link which is responsible for you seeing “Several people are typing…” and then the thing they typed, nearly as fast as the speed of light permits. The websocket connections are ingested into a system called “wss” (WebSocket Service) and accessible from the internet using wss-primary.slack.com and wss-backup.slack.com (it’s not a website, you just get a HTTP 404 if you go there).

Websocket connections start out as regular HTTPS connections, and then the client issues a protocol switch request to upgrade the connection to a websocket. At Slack, we have different websocket services dedicated to messages, to presence (listing which contacts are online), and to other services. One of the websocket endpoints is specifically made for apps that need to interact with Slack (because apps want real-time communication too).

Motivation to migrate to Envoy Proxy

While we have been using HAproxy since the beginning of Slack and knew how to operate it at scale, there were some operational challenges that made us consider alternatives, like Envoy Proxy.

Hot Restarts

At Slack, it is a common event for backend service endpoint lists to change (due to instances being added or cycled away). HAProxy provides two ways to update its configuration to accommodate changes in endpoint lists. One is to use the HAProxy Runtime API. We used this approach with one of our sets of HAProxy instances, and our experience is described in another blog post — A Terrible, Horrible, No-Good, Very Bad Day at Slack. The other approach, which we used for the websockets load balancer (LB), is to render the backends into the HAProxy configuration file and reload HAProxy.

With every HAProxy reload, a new set of processes is created to handle the new incoming connections. We’d keep running the old process for many hours to allow long-lived websocket connections to drain and avoid frequent disconnections of users. However, we can’t have too many HAProxy processes each running with it’s own “at the time” copy of the configuration — we wanted instances to converge on the new version of the configuration faster. We had to periodically reap old HAProxy processes, and restrict how often HAProxy could reload in case there was a churn in underlying backends.

Whichever approach we used, it needed some extra infrastructure in place for managing HAProxy reloads.

Envoy allows us to use dynamically configured clusters and endpoints, which means it doesn’t need to be reloaded if the endpoint list changes. If code or configuration do change, Envoy has the ability to hot restart itself without dropping any connections. Envoy watches filesystem configurations with inotify for updates. Envoy also copies statistics from the parent process to the child process during a hot restart, so gauges and counters don’t get reset.

This all adds up to a significant reduction in operational overhead with Envoy, and no additional services needed to manage configuration changes or restarts.

Load Balancing Features

Envoy provides several advanced load-balancing features, such as:

  • Built-in support for zone-aware routing
  • Panic Routing – Envoy will generally route traffic only to healthy backends, but it can be configured to send traffic to all backends, healthy or unhealthy, if the percentage of healthy hosts drops below a threshold. This was very helpful during our January 4, 2021 outage, which was caused by a widespread network problem in our infrastructure.

Because of the above reasons, in 2019, we decided to migrate our ingress load balancing tier from HAproxy to Envoy Proxy, starting with the websockets stack. The major goals of the migration were improved operability, access to new features that Envoy provides, and more standardization. By moving from HAProxy to Envoy across all of Slack, we would eliminate the need for our team to know the quirks of two pieces of software, to maintain two different kinds of configuration, to manage two build and release pipelines, and so on. By then, we were already using Envoy Proxy as the data plane in our service mesh. We also have experienced Envoy developers in-house, so we have ready access to Envoy expertise.

Generating Envoy configuration

The first step in this migration was to review our existing websocket tier configuration and generate an equivalent Envoy configuration. Managing Envoy configuration was one of our biggest challenges during the migration. Envoy has a rich feature set, and its configurations are quite different to those of HAProxy. Envoy configuration deals with four main concepts:

  • Listeners, which receive requests, aka TCP sockets, SSL sockets, or unix domain sockets
  • Clusters, representing the internal services that we send requests to, like message servers and presence servers
  • Routes, which glue listeners and clusters together
  • Filters, which operate on requests

Configuration management at Slack is primarily done via Chef. When we started with Envoy, we deployed envoy configuration as a chef template file, but it became cumbersome and error-prone to manage. To solve this problem, we built chef libraries and custom resources for generating Envoy configurations.

envy cookbook -> libraries -> 1.listner.rb 2. route.rb 3. cluster.rb 4. http_filter.rb 5. envoy_config.rb


Inside Chef, the configuration is a Singleton, modelling the fact that there is only one Envoy configuration per host. All Chef resources operate on that singleton, adding the listeners, routes, or clusters. At the end of the chef run, the envoy.yaml gets generated, validated, and then installed — we never write intermediate configurations, because these could be invalid.

This example shows how we can create one HTTP listener with two routes that routes traffic to two dynamic clusters.

It took some effort to replicate our complicated HAProxy configuration in Envoy. Most of the features needed were already available in Envoy so it was just a matter of adding the support for it to the chef library and voila! We implemented a few missing Envoy features (some were contributed upstream and some are maintained in-house as extensions).



Udemy: System Design Interview Guide for Software Architecture

 Sandeep is an Experienced Tech Lead/Architect with a huge breadth and depth of knowledge based on his experience on a wide variety of technologies that he has worked on in his career.

He has expertise in designing systems that can handle any amount of traffic and has helped multiple startups scale from a very small scale to being Billion Dollar companies, the Fortune #1 company scale their business even further and multiple other Fortune 500 companies.

He has been designing systems that are built for handling huge scale effectively over the last many years now and is teaching people how to build such systems for the last couple of years.

He has work experience in technologies for Frontend, Backend, Big Data, Machine Learning, Various Database options, Microservices, Analytics, and basic Data Science to name a few with industry experience ranging from Education to Advertising to Hospitality to Travel to E-Commerce to Supply Chain to Social Networks.


Udemy: Mastering the System Design Interview | Frank Kane

If you are looking for an Udemy course to prepare for System Design then you should look no further than this System design interview course by Frank Kane, an ex-Amazon hiring manager.

In this course, Frank has shared his first-hand experience with how to tackle System design questions on FAANG interviews. You will not only learn all the tips, concepts, and approaches to solve system design questions but also practice many classic System design problems like URL shorter, Web Crawler, and Designing a Restaurant reservation system.

Here are the key things you will learn in this 5-hour long System design course:

  • Learn techniques for scaling distributed systems and service fleets
  • Overview of Database technologies and “NoSQL” solutions
  • How to use caching to improve scalability and performance
  • How to design for resiliency and handling failures
  • How ot use Distributed storage solutions
  • How to process big data with Apache Spark
  • An overview of cloud computing resources

Along with that it also comes with six full mock interviews with real-world system design interview questions and general tips and tricks for a successful technical interview. You will also learn Interview strategies for structuring your system design interview

What makes this course separate from other system design courses is Frank Kane’s first-hand experience and his voice and teaching style which really makes learning super engaging and productive.

 

System design course: Udemy | Frank Kane

 

2. Mastering the System Design Interview by Ex Amazon Hiring Manager [Frank Kane]

If you are looking for an Udemy course to prepare for System Design then you should look no further than this System design interview course by Frank Kane, an ex-Amazon hiring manager.

In this course, Frank has shared his first-hand experience with how to tackle System design questions on FAANG interviews. You will not only learn all the tips, concepts, and approaches to solve system design questions but also practice many classic System design problems like URL shorter, Web Crawler, and Designing a Restaurant reservation system.

Here are the key things you will learn in this 5-hour long System design course:

  • Learn techniques for scaling distributed systems and service fleets
  • Overview of Database technologies and “NoSQL” solutions
  • How ot use caching to improve scalability and performance
  • How to design for resiliency and handling failures
  • How to use Distributed storage solutions
  • How to process big data with Apache Spark
  • An overview of cloud computing resources

Along with that it also comes with six full mock interviews with real-world system design interview questions and general tips and tricks for a successful technical interview. You will also learn Interview strategies for structuring your system design interview

What makes this course separate from other system design courses is Frank Kane’s first-hand experience and his voice and teaching style which really makes learning super engaging and productive.

Here is the link to join this course — Mastering the System Design Interview

System design courses: 10 best

10 Best System Design Courses for Coding Interviews in 2022

 

 Here is the link.


Tuesday, March 22, 2022

Exponent: Annual subscription | $12/ month

 Welcome, new Exponent Member!


Thanks for joining Exponent! We're so excited to help you land your dream job.

Here's how to make the most of your new membership:- The Exponent Team 

Exponent: System design videos | Plan to purchase annual subscription

March 22, 2022

Introduction

I plan to subscribe annual subscription of Exponent, so that I can watch some paid videos about system design. 

Exponent 

Annual subscription $12/ month 

Here is the link.

Course library -> System design

Here is the link.

Fundamentals of system design

  1. Introduction to system design
  2. The system design interview
  3. How to answer system design questions
  4. System design principles
  5. Web protocols
  6. Load balancers
  7. Content delivery networks
  8. APIs
  9. CAP theorem
  10. Caching strategies
  11. SQL vs NoSQL
  12. Replication
  13. Database sharding
  14. Asynchronous processing
  15. How do computers handle memory management?
  16. Encryption
  17. Authentication and authorization
  18. Cloud architecture
  19. Reliability strategies
  20. Company engineering blogs
  21. System design glossary

System design questions | 12 videos | 16 lessons


  1. Design Facebook messenger
  2. Design a URL shortener
  3. Design twitter
  4. Design Tiktok
  5. Design instagram
  6. Design a landmark recognition system
  7. Design a parking garage
  8. Design a vending machine
  9. Design youtube
  10. Design typehead for search box
  11. Design a web crawler
  12. Design a web crawler (video)
  13. Technical PM/TPM interview: Google search
  14. When should you use Http vs. Https?
  15. Break a monolith into Microservices
  16. Tips for system design questions



C# code: Given a target, find expressions with two operators +, -

March 22, 2022

Introduction

It is an algorithm I like to share and also take some time to think. How can I write better C# code without worrying about so many edge cases, and code is production-ready. 

Algorithm | My practice

Here is the link.


7 benefits to work on Leetcode algorithms

March 22, 2022

Introduction

I just had a few very busy weeks to study Leetcode algorithms, and I have chance to practice another 40 algorithms in last three months. I did prepare for Microsoft Vancouver code screen, virtual onsite, and then Meta phone screen. 

7 benefits to work on Leetcode algorithms

I really enjoy time to learn system design, NoSQL like Google bigtable, and also read technical papers, large distributed system course lecture notes, watch videos as well. But it is more important for me to practice Leetcode algorithms. There are so many benefits, and I like to write down a few of them, so that I can continue to maintain the habit to practice, and improve my crafting skills. 

There are 7 benefits I like to talk about, and I just put together in 10 minutes here. 

  1. Find my most favorite algorithm in the long time, and I learn to overcome my weakness in terms of design. The algorithm discuss is here.       
  2. I was so busy to work on Leetcode algorithm last two months, but total of my submissions is less than 200. Compared to Dr. Lai, last 12 months over 1500 submissions. I also work on my short research to try more submissions, different languages, and also other code from discuss, solutions. If I continue to work on submissions, then I will have more ideas to try.
  3. Get more self-control. I did not have any submissions from 2021 June to October. I have to practice self-control, and figure out how to build a good habit to practice. I should practice at least 20 algorithms a month, 10 algorithms a weekend, 3 algorithms a Canadian statue holiday. 
  4. I had three mock interviews on interviewing.io this time. I did have very good learning experience as well.  I wrote the discuss post here. 
  5. I did some research around leetcode.com, product features for players, locked solutions for premium user, and I still need more time to get to know more players, and read more solutions from others as well. 
  6. Understand the book writing is not easy. I have chance to read one chapter of patterns, writen by Li Yin, AI engineer. 
  7. I have a lot of good habits to document my practice, and also get better to learn and track my progress. 
  8. Meta phone screen is not easy, it is tough. I have to take it seriously, and prepare early.                                                                                                                                                                                                                                                                                                            

Monday, March 21, 2022

Last week's rally is a reminder to watch for bounces during market downturns, Jim Cramer says

 March 21, 2022

Here is the link. 

CNBC's Jim Cramer told investors what last week's rally tells investors about market volatility, and how they should maintain their portfolios going forward.

Last week's winners - seminconductors

  1. Lesson: Never get too negative
  2. People sold before rebound
  3. Adurable - full blown recession
  4. Delta, American express
  5. Nvida
  6. Profitable company, real company, real ...
  7. Make through together -
Play again, take more notes again

  1. Semiconductors: GlobalFoundries, NVIDIA
  2. A lot of people sold just the day before this rally happens
  3. Chinese name, ARRK name, super expensive name under this interest rate environment - went down
  4. Macy - six times earning
  5. Delta
  6. America express
  7. Last week reposition
  8. Bottom line: ...But I still recommend sticking to profitable companies with real products or services


Lessons from last week's rally
  1. Once the market gets oversold, it doesn't take much good news to create an explosive rebound
  2. When the whole market roars, recognize that not everything has the same kind of staying power
All the major averages were up more than 5% last week.
Dow -202




Leetcode discuss: 2096. Step-By-Step Directions From a Binary Tree Node to Another

March 21, 2022

Here is the link. 


C# | Preorder | TLE error 287/332

March 21, 2022
Introduction
It took me over 30 minutes to work on a few issues, and then my algorithm could not pass online judge, failed test case 287/332 TLE error.

Preorder traversal | Find startValue and DestValue | Common prefix

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2096_step_by_step
{
    class Program
    {
        public class TreeNode {
          public int val;
          public TreeNode left;
          public TreeNode right;
          public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) {
              this.val = val;
              this.left = left;
              this.right = right;
          }
        }

        static void Main(string[] args)
        {
            var node5 = new TreeNode(5);
            node5.left = new TreeNode(1);
            node5.right = new TreeNode(2);
            node5.left.left = new TreeNode(3);
            node5.right.left = new TreeNode(6);
            node5.right.right = new TreeNode(4);

            var test = new Program();
            var start = test.GetDirections(node5, 3, 6);
            var end = test.GetDirections(node5,3, 6);
        }

        /// <summary>
        /// Find startValue using 'L','R','U'
        /// Find endValue using 'L','R','U'
        /// </summary>
        /// <param name="root"></param>
        /// <param name="startValue"></param>
        /// <param name="destValue"></param>
        /// <returns></returns>
        public string GetDirections(TreeNode root, int startValue, int destValue)
        {
            if (root == null)
                return "";

            var found = false;
            var found2 = false;
            var path1 = new StringBuilder();
            var path2 = new StringBuilder();
            
            runPreOrderTraversal(root, startValue, ref found, "", path1);
            runPreOrderTraversal(root, destValue, ref found2, "", path2);
            var commonPrefix = -1;

            for (int i = 0; i < Math.Min(path1.Length, path2.Length); i++)
            {
                if (path1[i] == path2[i])
                {
                    commonPrefix = i;
                    continue;
                }
                else
                {
                    break;
                }
            }

            var result = new StringBuilder();
            var start = commonPrefix + 1;
            while (start < path1.Length)
            {
                result.Append('U');
                start++;
            }

            start = commonPrefix + 1;
            while (start < path2.Length)
            {
                result.Append(path2[start]);
                start++;
            }

            return result.ToString();
        }

        private void runPreOrderTraversal(TreeNode root, int startValue, ref bool found, string prefix, StringBuilder path)
        {
            if (root == null || found)
            {                
                return;
            }

            if (root.val == startValue)
            {
                found = true;
                foreach(var item in prefix)
                    path.Append(item);
                return;
            }
            
            runPreOrderTraversal(root.left,  startValue, ref found, prefix + "L", path);            
            runPreOrderTraversal(root.right, startValue, ref found, prefix + "R", path);
            
        }
    }
}