-
Notifications
You must be signed in to change notification settings - Fork 2
Feat/relay server to spring batch #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
861cefc to
8215dfc
Compare
8215dfc to
1ba6a6c
Compare
flab-true
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코멘트 남깁니다. :-)
| private val queue = ConcurrentLinkedQueue<ClaimedRow>() | ||
|
|
||
| // 배치 로딩 Lock (한 번에 한 스레드만 로딩) | ||
| private val loadLock = ReentrantLock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
락 경쟁을 하고 있는데요. 병목이 발생할 수 있을 것 같다는 생각입니다.
Reader 에서 Lock을 걸어 중복 조회를 막는 경우라면, Partitioning을 사용하는 방안은 어떤가요?
| } | ||
|
|
||
| // Queue가 비었으면 새 배치 로드 시도 | ||
| return loadLock.withLock { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
멀티스레드 Step 이라도 SynchronizedItemStreamReader를 사용하면, Reader 호출을 한번에 한 스레드만 하게 만들 수 있는 것 같습니다. 하지만 Partitioning으로 입력 자체를 나누는 방법이 더 효과적일 것 같다는 생각입니다.
| AND (next_retry_at IS NULL OR next_retry_at <= :now) | ||
| AND attempt_count < :maxAttempts | ||
| ORDER BY next_retry_at NULLS FIRST, created_at | ||
| FOR UPDATE SKIP LOCKED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
트랜잭션에서 SKIP LOCKED 을 사용하는 의도는 좋은 것 같습니다. 대기가 줄고 교착 가능성이 낮아지는 효과가 있을 것 같네요.
| */ | ||
| val fixedDelayMs: Long = 1000, | ||
| /** DB 조회 배치 크기 */ | ||
| val chunkSize: Int = 500, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chunksize가 500인데요. 100,200,300 설정에서 단일 스레드와 현재 멀티 스레드 방식의 속도를 확인해 보시면 좋겠습니다.
transfer-relay 멀티 인스턴스가 아닌, 단일 스레드에서 multiThread 방식으로 개선