Programmer Interview Questions

Date: Oct 26, 2022

Related Tags:1. ApsaraDB RDS for MySQL
2. ApsaraDB for Redis

Abstract:This article introduces the details of programmers interviewing Tencent.

After half a year of precipitation, and the addition of MySQL, redis and distribution, I finally regained my confidence in the interview and set off again.

goose factory
Interview position: go back-end development engineer, accepting from Java to language

We all know that the goose factory is the main battlefield of cpp, and most engineers with cpp as the background have very high requirements on os and network, unlike Java, which is a language that focuses on the business layer.

The companies that interviewed Java before focused on data structures, networks, frameworks, databases, and distribution. So the OS suffers a lot.

One side: basic technical side

In the phone interview, I asked some technical questions casually, and finally asked a medium-level algorithm question in LeetCode, which was relatively simple. A brief recollection of:

Has redis been used, commonly used data structures and scenarios used in business.

How is the hash of redis implemented?

What is the difference between the rehash process and the rehash of JavaHashMap?

Have you ever learned about redis cluster, how to achieve high availability?

Talking about the persistence mechanism of redis, why can't we use redis as a dedicated persistent database storage?

If you don’t understand tcp/udp, let’s talk about the definitions of the two. Why does tcp need to shake hands three times and wave four times?

How does tcp ensure orderly transmission, talk about the fast retransmission and congestion mechanism of tcp

Do you know the time_wait state, where does this state appear, and what is the use?

udp is an unreliable transmission. If you design an algorithm that is almost reliable based on udp, how to design it?

What is the difference between http and https? Tell me what problem https solves and how to solve it? Let's talk about the https handshake process.

Look at the etcd used in your project, explain what etcd is used for, and how to ensure high availability and consistency?

Since you mentioned the raft algorithm, what about the basic process of the raft algorithm? How to deal with split brain in raft algorithm?

Have you ever understood the zab algorithm of paxos and zookeeper, what is the difference between them before?

What database do you use for persistence in your backend? Have you used sub-database and sub-table, how to do it?

What are the common implementations of indexes and what are the differences?

What are the storage engines of MySQL and what are the differences?

What method does InnoDB use to implement indexes, and how? What is the difference between a clustered index and a non-clustered index?

Did you know about coroutines? Tell me the difference between coroutines and threads?

Algorithm question one, the sword refers to the 51st question of the offer, repeating numbers in the array?

Roughly speaking about my own answer, there is no problem with redis. The specific rehash has the impression that it is gradual, but the specific principle may be a little different.

The time_wait of tcp is not a very good answer. I have not understood the implementation of the quic mechanism before, so when I ask about the reliability of udp, I basically talk about the implementation of tcp in my mind.

There is nothing to say about https. Similar things were used in previous projects, and the research is relatively clear.

Because the raft algorithm is just brushing 6.824 (just brushed to lab2...), the answer is also improvised, but the paxos and zab algorithms are really unfamiliar, so I say no.

MySQL is very familiar, including indexes, locks, transaction mechanisms and mvcc, etc. There is nothing to say, all of which have been completed.

Coroutines and threads mainly talk about the difference between goroutines and Java threads and the scheduling model of goroutines. The interviewer suggested that there is no mention of thread switching in kernel mode, and goroutines are only scheduled in user mode.

The last algorithm question, first of all, use HashMap to do it, and say whether the space complexity can be reduced to O(1). After thinking about it for about 5 minutes, I came up with the idea of ​​​​in-place replacement.

All in all, the answer is okay, and that's it.

The second side: the technical side of the project

On the second side, I transferred from the basic technical inspection to the project, and mainly asked me the following questions:

For the project you are most familiar with, draw the project structure diagram and the main data table structure of the project.

Talk about the technical points used in the project, the total peak qps of the project, and the delay.

Have you analyzed where the time-consuming and time-consuming delays appear, and whether there is any improvement in the project?

If there is a problem with the request and there is no response, how to locate the problem and give some ideas?

How to deal with the tcp sticky packet problem?

Then I also asked about the mode of cache update, as well as the problems and solutions?

In addition to company projects, have you researched or contributed to well-known projects in your spare time?

The answer on this side is also relatively smooth, because it is all about the project, I am very familiar with it, and there are basically no problems. Except the interviewer said that the project experience is slightly weak, the rest is not bad.

Three aspects: comprehensive technical aspects
On this side, there is a lot of confusion. The interviewer asks questions in a fundamental way. After all, the interview experience is not enough, which makes the rhythm of the interview a bit chaotic. for example:

One of the questions is: What is the difference between goroutines and threads?

A: Starting a go process only requires about 4kb of memory, and starting a Java thread requires 1.5MB of memory; the scheduling of go processes is very lightweight in user mode, and the switching cost of Java threads is relatively high.

Then ask why the cost is higher? Because the scheduling of Java threads needs to switch between user mode and kernel mode, so the cost is high? Why is it expensive to switch scheduling between user mode and kernel mode? I briefly talked about the definitions of kernel mode and user mode.

Then ask, still do not understand why the cost is high? My heart collapsed in an instant, it was endless, the OS was still painful, and I gave up after hesitating for a long time.

All the questions that follow follow this pattern, and as a result, there is no rhythm in answering, and it feels like a routine. Most of them can answer one, two, or even one, two, three, but it will be GG later or deeper into the OS level.

Later, I asked the biggest challenge encountered during the project and how to solve it?

I also asked a question about problem positioning, how to position the server CPU 100%?

It may be due to the usual mindset of locating business problems, coupled with being in a blinded state, casually:

Check the monitoring panel first to see if there is any abnormal burst traffic

Then check whether there is any abnormality in the business log. For the time period when the CPU is 100%, take a log of a typical business process to view.

Finally, I mentioned using the top command to monitor which process is occupied by 100%.

Sure enough, he was in a mess, he opened his mouth and covered his face. . .

For this problem, the correct idea should be to use top to locate the problem process first, then use top to locate the problem thread, and then print the thread stack to check the running status.

This process can definitely answer the usual, but, but there is no but. Still have to sum up.

Finally, I asked a system design question (the design of the circle of friends). On the whiteboard, I drew the architecture diagram of the system, the main table structure and explained the main business processes. If the number of users increases and the traffic increases, how will the architecture expand and how to deal with it?

This answer is also a bit messy. It came directly from Gu Zi and used a general architecture, which doesn't feel like a bright spot.

Later reflections should first locate the characteristics of the business. This business is obviously more reading and less writing. Then communicate with the interviewer about the number of users, performance requirements, single-machine target qps, etc.

Design after clarifying the characteristics and constraints of the system, instead of using the general architecture of the typical Internet to develop your own solution from the beginning.

Interview result: Received a text message after 3 days, rejected

Tcp/udp, http and https and network (various network models, already selected, poll and epoll) must be very familiar

You must have the project experience that you can take out, and you must be able to speak clearly, explain the trade-offs in the project, design models and data sheets

Distributed to be very familiar with

Common problem positioning must have ideas

Operating system, or operating system, the important thing is said three times

System design, ideas, ideas, ideas, must have clear ideas, and must summarize the process of system design

A little bit of experience, no matter how many blogs and columns I usually read, if I don’t have my own thinking, it’s just passing by, and it won’t become my own thing at all, just like the kernel mode and user mode, I usually read it, but I don’t think about it, suddenly I want to be myself It's embarrassing to say, I really can't say it. Don't build a high platform with floating sand. It still takes time to slowly build a foundation for this kind of thing, and think and summarize more.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us