0

I have a 7Gig file to send using JAVA NIO in 2 scenarios:

  • First is the client will be the one sending the file and I allocate the buffer to be 500MB it is fast it took only 30sec

  • Second is the server will be one sending the file and I still used 500MB as my buffer but it took me almost 30mins to send the file but when I decrease the buffer allocation It improves performance until I arrive to 1MB buffer allocation and it took me 1min to send the file.

But on the first scenario I also decrease it but it just decrease the performance on sending the file.

Can someone explain me why did this happen?

HungPV
  • 489
  • 6
  • 19

1 Answers1

-2

From the information posted, it might be the TCP's congestion avoidance/Nagle at work on server side. To check impact on speed, follow each approach and note the difference at each step.

  1. Disable Nagle via TCP_NO_DELAY
  2. Use scatter, gather.

Examples of both can be found here: http://bedrin.livejournal.com/207032.html

Alos
  • 2,657
  • 5
  • 35
  • 47
Ac11
  • 1
  • Wouldn't account for a 30::1 difference, and wouldn't account for anything unless he has inexplicable large gaps between sends. Scatter/gather I/O doesn't have anything to do with the Nagle algorithm, or with transferring a file either. The code in your link is invalid. – user207421 Jun 02 '16 at 00:02
  • Fair top level point, more information on question including code will lead better idea to why the 60x difference or 2x for smaller file. Scatter Gather IO will help use the server's core efficiently for NIO right? – Ac11 Jun 02 '16 at 17:58
  • Scatter-gather from what? It's a file. There is only one source of data. – user207421 Jun 02 '16 at 23:38
  • Why would scatter gather not help with single file? – Ac11 Jun 28 '16 at 18:35