Backend Development 20 min read

Comprehensive Backend Interview Guide: Redis, MySQL, Operating System, Network, and Java Fundamentals

This article provides a detailed backend interview cheat‑sheet covering Redis data structures and performance issues, MySQL indexing and transaction principles, operating‑system process and thread concepts, TCP/UDP networking differences, and common Java garbage‑collection algorithms, all illustrated with examples and code snippets.

IT Services Circle
IT Services Circle
IT Services Circle
Comprehensive Backend Interview Guide: Redis, MySQL, Operating System, Network, and Java Fundamentals

Redis

Redis is an in‑memory database offering extremely fast read/write operations, commonly used for caching, message queues, and distributed locks.

It supports various data types such as String, Hash, List, Set, Zset, Bitmaps, HyperLogLog, GEO, and Stream, all with atomic operations because commands are executed by a single thread.

Additional features include transactions, persistence, Lua scripting, multiple clustering modes (master‑slave, sentinel, sharding), pub/sub, memory eviction, and expiration mechanisms.

ZSet

ZSet elements are stored using either a compressed list or a skiplist. If the number of elements is less than 128 and each element size is under 64 bytes, a compressed list is used; otherwise a skiplist is employed. In Redis 7.0 the compressed list has been replaced by the listpack structure.

The range query command ZRANGE has a time complexity of O(log(N)+M), where N is the total number of elements and M is the number of elements returned.

Skiplist

A skiplist is a multi‑level ordered linked list that reduces search complexity from O(N) to O(log N). Levels are assigned probabilistically: a random number in [0‑1] is generated, and for each value less than 0.25 the level increases by one.

Hash Table Rehash

Redis uses incremental rehash to avoid long pauses during hash table resizing. It allocates a new hash table (hash table 2) and gradually migrates entries from the old table (hash table 1) during normal read/write operations, spreading the cost over many requests.

During rehash, lookups first check hash table 1; if the key is not found, they continue searching hash table 2.

Big Key & Hot Key

Solutions for big keys include splitting large hashes into multiple smaller keys, cleaning up unused data, monitoring memory usage, and periodically deleting expired entries.

A hot key is identified by unusually high QPS, bandwidth, or CPU usage concentrated on a single key. Mitigation strategies involve replicating the hot key to other shards, using read‑write separation, or adding more replica nodes.

MySQL

Index Optimization

Prefix indexes reduce index size for long string columns.

Covering indexes allow queries to be satisfied entirely from the index without accessing the table.

Auto‑increment primary keys avoid page splits and improve insert performance.

Avoid index invalidation caused by leading wildcards (e.g., LIKE %xx ), functions on indexed columns, or violating the left‑most prefix rule in composite indexes.

In OR conditions, ensure the left side uses indexed columns; otherwise the index may be ignored.

Primary vs. Secondary Index

Primary indexes are unique, non‑null, and each table can have only one; they provide the main access path. Secondary (non‑primary) indexes can be multiple, allow nulls and duplicates, and are used for covering queries to avoid table lookups.

Transaction Properties

Atomicity : All operations in a transaction succeed or none do.

Consistency : Transactions preserve database invariants.

Isolation : Concurrent transactions do not interfere with each other.

Durability : Once committed, changes survive crashes.

Operating System

Process vs. Thread

A process is the smallest unit of resource allocation with its own address space, while a thread is the smallest unit of CPU scheduling that shares the process's resources.

Process switching incurs higher overhead due to address space changes; thread switching only saves a few registers.

Resources Assigned to a Process

Virtual memory, file descriptors, signals, etc.

Locking and Deadlock

Locks protect shared data from race conditions. A deadlock occurs when multiple threads hold resources while waiting for each other, satisfying the four conditions: mutual exclusion, hold‑and‑wait, no preemption, and circular wait.

Network

TCP vs. UDP

TCP is connection‑oriented, reliable, and provides flow and congestion control; UDP is connectionless and best‑effort.

TCP ensures ordered delivery; UDP sends independent packets.

Three‑Way Handshake

The handshake establishes a reliable connection using SYN, SYN‑ACK, and ACK packets, synchronizing initial sequence numbers and preventing “historical” connections.

Two‑way handshakes cannot block stale connections because the server may enter ESTABLISHED state before the client, leading to potential resource waste.

Java

Garbage Collection Algorithms

Mark‑Sweep

Copying

Mark‑Compact

Generational Collection (young and old generations)

Incremental (incremental collection)

JavaRedisMySQLOperating SystemNetworkingBackend Interview
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

login 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.