title: ByteDance Second Round Interview Questions Record
date: 2021-10-21 19:01:53
Yesterday afternoon, I participated in two interviews. The first round of the interview with Kuaishou went smoothly and I passed. I thought the second round of the interview with ByteDance wouldn't be too difficult, but I ended up being overwhelmed... Here, I will record the topics that I didn't know or wasn't clear about for review purposes (sad.
Computer Architecture Related
Do you have an understanding of CPU cache structure?
Computer Networking Related
What problems can arise from having too many connections in the TIME_WAIT state? How to solve them?
The range of ports is 0-65535, excluding those occupied by the system and other services. Therefore, the number of available ports for TCP is actually not many. In this case, if a large number of connections remain in the TIME_WAIT state, it will prevent the use of these ports when other HTTP requests arrive. In other words, a continuous arrival of a certain amount of high-concurrency short connections will cause the server to refuse to serve a portion of clients due to insufficient port resources.
Do you have an understanding of HTTP persistent connections?
What are the common request headers in HTTP?
How to write a cookie?
The server creates a cookie by sending an HTTP header named Set-Cookie as part of the Response Headers. Each Set-Cookie represents a cookie (if there are multiple cookies, multiple Set-Cookie headers need to be written), and each attribute is also in the form of name/value pairs (except for secure), separated by a semicolon and a space. The format is as follows:
Set-Cookie: name=value[; expires=GMTDate][; domain=domain][; path=path][; secure]
What is the principle behind using the kill command to kill a process?
The kill command sends a signal to the process with the specified process ID. The list of signals that can be sent is as follows:
❯ kill -l
HUP INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM
TERM STKFLT CHLD CLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF
WINCH IO POLL PWR SYS RT<N> RTMIN+<N> RTMAX-<N>
Do you have an understanding of Linux commands related to networking?
When garbage collection starts scanning objects from the root node in Golang, what does the root node refer to?
Reference article: Golang Garbage Collection - Zhihu
Root set: The root objects, which are the objects checked by the garbage collector first. They include variables that can be determined by the program during compilation and variables on each goroutine's execution stack as well as pointers to the heap memory during execution.
What is the difference between WaitGroup and Channel for concurrency control in Golang?
Going into the underlying implementation, WaitGroup is essentially a semaphore, and modifications to the semaphore use atomic operations from the
atomic package. On the other hand, a channel itself is a thread-safe circular queue, and its internal production and consumption processes require locking. In other words, WaitGroup is lock-free, while channels have locks. (Personal understanding)
Why does Golang use a circular queue for channels?
I couldn't find an official answer, but I refer to the content of the blog post Illustrated Explanation of the Underlying Implementation of Go Channels - Cai Gang RyuGou's Blog:
As for why channels use a circular linked list as the cache structure, I personally think it is more convenient to locate the current send or recvx position and select the send and recvx positions during the dynamic send and recv process of the cache list. Just follow the order of the linked list to rotate the operations.
My personal understanding aligns with the author's.
When does Golang garbage collection perform STW (Stop the World)?
To tackle that potential issue, an algorithm of write barrier is implemented and will allow Go to track any pointer changes. The only condition to enable write barriers is to stop the program for a short time, also called "Stop the World".
In other words, STW is required before the marking process begins.