Skip to main content

Posts

Web Technology troubleshooting

Get a troubleshooting question in the interview, and you are excited because some troubleshooting techniques came to your mind immediately? Hold on! Diving into a specific solution without clarifying the issue is usually a bad practice. You should always ask questions to clarify the issue and start from the big picture. Using "binary search"(yes or no question) to clarify the issue is a common practice. "Users report they got error when visiting your website" The big picture is this kind of troubleshooting question can usually be broken down into 3 parts. client side issue network issue server side issue After getting the big picture, you can start troubleshooting. client side issues Can you reproduce it? Yes - it's obvious there is a bug. Find out what the bug is and file it. If you can not precisely find the root cause, at least summarize how to reproduce it, so the engineers who are in charge of this can better address the issue. C...
Recent posts

How DNS work

When entering www.google.com in the browser, the following process starts: Browser looks up it's cache to see if it knows the IP address(to see the DNS Cache in Chrome, go to chrome://net-internals/#dns) Computer checks local host file(usually /etc/hosts) Computer asks local DNS server(ISP DNS server) -> it's called recursive query Local DNS server checks local cache. If the IP address of this domain is not in the cache, the local DNS server starts the following iterative query procedure: local DNS server queries a global root server(there are 13 sets of root servers globally) A root server directs the local DNS server(resolver) to the IP of a top level domain(TLD) server The TLD server refers the resolver to the Google DNS server the Google DNS server knows the IP address of www.google.com  Local DNS server caches the IP address in case it needs the address in the future and returns it to the computer Computer caches the IP address and visits the address

How Packets Move Through a Network

Let's say we have the following setup: Host 1 -> Switch 1 -> Router 1 -> Router 2 -> Switch 2 -> Host 2 How packets move through the network when H1 wants to send some data to H2? 1. H1 needs to learn R1's MAC address to create a data link layer frame H1 is the initializer and gets a couple of tasks to do adds transport layer header, which includes the source port and destination port, to the data and sends the segment to network layer. In network layer, it creates an IP header, in which source IP address and destination IP address are specified. Then it sends the packet to data link layer In Data link layer, H1 needs to learn H1's Default Gateway's MAC via  Address Resolution Protocol (ARP), so the default gateway can help send the data to H2, which is in different network. (ARP is a data link layer protocol) sends out an ARP request, which targets to the IP address of Default Gateway. S1 receives the ARP request and  learns H1...

Steps to solve a coding problem

Diving in the problem directly is usually not a good idea. A good approach should should be: ask some questions to clarify the question think of some base test cases and edge cases. write the code test the code with cases analyze the complexity of your code can you can improve the complexity?

Common ideas to solve problems

Although problems may look very different from others, they usually share some common ideas. Array it's usually helpful to divide an array problem to subproblmes. Such as merge sort. Linked List runner: use 2 pointers - a fast runner and a slow runner to iterate over the list. recursion Recursion when you need to return multiple data from recursion, it's helpful to create a class to wrap the data

Test cases to keep in mind

Testing your code is an important part of coding interview. This note try to list down some common cases worth keeping in mind. Int 0 infinite -1 Array length odd even 0 index out of range off-by-one error: when manipulating array index, make sure you cover all the indices and the manipulation will not lead to infinite loop. (it's easy to get this kind of error when you need to divide the problem into subproblems and set index as low, high, and mid, such as binary search) Loop and Recursion will the loop really get started? will the loop end properly? Tree & Graph What if there is only one node? Is there a circle in the graph? If so, watch out for infinite traverse!