I have an api into which ill get quite a few requests in https. Since its restful, each time the api is sent , it requires a full ssl handshake. On enabling http-keepalive , the latency of the request is reduced greatly (first request takes same time, but subsequent requests are as fast as http).
Now, I was experimenting with amazon's elb (I will also use cloud front). My question is, how will keep alive work in the same setup , where the request coming from a client can be routed to different machines randomly ?
Or is it not possible at all to prevent an ssl handshake each time a request is made ?
Yes, AWS ELB will re-use open connections to backends when possible, while still trying to distribute the load as it's configured to do so. AWS even recommends this as a best practice in their docs:
ETA: Note that the ELB doesn't actually hand a client connection off to a back-end. All requests between the client and the backend still get passed through the ELB in both directions. You can either have the ELB terminate SSL from the client (assuming that's HTTPS) and then creates or re-uses its own HTTPS connection (if configured to do so) to the backend, or you can choose to terminate SSL at the backend only.