Large amount of data - what is the best way to send them?

Vitek picture Vitek · Jan 2, 2009 · Viewed 10.5k times · Source

we have this scenario:

A server which contains needed data and client component which these data wants.

On the server are stored 2 types of data: - some information - just a couple of strings basically - binary data

We have a problem with getting binary data. Both sides are written in Java 5 so we have couple of ways....

Web Service is not the best solution because of speed, memory etc...

So, What would you prefer?

I would like to miss low level socket connection if possible...

thanks in advance

Vitek

Answer

Toby Hede picture Toby Hede · Jan 2, 2009

I think the only way to do LARGE amounts of data is going to be with raw socket access.

You will hit the Out of Memory issues on large files with most other methods.

Socket handling is really pretty straight forward in Java, and it will let you stream the data without loading the entire file into memory (which is what happens behind the scenes without your own buffering).

Using this strategy I managed to build a system that allowed for the transfer of arbitrarily large files (I was using a 7+ GB DVD image to test the system) without hitting memory issues.