Why Is Tencent Rated Most Comfortable? 10 Essential Backend Interview Q&A

The article first presents a comfort ranking of Chinese internet companies, highlighting Tencent as the most comfortable, then provides a comprehensive backend interview guide covering networking fundamentals, HTTP protocols, Linux process commands, MySQL indexing, C++ struct vs class, STL containers, map thread‑safety, and the differences between queues and stacks.

Su San Talks Tech
Su San Talks Tech
Su San Talks Tech
Why Is Tencent Rated Most Comfortable? 10 Essential Backend Interview Q&A

In Chinese internet companies, a comfort ranking shows Tencent as the most comfortable, followed by Baidu and JD, while ByteDance and Pinduoduo are considered highly competitive.

The article then presents a detailed backend interview guide covering networking fundamentals (TCP vs UDP), HTTP transport choices and evolution (HTTP/1.1, HTTP/2, HTTP/3 with QUIC), Linux process commands, MySQL index implementation with B+Tree, differences between C++ struct and class, an overview of STL containers, thread‑safety considerations for std::map, and the distinction between queues and stacks.

腾讯(后端一面)

1. TCP和UDP区别是什么?

连接:TCP是面向连接的传输层协议,传输数据前先要建立连接;UDP是不需要连接,即刻传输数据。

服务对象:TCP是一对一的两点服务,即一条连接只有两个端点。UDP支持一对一、一对多、多对多的交互通信。

可靠性:TCP提供可靠交付,数据无差错、不丢失、不重复、按序到达;UDP采用尽最大努力交付,不保证可靠性。

拥塞控制、流量控制:TCP拥有拥塞控制和流量控制机制,UDP没有。

首部开销:TCP首部较长(20字节或更多),UDP首部固定8字节。

传输方式:TCP是流式传输,没有边界但保证顺序和可靠;UDP是分包传输,有边界但可能丢包和乱序。

2. HTTP用的是哪个传输协议,为什么?

HTTP/1.1底层基于TCP协议,原因是可靠性需求。HTTP需要确保数据完整、有序传输,TCP提供确认、重传、序号等可靠传输机制。

HTTP/2仍基于TCP,但通过多路复用、二进制帧、头部压缩(HPACK)等优化缓解了HTTP/1.1的队头阻塞问题。

HTTP/3改用基于UDP的QUIC协议,以解决TCP的队头阻塞、加速连接建立(1‑2 RTT)以及连接迁移等问题。QUIC在保持可靠性的同时利用UDP的低延迟优势。

3. HTTP状态码你知道哪些?

HTTP状态码分为5大类:

1xx:提示信息(中间状态)。

2xx:成功(服务器成功处理请求)。

3xx:重定向(客户端需使用新URL)。

4xx:客户端错误(请求报文有误)。

5xx:服务器错误(服务器内部处理出错)。

常见状态码包括200、301、302、404、405、500等。

4. HTTP是长连接还是短连接?

HTTP采用请求‑应答模式。默认情况下,HTTP/1.1使用长连接(Keep‑Alive),在同一TCP连接上可以发送多个请求/响应,避免频繁建立和释放连接的开销。

5. Linux查看进程指令是哪个?

使用 ps 命令。

6. Linux命令 ps -aux 第二列是什么,和 ps -elf 区别?

ps -aux

第二列是进程的PID,侧重显示用户、CPU/内存占用等信息; ps -elf 更侧重显示进程关系(PPID)、优先级(PRI/NI)和系统标志(F)。

7. MySQL的索引如何实现的?

MySQL InnoDB使用B+树作为索引结构。B+树是多叉树,叶子节点存放数据,非叶子节点只存索引键,所有数据按主键顺序存放,叶子节点通过双向链表相连,支持高效范围查询。 select * from product where id = 5; 查询过程从根节点逐层向下定位,通常只需3‑4次磁盘I/O。

8. 为什么用B+树不用B树?如果把内容存在内存上,B树会不会快一点?

B+树的非叶子节点只存索引键,叶子节点存数据并通过链表相连,降低树的高度,减少磁盘I/O,且更适合范围查询。即使在纯内存场景,B+树在大多数情况下仍具优势,只有在极端随机查询时B树可能略有优势。

9. C++中 struct和 class 区别是什么?

主要区别在默认访问权限和默认继承方式。 struct 默认成员为 public ,默认继承为 publicclass 默认成员为 private ,默认继承为 private

struct A { int x; void f() {} };
class B { int y; void g() {} };
int main(){
    A a; a.x = 10; a.f();
    // B b; // b.y = 20; // error: private
    return 0;
}

10. C++ STL有哪些容器?

STL容器分为序列式容器(vector、deque、list、array)、关联式容器(set、multiset、map、multimap)和容器适配器(stack、queue、priority_queue)。序列式容器适合频繁访问元素,关联式容器提供键值快速查找,容器适配器封装特定接口。

11. C++的 map 是线程安全的吗?

std::map本身不是线程安全的。并发写或读写会导致未定义行为,需要使用外部同步(如 std::mutex)或使用线程安全的容器实现。

#include <map>
#include <mutex>
std::map<int,int> my_map;
std::mutex mtx;
void safe_insert(int key,int value){
    std::lock_guard<std::mutex> lock(mtx);
    my_map[key]=value;
}
int safe_find(int key){
    std::lock_guard<std::mutex> lock(mtx);
    auto it=my_map.find(key);
    return it!=my_map.end()?it->second:-1;
}

12. 队列和栈有什么区别?

队列采用先进先出(FIFO),在队尾插入、队首删除;栈采用后进先出(LIFO),在栈顶插入和删除。

舒适度排行榜
舒适度排行榜
后端一面
后端一面
B+Tree 索引结构
B+Tree 索引结构
HTTP 长连接示意图
HTTP 长连接示意图
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendinterviewdatabasesNetworking
Su San Talks Tech
Written by

Su San Talks Tech

Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.