Choosing YAML over .properties files has essentially no impact on runtime performance, since both are parsed once at application startup; the real difference is in readability and how well each format expresses nested configuration.
Key Points: • Both formats are read and converted into the same internal configuration model once at startup, so there's no meaningful difference in request-time performance. • YAML naturally supports nested, hierarchical structures and lists, which makes complex configuration easier to read than deeply dotted property keys. • .properties files are flatter, using dot-separated keys, which some teams prefer for simplicity and for avoiding YAML's whitespace sensitivity. • YAML's indentation-based syntax can be more error-prone, since a misplaced space silently changes the structure rather than throwing an obvious error. • Spring Boot supports both formats interchangeably through its PropertySource abstraction, so the choice comes down to team preference and configuration complexity.
Example: A datasource configuration with several nested properties (url, username, pool settings) reads more clearly as a nested YAML block than as a series of flat, dot-separated property keys, even though Spring Boot resolves both to the exact same values.
Code Example:
# application.yml
spring:
datasource:
url: jdbc:mysql://localhost/app
username: appuser# application.properties
spring.datasource.url=jdbc:mysql://localhost/app
spring.datasource.username=appuserInterview Tip: A concise interview answer is:
"There's no real performance difference between YAML and properties files, since both are parsed once at startup. YAML just represents nested configuration more cleanly, while properties files are flatter and less prone to whitespace-related mistakes, so the choice is really about readability, not speed."