# Start consuming Source(s) elements before Sink pull (Archive.zip flow)

**URL:** <https://discuss.akka.io/t/start-consuming-source-s-elements-before-sink-pull-archive-zip-flow/10311>\
**Category:** Akka Streams & Alpakka\
**Tags:** alpakka, streams\
**Created:** [May 13, 2023, 9:09am UTC](https://discuss.akka.io/t/start-consuming-source-s-elements-before-sink-pull-archive-zip-flow/10311 "2023-05-13T09:09:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gael-ft](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/gael-ft/32/3024_2.png) [@gael-ft](https://discuss.akka.io/u/gael-ft)\
**Post date:** [May 13, 2023, 9:09am UTC](https://discuss.akka.io/t/start-consuming-source-s-elements-before-sink-pull-archive-zip-flow/10311/1 "2023-05-13T09:09:40Z")

</div>

Hello,

I’m using Alpakka `Archive.zip` flow.  
(As reminder, here is the signature of the Flow is `Flow[(ArchiveMetadata, Source[ByteString, Any]), ByteString, NotUsed]`).

The flow is consuming inner sources one by one.  
I would like to start consuming others inner sources in order to speed up the process (at least until the buffer reach a given size).

Code example:

```scala
val objectKeys: Seq[String] = ...

val zipObjects: Seq[(ArchiveMetadata, Source[ByteString, NotUsed])] = objectKeys.map { obj =>  
  val filename = trimPrefixFromKey(obj)
  ArchiveMetadata(filename) -> S3.download("myBucket", obj)
    .flatMapConcat {  
      case Some((dataSource, _)) =>
        dataSource
          .prefixAndTail(1)  
          .flatMapConcat { case (head, tail) =>  
            Source(head)  
              .wireTap(_ => logger.info("Start consuming {}", obj))  
              .concat(tail)  
          }
          /* How to start consuming let's say 50 MB ??? */ 
      case None => Source.single(ByteString.empty)
  }  
}

val s3Sink: Sink[ByteString, Future[MultipartUploadResult]] = ...

val uploadResultFuture = Source(zipObjects)  
  .via(Archive.zip())   
  .runWith(s3Sink)

```

---

<div class="post-metadata">

**Author:** ![liewhite](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/liewhite/32/2955_2.png) [@liewhite](https://discuss.akka.io/u/liewhite)\
**Post date:** [May 18, 2023, 10:42am UTC](https://discuss.akka.io/t/start-consuming-source-s-elements-before-sink-pull-archive-zip-flow/10311/2 "2023-05-18T10:42:43Z")

</div>

Same question

---

<div class="post-metadata">

**Author:** ![gael-ft](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/gael-ft/32/3024_2.png) [@gael-ft](https://discuss.akka.io/u/gael-ft)\
**Post date:** [May 23, 2023, 1:11pm UTC](https://discuss.akka.io/t/start-consuming-source-s-elements-before-sink-pull-archive-zip-flow/10311/3 "2023-05-23T13:11:11Z")

</div>

Created a ticket (and PR) =\> [Add supports for Byte-Range Fetches when downloading from S3 · Issue #2981 · akka/alpakka · GitHub](https://github.com/akka/alpakka/issues/2981)

Buffering as described above is pointless.  
Preferred improving download speed directly.
