Conversation
요약MongoDB 프로덕션 환경 설정을 평면 구조에서 중첩 구조로 재구성하고, 연결 풀 및 타임아웃 설정이 추가되었습니다. 인증 필드는 환경 변수에서 유지됩니다. 변경 사항
예상 코드 리뷰 소요 시간🎯 1 (Trivial) | ⏱️ ~3 분 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
backend/src/main/resources/application-prod.yml (1)
19-26: 운영 튜닝 값은 환경변수로 외부화하는 것을 권장합니다.현재 하드코딩이라 운영 환경별 조정 시 재배포가 필요합니다.
🔧 제안 변경안
# Connection Pool 설정 - max-pool-size: 30 - min-pool-size: 10 + max-pool-size: ${MONGO_MAX_POOL_SIZE:30} + min-pool-size: ${MONGO_MIN_POOL_SIZE:10} # timeout 설정 - max-wait-time: 2000 - socket-timeout: 3000 - connect-timeout: 1000 - max-connection-idle-time: 30000 + max-wait-time: ${MONGO_MAX_WAIT_TIME_MS:2000} + socket-timeout: ${MONGO_SOCKET_TIMEOUT_MS:3000} + connect-timeout: ${MONGO_CONNECT_TIMEOUT_MS:1000} + max-connection-idle-time: ${MONGO_MAX_CONN_IDLE_TIME_MS:30000}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@backend/src/main/resources/application-prod.yml` around lines 19 - 26, Replace the hard-coded pool and timeout values with environment-variable placeholders so production tuning doesn't require redeploy: change the keys max-pool-size, min-pool-size, max-wait-time, socket-timeout, connect-timeout, and max-connection-idle-time to use Spring property placeholders (e.g. ${ENV_VAR:default}) and pick sensible defaults; ensure the service reads these properties as before (no code changes needed) and document the expected ENV_VAR names for operators so env vars can override values per environment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@backend/src/main/resources/application-prod.yml`:
- Around line 19-26: The YAML uses unsupported MongoDB pool/timeout properties
(max-pool-size, min-pool-size, max-wait-time, socket-timeout, connect-timeout,
max-connection-idle-time) for Spring Boot 3.5.3 so replace them by either
setting connection options in the Mongo URI via spring.data.mongodb.uri (include
maxPoolSize, minPoolSize, connectTimeoutMS, socketTimeoutMS, authSource as query
params) or implement a MongoClientSettingsBuilderCustomizer bean to
programmatically set MongoClientSettings (configure connectionPoolSettings and
socketSettings/connectTimeouts) so the pool/timeouts take effect.
---
Nitpick comments:
In `@backend/src/main/resources/application-prod.yml`:
- Around line 19-26: Replace the hard-coded pool and timeout values with
environment-variable placeholders so production tuning doesn't require redeploy:
change the keys max-pool-size, min-pool-size, max-wait-time, socket-timeout,
connect-timeout, and max-connection-idle-time to use Spring property
placeholders (e.g. ${ENV_VAR:default}) and pick sensible defaults; ensure the
service reads these properties as before (no code changes needed) and document
the expected ENV_VAR names for operators so env vars can override values per
environment.
| max-pool-size: 30 | ||
| min-pool-size: 10 | ||
|
|
||
| # timeout 설정 | ||
| max-wait-time: 2000 | ||
| socket-timeout: 3000 | ||
| connect-timeout: 1000 | ||
| max-connection-idle-time: 30000 |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, find the Spring Boot version
if [ -f "pom.xml" ]; then
echo "=== pom.xml found ==="
grep -A 2 -B 2 "spring-boot" pom.xml | head -20
elif [ -f "build.gradle" ] || [ -f "build.gradle.kts" ]; then
echo "=== Gradle build file found ==="
grep -i "spring.*boot" build.gradle* 2>/dev/null | head -20
fiRepository: woowacourse-teams/2025-course-pick
Length of output: 60
🏁 Script executed:
# Also check if there's a parent pom or version file
find . -type f \( -name "pom.xml" -o -name "build.gradle*" -o -name "*.properties" \) | grep -E "(pom|build|version)" | head -20Repository: woowacourse-teams/2025-course-pick
Length of output: 162
🏁 Script executed:
# Check the backend build.gradle.kts for Spring Boot version
cat backend/build.gradle.kts | head -50Repository: woowacourse-teams/2025-course-pick
Length of output: 1405
🌐 Web query:
Spring Boot 3.5.3 MongoDB connection pool properties spring.data.mongodb max-pool-size socket-timeout
💡 Result:
In Spring Boot 3.5.x, Spring Boot’s spring.data.mongodb.* properties do not include dedicated “pool” or “socket timeout” fields (Boot mainly exposes spring.data.mongodb.uri, etc.). (docs.spring.io)
So, to set max pool size and socket timeout, use one of these approaches:
1) Put driver options on spring.data.mongodb.uri (recommended for simple config)
MongoDB Java driver supports these URI options:
- Pool size:
maxPoolSize(andminPoolSize) - Timeouts:
connectTimeoutMS,socketTimeoutMS(note:socketTimeoutMSis deprecated in newer driver docs in favor of client-level timeout) (mongodb.com)
Example (application.yml):
spring:
data:
mongodb:
uri: mongodb://user:pass@host:27017/mydb?maxPoolSize=50&connectTimeoutMS=10000&socketTimeoutMS=15000Defaults worth knowing: maxPoolSize defaults to 100 if not set. (mongodb.ac.cn)
2) Customize MongoClientSettings (best if you want “typed” config / advanced tuning)
Spring Boot builds the client using MongoClientSettings, and the MongoDB driver lets you set pool and socket settings there (e.g., socket read timeout). (mongodb.com)
Citations:
- 1: https://docs.spring.io/spring-boot/docs/3.2.10/reference/html/application-properties.html?utm_source=openai
- 2: https://www.mongodb.com/docs/languages/java/reactive-streams-driver/v5.4/connect-to-mongo/connection-options/?utm_source=openai
- 3: https://mongodb.ac.cn/docs/drivers/java/sync/current/fundamentals/connection/connection-options/?utm_source=openai
- 4: https://www.mongodb.com/docs/drivers/java/sync/current/connection/specify-connection-options/socket-settings/?utm_source=openai
🌐 Web query:
Spring Data MongoDB connection pool configuration spring.data.mongodb.uri options replicaSet maxPoolSize socketTimeoutMS
💡 Result:
In Spring Boot / Spring Data MongoDB you can pass MongoDB driver connection-string options directly via spring.data.mongodb.uri, and Spring Boot will apply them when it auto-configures MongoClientSettings. (docs.spring.io)
1) Configure via spring.data.mongodb.uri (replicaSet, pool, timeouts)
Example:
spring.data.mongodb.uri=mongodb://user:pass@host1:27017,host2:27017,host3:27017/mydb\
?replicaSet=rs0\
&maxPoolSize=200\
&minPoolSize=10\
&socketTimeoutMS=45000\
&connectTimeoutMS=10000Relevant URI options (driver-level):
replicaSet(replica set name) (mongodb.com)maxPoolSize/minPoolSize(connection pool sizing;maxPoolSizedefault is 100) (mongodb.com)socketTimeoutMS(socket read/write timeout; docs note default “never timeout”, driver-dependent) (mongodb.com)connectTimeoutMS(connect timeout) (mongodb.com)
Note: in the Java driver, pool sizing applies per server in the topology. (mongodb.com)
2) When URI options aren’t enough: customize MongoClientSettings
Spring Boot supports MongoClientSettingsBuilderCustomizer to fine-tune MongoClientSettings. (docs.spring.io)
Citations:
- 1: https://docs.spring.io/spring-boot/docs/3.2.10/reference/html/data.html
- 2: https://www.mongodb.com/docs/manual/reference/connection-string-options/
- 3: https://www.mongodb.com/docs/manual/reference/connection-string-options/
- 4: https://www.mongodb.com/docs/manual/reference/connection-string-options/
- 5: https://www.mongodb.com/docs/manual/reference/connection-string-options/
- 6: https://www.mongodb.com/docs/drivers/java/sync/v5.4/connection/specify-connection-options/connection-pools/?utm_source=openai
- 7: https://docs.spring.io/spring-boot/docs/3.2.10/reference/html/data.html
🏁 Script executed:
cat backend/src/main/resources/application-prod.ymlRepository: woowacourse-teams/2025-course-pick
Length of output: 901
Spring Boot 3.5.3에서는 지정한 MongoDB 풀/타임아웃 속성들이 지원되지 않습니다.
현재 설정의 max-pool-size, min-pool-size, max-wait-time, socket-timeout, connect-timeout, max-connection-idle-time은 Spring Boot 3.5.3에서 인식되지 않는 속성으로, 이들은 무시되고 PR의 목적(커넥션 풀 조정)이 전혀 반영되지 않습니다.
다음 중 하나의 방법으로 수정하세요:
-
spring.data.mongodb.uri를 사용 (권장):spring: data: mongodb: uri: mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}/${MONGO_DATABASE}?authSource=${MONGO_AUTH_DATABASE}&maxPoolSize=30&minPoolSize=10&connectTimeoutMS=1000&socketTimeoutMS=3000
-
MongoClientSettingsBuilderCustomizer빈 생성: 더 복잡한 설정이 필요한 경우 커스텀 빈을 작성하여MongoClientSettings를 직접 구성합니다.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@backend/src/main/resources/application-prod.yml` around lines 19 - 26, The
YAML uses unsupported MongoDB pool/timeout properties (max-pool-size,
min-pool-size, max-wait-time, socket-timeout, connect-timeout,
max-connection-idle-time) for Spring Boot 3.5.3 so replace them by either
setting connection options in the Mongo URI via spring.data.mongodb.uri (include
maxPoolSize, minPoolSize, connectTimeoutMS, socketTimeoutMS, authSource as query
params) or implement a MongoClientSettingsBuilderCustomizer bean to
programmatically set MongoClientSettings (configure connectionPoolSettings and
socketSettings/connectTimeouts) so the pool/timeouts take effect.
🛠️ 설명
📸 스크린샷 / 동영상
🔍 리뷰 요청사항
🔗 관련 이슈
Summary by CodeRabbit
개선 사항