Fundamentals 19 min read

Comprehensive Interview Review: Networking, TCP/IP, Epoll, Redis, MySQL MVCC, and C++ Concepts

This article compiles a detailed interview guide covering TCP/UDP differences, three‑way handshake and four‑way termination, flow and congestion control, select/poll/epoll mechanisms, zero‑copy techniques, Redis advantages and persistence, MySQL MVCC and repeatable‑read semantics, as well as core C++ topics and common algorithm questions.

IT Services Circle
IT Services Circle
IT Services Circle
Comprehensive Interview Review: Networking, TCP/IP, Epoll, Redis, MySQL MVCC, and C++ Concepts

The author shares a reader's interview notes for a C++ backend internship, supplementing answers on networking, operating systems, MySQL, Redis, and algorithm basics.

Computer Network

UDP vs TCP

TCP is a connection‑oriented, reliable byte‑stream protocol, while UDP is connection‑less and unreliable; UDP offers better real‑time performance.

TCP Handshake and Teardown

The three‑way handshake establishes a TCP connection using states CLOSE, LISTEN, SYN, SYN‑SENT, SYN‑RCVD, and finally ESTABLISHED. The four‑step termination involves FIN and ACK exchanges, moving through states such as FIN_WAIT_1, FIN_WAIT_2, TIME_WAIT, and ending in CLOSE.

Flow Control and Congestion Control

TCP uses flow control to match the sender’s rate to the receiver’s processing capacity and congestion control to avoid saturating the network, reducing retransmissions and latency.

Website Access Process (HTTP)

The author adds a diagram of the full stack traversal from the application layer down to the data‑link layer and routers when a URL is entered.

IP/Port and Connection Establishment

A client needs the server’s IP and port and calls connect(); the server must listen on an address reachable by the client.

Select, Poll, Epoll Differences

Select copies a fixed‑size file‑descriptor bitmap ( FD_SETSIZE ≈ 1024) to kernel space, scans it linearly, and copies it back, causing two traversals and two copies per event.

Poll replaces the bitmap with a dynamic array, removing the descriptor limit but still requiring linear scans.

Epoll uses a red‑black tree for efficient O(log n) insert/delete and a ready‑list for event‑driven notifications, eliminating full scans and reducing copies.

Epoll Workflow

Create an epoll object with epoll_create, which holds a ready list and a red‑black tree.

Add sockets to the tree via epoll_ctl and register callbacks.

Call epoll_wait to block until events occur; the kernel moves ready sockets to the list and returns them to user space.

Zero‑Copy

Zero‑copy (e.g., sendfile) eliminates two context switches and data copies by using DMA, employed by projects like Nginx and Kafka.

Redis

Advantages and Use Cases

Redis is an in‑memory database offering extremely fast read/write, suitable for caching, distributed locks, flash sales, and message queues.

Why Redis Is Fast

All operations run in memory with efficient data structures, making CPU not the bottleneck.

Single‑threaded execution avoids thread‑contention and deadlocks.

It uses I/O multiplexing (select/epoll) to handle many client sockets with one thread.

Persistence

Redis provides three persistence methods: AOF (append‑only log), RDB snapshots, and the hybrid approach introduced in Redis 4.0.

Distributed Lock with Redis

The SET command with NX and PX options implements an atomic lock: SET lock_key unique_value NX PX 10000 Key points: the key must not exist (NX), an expiration prevents deadlocks (PX), and a unique value identifies the owner.

MySQL

MVCC Concept and Implementation

InnoDB creates a Read View containing four fields: m_ids (list of active transaction IDs), min_trx_id, max_trx_id, and creator_trx_id. Each clustered index record stores hidden columns trx_id and roll_pointer to track the creating transaction and the undo pointer.

Visibility rules:

If trx_id < min_trx_id, the version is committed before the view and is visible.

If trx_idmax_trx_id, the version was created after the view and is invisible.

If min_trx_idtrx_id < max_trx_id, check whether trx_id is in m_ids; if present, it is still active and invisible, otherwise it is visible.

Repeatable Read

Repeatable read guarantees that a transaction sees a consistent snapshot for the whole transaction; the snapshot (read view) is created on the first SELECT (or immediately with START TRANSACTION WITH CONSISTENT SNAPSHOT).

C++

Difference between pointers and references.

Smart pointers and their usage.

When destructors are invoked.

Memory‑leak detection with Valgrind.

Algorithms

Top‑K problem and hot‑search ranking (heap choice).

Linked‑list reversal implementation.

Overall, the material emphasizes that interview questions focus more on operating systems, networking, databases, and algorithms than on pure programming language syntax.

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.

databaseconcurrencyc++TCPmysqlNetworking
IT Services Circle
Written by

IT Services Circle

Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.

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.