Netflix / zuul

Zuul is a gateway service that provides dynamic routing, monitoring, resiliency, security, and more.
Apache License 2.0
13.52k stars 2.38k forks source link

Allow streaming of multipart requests/response in Zuul proxy #414

Open amitabhprasad opened 6 years ago

amitabhprasad commented 6 years ago

When calling the service directly, the download streams fine, however when calling through Zuul it seems to download the file to zuul first and then stream it from there. This becomes for large file downloads especially when running in GB's, file download starts only after entire file is read in Zuul filter, this frces us to use really large heap size and other performance issues. We debugged the code and looks like problem happens during

private void writeResponse(InputStream zin, OutputStream out) throws Exception { byte[] bytes = buffers.get(); int bytesRead = -1; while ((bytesRead = zin.read(bytes)) != -1) { out.write(bytes, 0, bytesRead); } } in org.springframework.cloud.netflix.zuul.filters.post.SendResponseFilter

That loops over untill entire file is read. I tried sending the request as /zuul/... but nothing helped, please let me know if there is a way out ? we are totally stuck.

spencergibb commented 6 years ago

No need to cross post. Already discussing in the proper place here https://github.com/spring-cloud/spring-cloud-netflix/issues/2773