Master Tencent Interview: Deep Dive into HashMap, Redis, MySQL & System Design

This article compiles a comprehensive set of Tencent interview questions and detailed answers covering HashMap internals, thread safety, red‑black trees, Redis performance, MySQL indexing, TCP reliability, IO multiplexing, RPC, and system bottleneck analysis to help candidates prepare effectively.

Programmer DD
Programmer DD
Programmer DD
Master Tencent Interview: Deep Dive into HashMap, Redis, MySQL & System Design

Background

A recent graduate with a Java development background seeks to improve competitiveness by preparing for big‑tech interviews after two years of experience.

Tencent TEG First Interview

1. HashMap underlying implementation

Introduce the basic structure of HashMap and compare differences between JDK 1.7 and 1.8. Recommend reading the source of resize() and the red‑black tree conversion process.

2. Is HashMap thread‑safe? How to achieve thread safety?

Compare HashMap, Hashtable, and ConcurrentHashMap, discuss their use cases, and show how to make a HashMap thread‑safe by wrapping it with Collections.synchronizedMap or applying explicit locks.

3. Red‑black tree overview

Explain the principle of red‑black trees, their application in JDK 1.8 HashMap, and compare them with B+ trees and skip lists.

4. Why is Redis fast?

Discuss reasons such as in‑memory storage, single‑threaded design, efficient data structures, and I/O multiplexing. Mention performance bottlenecks (memory, network I/O) and Redis 6.0’s multi‑worker thread design compared with Memcached.

5. MySQL index introduction

Difference between clustered and non‑clustered indexes (InnoDB vs MyISAM)

How the optimizer selects indexes

Index invalidation

Index push‑down

6. Why choose B+ tree?

Describe differences between B+ tree and B tree, emphasizing B+ tree’s advantage in disk I/O because a single page can store more index entries; note MongoDB uses B‑tree indexes.

7. Clustered vs non‑clustered index

Clarify that clustered index and cluster index refer to the same concept.

8. Implicit primary key index

If no primary key is defined, InnoDB adds a hidden column as the primary key; this hidden column is needed for the storage engine’s internal structure.

9. Virtual memory vs physical memory

Physical memory is limited; virtual memory maps disk space to extend usable memory.

This mapping solves memory shortage when multiple processes run concurrently.

10. False sharing

Can be mitigated by using volatile and ConcurrentHashMap.CounterCell.

11. How TCP ensures reliable transmission

Checksum verification

Reordering

Duplicate discard

Acknowledgment mechanism

Timeout retransmission

Flow control

12. Congestion control

Slow start

Congestion avoidance

Fast retransmit

Fast recovery

Requires memorization and clear expression.

13. Project design

Discussion of project‑level design considerations.

14. Experience with Kafka / Elasticsearch

Brief mention of usage.

15. Awareness of latest Redis versions supporting multithreading

Reference to Redis 6.0+ features.

16. Written test topics

Includes programming, algorithm, and multiple‑choice questions about program output.

Second Interview

1. Biggest problem encountered (OOM)

Describe analysis steps based on theoretical foundations, systematic troubleshooting, and performance testing.

1、为什么引入RocketMQ
通过对核心接口的压测, 发现接口 tps 相对较低,经过排查发现主流程中操作步骤相对较多。
一次写请求处理了比较多内容,导致整个请求的响应缓慢。
通过将核心的流程和辅助功能进行拆分, 通过异步的方式完成后续的工作,从而提高接口的吞吐量。
问题:响应缓慢,吞吐量低
期望:快速响应,提高tps
解决方式:通过引入 RocketMQ 进行异步操作/解耦
2、为什么使用RocketMQ
技术选型:RabbitMQ,RocketMQ和Kafka
主要从:消息堆积,响应速度,底层语言和使用场景进行分析
3、如何保证消息的可靠性
从 客户端,MQ和消费端来进行保证消息可靠。
客户端: 通过事务消息来进行保证,或者失败重试(sendResult判断)
MQ :通过RocketMQ 集群,进行保证,主要由运维负责(可能会牵扯到MQ消息保存的问题)
消费端:1、消费幂等和2、流水表的形式
这个问题需要结合到项目中的实际场景进行分析, 不能硬套
4、优化后的吞吐量
这个是比较核心的问题, 你优化完之后, 没有做性能的测试,凭什么说引入就好了(引入中间件原本就会降低系统可靠性,提高复杂度)
因此需要在优化后,进行一轮的压测(注意测试场景要保持和生产或上一次测试场景一致)和消息的消费速度(避免消费过慢导致堆积)
5、优化后的性能瓶颈在哪?
主要从:cpu,内存和IO 三方面进行分析吧, 具体系统具体分析。

2. Why use Redis?

Introduce middleware to alleviate database pressure, frequent data changes, high access frequency, and low data freshness; discuss data consistency and high availability when Redis is unavailable.

3. Improved throughput and DB QPS

Assess performance impact of changes, quantify improvements, and identify remaining bottlenecks.

4. Database transactions and InnoDB index implementation

Explain transaction isolation levels and MVCC mechanism.

5. I/O multiplexing

Compare select, poll, and epoll; discuss epoll event notification implementation.

6. Performance bottlenecks and further optimization

Analyze CPU, memory, and I/O to locate bottlenecks.

7. RPC call process (why read Dubbo source)

Study Dubbo architecture and follow source code to understand RPC mechanisms and improve coding and design skills.

8. Team responsibilities

Version development

Issue handling

Task allocation

Technical review

9. Refactoring (ideas and implementation)

Discuss refactoring approaches.

10. Performance optimization actions

JVM tuning, SQL optimization/rebuilding indexes, and MQ decoupling.

11. Synchronous vs asynchronous differences

Explain the distinction.

12. Linux I/O multiplexing / AIO

Reference previous interview material.

13. Linux select notification

Explain select notification mechanism.

14. B+ tree vs red‑black tree

Compare data structures.

15. HashMap and red‑black tree

Discuss their relationship.

16. Inter‑process communication methods

Pipes

Anonymous pipes

Signals

Semaphores

Message queues

Shared memory

Sockets

17. System performance bottlenecks

Analyze CPU, memory, and I/O.

Result

The candidate ultimately received an offer from the Tencent TEG interview.

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.

BackendRedismysqlinterviewHashMap
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

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.