Yes, the help of multiple files on multiple disks should help, and if no one else writes these disks at the same time, performance should scale linearly with the number of disks until I / O becomes a bottleneck. You can also try a couple more optimizations to increase productivity even more.
If you create huge files and the disk just can't keep up, you can use GZIPOutputStream to compress the output, which in turn will reduce the number of disk I / O. For nonrandom text, you can usually expect a compression ratio of at least 2x-10x.
//...background multi-threaded process keeps building the queue.. OutputStream out = new FileOutputStream("foo.txt",true); OutputStreamWriter writer = new OutputStreamWriter(new GZIPOutputStream(out)); BufferedWriter bufferWriter = new BufferedWriter(writer); while(!queue_of_stuff_to_write.isEmpty()) { String data = solutions.poll().data; bufferWriter.newLine(); bufferWriter.write(data); } bufferWriter.close();
If you output regular (i.e., repeating) data, you can also consider switching to another output format - for example, binary data encoding. Depending on the structure of your data, it may be more efficient to store it in a database. If you are outputting XML and really want to stick with XML, you should study the Binary XML format , such as EXI or Fast InfoSet.
source share