Spring Boot

Performance Optimization

Performance optimization: profiling, caching, lazy loading, pagination, connection pooling, DB indexing

30 interview questions·
Senior
1

What is HikariCP in the context of Spring Boot?

Answer

HikariCP is the default connection pool manager in Spring Boot since version 2.0. It offers exceptional performance through an optimized implementation (low overhead, efficient concurrency management) and is widely considered the fastest connection pool on the market. Spring Boot uses it automatically when spring-boot-starter-data-jpa or spring-boot-starter-jdbc is present in dependencies.

2

Which HikariCP parameter defines the maximum number of connections in the pool?

Answer

The maximumPoolSize parameter defines the maximum number of connections (active and idle) that HikariCP will maintain in the pool. The recommended value by HikariCP is generally based on the formula: connections = ((core_count * 2) + effective_spindle_count), often between 10 and 20 for typical applications. A value too high can saturate the database, while a value too low can cause connection waits.

3

What is the difference between maximumPoolSize and minimumIdle in HikariCP?

Answer

maximumPoolSize defines the total maximum number of connections (active and idle) in the pool, while minimumIdle defines the minimum number of idle connections that HikariCP maintains permanently. HikariCP recommends not setting minimumIdle and letting maximumPoolSize manage the pool (default behavior: minimumIdle = maximumPoolSize), as the pool automatically adjusts based on load to optimize performance.

4

What is the formula recommended by HikariCP to calculate maximumPoolSize?

5

Which HikariCP parameter controls the maximum wait time to obtain a connection from the pool?

+27 interview questions

Master Spring Boot for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free