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 it turned out to be extremely challenging... I will record the topics that I didn't know or wasn't clear about here for review (sad.
Computer Architecture Related#
Do you have any understanding of CPU cache structure?#
Reference articles:
Computer Networking Related#
What problems can arise from having too many time wait states? How to solve them?#
The range of ports is 0-65535. After excluding the parts occupied by the system and other services, the number of available TCP ports is actually not many. In this case, if a large number of connections remain in the TIMEWAIT state, it will prevent these ports from being used 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 reject serving a portion of the clients due to insufficient port resources.
Solution:
Do you understand HTTP persistent connections?#
Reference article:
HTTP Persistent Connections and Short Connections - Cnblogs
Common HTTP request headers?#
Reference article:
Detailed Explanation of Common HTTP Request Headers and Response Headers - Juejin
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 should be written), and each attribute is 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]
Reference article:
Linux Related#
What is the principle of killing a process using the kill command?#
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 any understanding of Linux commands related to networking?#
Reference article:
Common Linux Network Commands - Cnblogs
Golang Related#
What does the root node refer to in garbage collection that starts scanning objects?#
Reference from the article: Garbage Collection in Golang - Zhihu
root set: The root object, the object that the garbage collector checks first. It includes variables that can be determined by the program during compilation, variables on each goroutine's execution stack and pointers to the heap, and pointers to heap memory during execution.
What is the difference between WaitGroup and Channel for concurrency control in Golang?#
Going deep into the underlying implementation, WaitGroup is essentially a semaphore, and the modification of the semaphore uses atomic operations in the atomic
package. On the other hand, a channel 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 a definitive answer, so I referred to the content of the article Illustrated Explanation of Golang Channel Underlying Implementation - Cai Gang RyuGou's Blog:
As for why the channel uses 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 in the dynamic send and receive process of the cache list. You just need to rotate the list in order.
My personal understanding is the same as the author's.
When does Golang garbage collection perform STW (Stop the World)?#
Reference from the article:
Go: How Does the Garbage Collector Mark the Memory? - Medium
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 starts.