Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to write a file as fast as I can through a buffered FileChannel similar to a BufferedOutputStream. I am wondering what is the optimum chunk of data I should use per write call to maximize bandwidth? I am on Ubuntu Linux.

share|improve this question

closed as not a real question by Michael Hampton, Chopper3, HopelessN00b, Basil, Iain Sep 26 '12 at 16:48

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
what protocols are involved? –  Chopper3 Sep 26 '12 at 16:02
    
Protocols? This is disk I/O on Linux Ubuntu. –  chrisapotek Sep 26 '12 at 16:06
    
* sigh * and they're attached to the machine via....? –  Chopper3 Sep 26 '12 at 16:10
    
sorry, as you can see I am not a hardware guy hehehe... man, that regular socket they have nowadays on the motherboard... i forgot the name, ISO? I remember in the distant past they had SCSI but that is gone, right? –  chrisapotek Sep 26 '12 at 16:16
    
Ok, well you just made sure this question is unanswerable sorry, we can't give you even a wild guess without even that basic information. –  Chopper3 Sep 26 '12 at 16:17

1 Answer 1

There is no such thing as a "one size fits all" perfect answer on a question like this. This sort of thing is impossible to predict.

It depends on the disk, controller, CPU, application, OS, other system load, kernel version, filesystem used and probably about a dozen other things I can't quickly remember right now.

Often bigger is better, but there usually is a point of diminishing returns.
Trial and error is, for any given system, the only way to say for sure.

Even if you figure this out for your development environment, you will have to do it all again for every other system on which the software needs to run.

Best to do some limited testing and then pick a "reasonable" value that performs "well enough" on the majority of intended target systems.

share|improve this answer
    
Thanks, Tonny. If you were to guess or pick a value without doing much research for your Linux system, what would that value be? Just your personal feeling about this value. A rough guess :) –  chrisapotek Sep 26 '12 at 16:05
    
I would use 64K and 128K and see which one works best. On a raid or SSD ALWAYS use a multiple of the stripe-size (raid) or native block-size (SSD). Smaller really can kill performance. –  Tonny Sep 26 '12 at 16:09
    
I am on a disk hard drive here... no SSD... for now... :) –  chrisapotek Sep 26 '12 at 16:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.