I know that very similar questions were asked before. But I don’t think that the solutions that I found in google / stackoverflow suit me.
I started writing some web services using Scala / Spray, and it seems the best way to send large files without consuming large memory resources is to use stream sorting. This way, Spray will send http fragments. Two questions:
Is it possible to send a file without using HTTP fragments and without reading the entire file in memory?
AFAIK akka.io processes only one record at a time, which means that it can buffer one record until it is completely transferred to the O / S kernel. Is it possible to tell Spray for each HTTP response the length of the content? After that, Spray will request new data (via akka messages) until the completion of the entire length of the content. For example, I indicate that my content is 100 bytes long. Spray sends a message requesting data for my actor, I provide 50 bytes. When this data is transferred to O / S, the spray sends another message requesting new data. I provide the remaining 50 bytes ... the answer is complete.
source
share