Master Ant Group Backend Interview: Java, MySQL, TCP, Zookeeper & Redis Secrets
This article walks through Ant Group's bonus structure, explains Java heap vs stack, String object creation, TCP packet issues, MySQL index types, B+‑tree advantages, database lock mechanisms, and shows how Zookeeper and Redis implement distributed coordination and locking, providing concrete code examples and best‑practice recommendations.
Recently Ant Group (Alipay) disclosed its year‑end bonus policy: performance score 3.5 is the threshold; below it bonuses may be reduced, above it bonuses increase, and salary adjustments follow similar rules.
Java Interview Questions
1. Difference between heap and stack
Stack stores local variables and method call contexts, while the heap stores object instances and arrays created with the
newkeyword.
Storage content : stack holds locals; heap holds objects/arrays.
Allocation & reclamation : stack frames are automatically allocated and freed; heap memory is reclaimed by the garbage collector.
Access speed : stack access is faster; heap access is slower due to dynamic allocation.
Size : each thread has a small stack (a few MB); the heap is shared and can be large.
Example code illustrating heap and stack usage:
public class Example {
private static String staticVar = "Static"; // heap (method area)
private int instanceVar = 10; // heap (object instance)
public void method() {
int localVar = 20; // stack
Object obj = new Object(); // reference on stack, object on heap
int[] arr = new int[5]; // reference on stack, array on heap
}
}2. Objects created by String a = new String("123")
Usually two
Stringobjects are created: one in the string constant pool and one on the heap. If the constant already exists, only the heap object is created.
public class StringObjectCreation {
public static void main(String[] args) {
String constantPoolStr = "123"; // constant pool
String heapStr = new String("123"); // heap
System.out.println(constantPoolStr == heapStr); // false
System.out.println(constantPoolStr.equals(heapStr)); // true
}
}3. Benefits of String immutability
Thread‑safety: multiple threads can share the same
Stringwithout synchronization.
Hash code caching improves performance in hash‑based collections.
The string constant pool reduces memory consumption.
TCP Sticky and Half Packets
Sticky packet occurs when multiple sends are concatenated in the same stream, e.g., "ABC" and "DEF" become "ABCDEF" on the receiver side.
Sender cause: writes smaller than socket buffer, TCP coalesces them.
Receiver cause: delayed reads cause multiple packets to be buffered.
Half packet happens when a large message is split across multiple TCP segments.
Sender cause: write larger than socket buffer.
Common solutions:
Fixed‑length messages.
Special delimiter characters (e.g., HTTP uses CRLF).
Custom message structure with a header indicating payload length.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.