Search code examples
amazon-web-servicesspring-bootamazon-elbpcf

AWS Loadbalancer terminating http call before complete http response is sent


We are making a REST call to a spring boot application hosted in PCF environment. There is an AWS load balancer in front of our application to handle traffic management. We are consuming the http request in a streaming manner using apache file upload library [https://commons.apache.org/proper/commons-fileupload/]. On processing the request, we are immediately sending the response back without waiting for the whole request to arrive. The size of the http request is normally large in the range of 100 MB.

This implementation works fine without AWS load balancer in between. When AWS load balancer is present, it terminates the http call after few bytes of response has been sent. If we defer the response sending till whole request is received in the server side, request go through without any failures. If the size of the http request is small, then also implementation works fine.

Any idea why AWS load balancer terminates the http call, if we start sending the http response before receiving full http request.


Solution

  • I assume in your case you are using an application load balancer, however I'd recommend in your case is to use network load balancer, classic may work too as they provide more transparency to your requests than application locad balancer, also its recommended for API implementations

    if this is still not solving your case, consider implementing HA proxy LB

    https://www.loadbalancer.org/blog/transparent-load-balancing-with-haproxy-on-amazon-ec2/