Backend Interview Questions and Answers: HTTP, HTTPS, TCP, Virtual Memory, Eureka, Hystrix, Zookeeper, and Longest Substring Algorithm

This article compiles a series of backend interview questions covering HTTP header fields, HTTPS handshake, TCP connection states, virtual and physical memory concepts, TCP connection limits, Eureka architecture and consistency, Hystrix fault‑tolerance mechanisms, Zookeeper's Zab protocol and leader election, and provides a Java solution for finding the longest substring without repeating characters.

Full-Stack Internet Architecture
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Backend Interview Questions and Answers: HTTP, HTTPS, TCP, Virtual Memory, Eureka, Hystrix, Zookeeper, and Longest Substring Algorithm

Preface

Hello, I am the author who collected these interview questions for backend positions. Feel free to discuss any errors in the comments.

1. HTTP Request Header Fields and Common Status Codes

1.1 Meaning of Expires and Cache-Control

Cache-Control

is an HTTP/1.1 header used to define caching policies such as public, private, no-cache, etc. Expires is an HTTP/1.0 header that specifies an absolute expiration time; browsers will serve the cached response until that time.

1.2 Common HTTP Status Codes

(Image omitted)

2. HTTPS Principle, Digital Signature, and Certificate

2.1 HTTPS Principle

HTTPS = HTTP + SSL/TLS, where SSL/TLS encrypts/decrypts data and HTTP transports it.

SSL (Secure Sockets Layer) provides security and data integrity.

TLS (Transport Layer Security) is the successor to SSL 3.0.

HTTPS handshake workflow:

The user enters an HTTPS URL; the browser connects to the server's port 443.

The server must have a digital certificate (self‑signed or issued by a CA) containing a public‑private key pair.

The server sends its certificate (including the public key) to the client.

The client validates the certificate; if valid, it generates a symmetric key and encrypts it with the server's public key.

The client sends the encrypted symmetric key to the server.

The server decrypts the symmetric key with its private key and uses it to encrypt data sent back to the client.

The server returns the encrypted data.

The client decrypts the data with the symmetric key.

2.2 Digital Signature and Certificate

A digital certificate consists of a public key, personal information, and a digital signature generated by a trusted Certificate Authority (CA) after hashing the data.

The certificate is the combination of the public key, personal information, and the digital signature.

3. TCP Connection States and TIME_WAIT

3.1 TCP Connection States

Client states: SYN_SEND, ESTABLISHED. Server states: SYN_RCVD, ESTABLISHED.

Three‑way handshake:

Client sends SYN, enters SYN_SEND.

Server replies with SYN‑ACK, enters SYN_RCVD.

Client sends ACK, both sides enter ESTABLISHED and data transfer can begin.

3.2 TIME_WAIT State

After the four‑step TCP termination, the side that initiates the close enters TIME_WAIT and waits for 2 MSL (Maximum Segment Lifetime) to ensure all stray packets are discarded before moving to CLOSED.

2 MSL guarantees that: The final ACK of the four‑step termination reaches the peer. Any retransmitted FIN from the peer can be received.

4. Virtual Memory vs. Physical Memory

4.1 What Is Virtual Memory?

Virtual memory provides each process with its own address space, which the operating system maps to physical memory via the MMU.

4.2 What Is Physical Memory?

Physical memory refers to the actual RAM modules; virtual memory may use a portion of the disk as a backing store.

4.3 Mapping Process

The Memory Management Unit (MMU) translates virtual addresses to physical addresses before the data reaches the memory bus.

5. Maximum Number of TCP Connections

Client side: limited by ip_local_port_range and the maximum of 65535 ports; multiple IPs can increase the limit. Server side: limited by available memory, as each idle connection consumes roughly 3.3 KB.

6. Eureka Architecture and Consistency

6.1 Eureka Components

Eureka Server – service registration and discovery, synchronizes state across servers (eventual consistency).

Service Provider – registers itself with Eureka.

Service Consumer – queries Eureka for service instances.

6.2 Clustered Eureka

Multiple Eureka nodes replicate data asynchronously, achieving eventual consistency.

6.3 Service Availability When Eureka Is Down

If the provider’s address does not change, clients can still call the service using cached information.

6.4 Comparison with Zookeeper

Zookeeper provides CP (consistency + partition tolerance) but may become unavailable during leader election.

Eureka provides AP (availability + partition tolerance) and prioritizes availability.

7. Hystrix Working Principle

Hystrix workflow includes command construction, execution (synchronous, asynchronous, hot/cold observables), cache checking, circuit‑breaker evaluation, thread‑pool or semaphore isolation, task execution, health metrics collection, fallback handling, and result return.

8. Zookeeper Consistency and Zab Protocol

Zab (Zookeeper Atomic Broadcast) ensures eventual consistency. It follows a leader‑follower model where the leader processes writes and broadcasts them to followers; a majority of followers must acknowledge for the write to be committed.

9. Zookeeper Leader Election

9.1 Startup Election

Servers vote using (myid, zxid); the server with the highest zxid (or myid if zxid ties) becomes the leader.

9.2 Runtime Election

When the leader crashes, remaining servers enter LOOKING state, vote, and the server with the highest zxid wins.

10. Algorithm: Longest Substring Without Repeating Characters

The problem can be solved with a sliding‑window technique. Java implementation:

public int lengthOfLongestSubstring2(String s) {
    int n = s.length();
    if (n <= 1) return n;
    int maxLen = 1;
    int left = 0, right = 0;
    Set<Character> window = new HashSet<>();
    while (right < n) {
        char rightChar = s.charAt(right);
        while (window.contains(rightChar)) {
            window.remove(s.charAt(left));
            left++;
        }
        maxLen = Math.max(maxLen, right - left + 1);
        window.add(rightChar);
        right++;
    }
    return maxLen;
}
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.

algorithmTCPeurekainterviewHTTPS
Full-Stack Internet Architecture
Written by

Full-Stack Internet Architecture

Introducing full-stack Internet architecture technologies centered on Java

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.