Inside Xiaomi Car Interviews: SpringBoot, MySQL Tuning & Distributed Transactions
This article shares Xiaomi car interview salary data, explains SpringBoot's startup process, discusses Spring IOC/AOP benefits, offers MySQL table creation and indexing tips, compares lock types, reviews common design patterns, outlines network device differences, and summarizes distributed transaction solutions including Seata.
After the launch of Xiaomi's SU7 Ultra, the author became curious about the salary packages for Xiaomi automotive software positions and collected data from OfferShow, showing entry‑level offers of 22k–24k RMB per month (15‑month total, about 330k–360k RMB annually) in Beijing.
SpringBoot Startup Process
SpringBoot simplifies configuration and embeds Tomcat, allowing rapid web application development. A typical entry point is:
<code>@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}</code>The startup sequence includes creating a
SpringApplicationinstance, initializing listeners, loading the configurable environment, creating the application context, and finally refreshing the Spring container to instantiate beans and apply auto‑configuration.
Spring IOC and AOP
IOC decouples object dependencies by letting the Spring container manage creation and injection, improving maintainability and testability. Without IOC, developers must manually instantiate dependent objects with
new, leading to tight coupling.
<code>public class UserService {
private UserDao userDao = new UserDao();
public void doSomething() {
// use userDao
userDao.saveUser();
}
}</code>AOP separates cross‑cutting concerns such as logging, transaction management, and security into aspects, reducing code duplication and enhancing reuse.
<code>public void doSomething() {
System.out.println("enter doSomething");
// business logic
System.out.println("exit doSomething");
}</code>MySQL Table Design and Indexing
Choose appropriate data types (e.g.,
TINYINTfor small integers,
CHARfor fixed‑length strings,
VARCHARfor variable length).
Limit the number of columns to reduce storage and improve query performance.
Consider denormalization when it balances read efficiency.
Create indexes on columns frequently used in
WHERE,
JOIN, or
ORDER BYclauses, avoiding over‑indexing.
MySQL Lock Types
Lock Type
Scope
Statement
Description
Global Lock
Entire database
flush tables with read lockDatabase becomes read‑only; all write operations block.
Table Lock
Single table
lock tablesPrevents other sessions from reading or writing the locked table.
Metadata Lock (MDL)
Table
Automatic
Read lock for CRUD, write lock for DDL to protect schema changes.
Intent Lock
Table
Automatic on DML
Marks intention to acquire row‑level locks, speeding lock checks.
Row Lock
Single record
InnoDB automatic
S (shared) and X (exclusive) locks ensure read/write mutual exclusion.
Gap Lock
Record gap
InnoDB automatic (REPEATABLE READ)
Prevents phantom reads.
Next‑Key Lock
Record + gap
InnoDB automatic
Combination of record and gap lock.
Common Design Patterns
Singleton – ensures a single instance.
Factory – abstracts object creation.
Strategy – encapsulates interchangeable algorithms.
Decorator – adds responsibilities dynamically.
Proxy – controls access to a target object, often adding logging or security.
Network Device Differences
Switches operate at the data‑link layer, forwarding frames based on MAC addresses.
Routers operate at the network layer, forwarding packets based on IP addresses using routing tables.
Distributed Transaction Solutions
Solution
Consistency
Performance
Complexity
Use Cases
2PC
Strong
Low
Medium
Traditional DB, XA
3PC
Strong
Medium‑Low
High
High‑concurrency, less strict consistency
TCC
Eventual
High
High
High‑throughput e‑commerce
Saga
Eventual
Medium
High
Long‑running business processes
Message Queue
Eventual
High
Medium
Event‑driven architectures
Local Message Table
Eventual
Medium
Low
Async notifications
Seata Framework Overview
AT mode – default, uses automatic rollback logs for relational databases.
TCC mode – requires explicit Try/Confirm/Cancel methods.
SAGA mode – splits long transactions into short ones with compensating actions.
For further learning, the author recommends the open‑source mall project (SpringBoot 3 + Vue) and its microservice variant mall‑swarm , both accompanied by video tutorials.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
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.