Explain CAP, indexing, locks, and logs
Company: Bytedance
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Technical Screen
You are interviewing for a general software engineering role. Answer the following conceptual questions:
1. What does the CAP theorem state in distributed systems, and what trade-offs do real systems make in practice?
2. What is a database index? Compare common index types such as B-tree and hash indexes, and discuss their effects on read performance, write performance, storage cost, and query patterns.
3. How do concurrency control and locks work in databases or multithreaded systems? Explain shared vs. exclusive locks, deadlocks, and common isolation problems such as dirty reads, non-repeatable reads, and phantom reads.
4. What is the purpose of logs in software systems and databases? Distinguish between application logs, audit logs, and database recovery logs, and explain how logging helps with debugging, observability, and crash recovery.
Quick Answer: This question evaluates knowledge of distributed systems concepts (CAP theorem), database internals (index types and logging), and concurrency control mechanisms (locks and isolation anomalies) within the Software Engineering Fundamentals domain.