Spring Batch Scaling - stellaxxx/batch GitHub Wiki

Scaling & Parallel

Reference Doc

  • Multi-threaded Step
  • Parallel Steps
  • Remote Chunking of Step
  • Partitioning a Step

Multi Threaded step

<step id="loading"> 
  <tasklet task-executor="taskExecutor" throttle-limit="20">...</tasklet>
</step>
  • Step executes by reading, processing and writing each chunk of items (each commit interval) in a separate thread of execution. commit interval ๋‹จ์œ„๋กœ item์„ ์ชผ๊ฐœ์„œ ์—ฌ๋Ÿฌ ์Šค๋ ˆ๋“œ์—์„œ step์ด ์ˆ˜ํ–‰๋จ.
  • there is no fixed order for the items to be processed, and a chunk might contain items that are non-consecutive compared to the single-threaded case. ์ˆœ์„œ ๋ณด์žฅ๋˜์ง€ ์•Š์Œ. ์‹คํ–‰๋˜๋Š” chunk ๋‚ด์˜ item ์—ญ์‹œ sequencialํ•˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Œ.
  • default throttle limit : 4

Partitioning

<step id="step1.master">
    <partition step="step1" handler="handler"/></step>

<bean class="org.spr...TaskExecutorPartitionHandler">
    <property name="taskExecutor" ref="taskExecutor"/>
    <property name="step" ref="step1" />
    <property name="gridSize" value="10" /></bean>
  • The Job is executing on the left hand side as a sequence of Steps, and one of the Steps is labelled as a Master. The Slaves in this picture are all identical instances of a Step, which could in fact take the place of the Master resulting in the same outcome for the Job. ํŠน์ •ํ•œ Step์— ๋Œ€ํ•ด M/S ๊ตฌ์กฐ๋กœ ๊ตฌ๋™ํ•˜๊ฒŒ ํ•จ. Master๊ฐ€ ๋œ step์€ slave๋“ค์— ๋Œ€ํ•ด ๊ตฌ๋™ ์‹œ๊ทธ๋„์„ ๋ณด๋‚ด๊ณ  ์‘๋‹ต๋งŒ ๋ฐ›์Œ.
  • The Slaves are typically going to be remote services, but could also be local threads of execution. Slave์˜ ๊ฒฝ์šฐ remote/local ๋ชจ๋‘ ๊ฐ€๋Šฅํ•จ.
  • PartitionHandler : simple RMI remoting, EJB remoting, custom web service, JMS, Java Spaces, shared memory grids (like Terracotta or Coherence), grid execution fabrics (like GridGain) <-- Remote์— ๋Œ€ํ•ด ์ง€์›๋˜๋Š” ๋ฐฉ์‹
  • gridSize : determines the number of separate step executions to create. default value is 10. ์ƒ์„ฑ๋˜๋Š” slave์˜ max count.
  • spring batch ensure that one execution of slave step per one job. ํ•œ JOB์˜ step์— ๋Œ€ํ•ด slave๊ฐ€ ํ•œ๋ฒˆ๋งŒ ์‹คํ–‰๋˜๋Š” ๊ฑธ ํ”„๋ ˆ์ž„์› ๋ ˆ๋ฒจ์—์„œ ๋ณด์žฅํ•จ.
  • Many articles recommand this solution for solving issues of batch scaling.

Remote partitioning

  • Spring Integration์„ ํ†ตํ•œ remote management. (batch integration)
  • Using MessageChannelPartitionHandler
  • remote slave๋“ค์€ ๊ฐ๊ฐ ItemReader, ItemWriter, ItemProcessor๋ฅผ ๊ฐ€์ง (๋™์ผํ•œ step์„ copy)
  • remote worker (remote partitionor)๋ฅผ ๊ตฌ์„ฑํ•˜๊ณ  step์— ๋Œ€ํ•œ ์‘๋‹ต์„ ๋ฐ›์Œ.
  • JMS, AMQP ๋กœ abstraction ์ œ๊ณตํ•จ. (๋”ฐ๋กœ ๋ฏธ๋“ค์›จ์–ด ์„ค์น˜ ์—†์ด ์„ค์ •๋งŒ์œผ๋กœ ๊ฐ€๋Šฅ...) spring batch remote partition
โš ๏ธ **GitHub.com Fallback** โš ๏ธ