سؤال

val iter = (1 to 1000).iterator.map { i =>
  accountService.getAccountDataSyncList(i, 200)
}.takeWhile(_.nonEmpty).flatten.map(acc => produceReport(acc.bindAccount))
Future.sequence(iter.toList)

I iterate over 1 to 1000 pages of accounts and create at most 200 * 1000 futures,

Will this use a lot of memory ?

Is this create all task as future then forget pattern performance friendly ?

هل كانت مفيدة؟

المحلول

How much memory it will take depends on how much memory of your each callback costs and how many threads you specified to execute the futures.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top