Java optimal chunk size for file downloads






















Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. How to determine ideal chunk size for file writing? Ask Question. Asked 1 year, 1 month ago.

Active 1 year, 1 month ago. Viewed 1k times. Improve this question. Is this a one off for your current system or are you writing code that will need to discover this ideal chunk size once deployed? Depending precisely how you write to this file, the language and libraries you use may already be buffering the actual writes when you 'flush' to file.

We deploy our application to a server with a dual-core CPU:. But this example is oversimplified. If you have different classes of tasks it is best practice to use multiple thread pools, so each can be tuned according to its workload.

At this step we can get an optimal thread pool size, we know our theoretical upper bounds and we have some metrics in place. But how does the number of parallel workers change the latency or throughput? Little's law can be used to answer this question. The law says that the number of requests in a system equals the rate at which they arrive, multiplied by the average amount of time it takes to service an individual request.

We can use this formula to calculate how many parallel workers there should be to handle a predefined throughput at a particular latency level. I just tried the available method and it returned zero, so I think I'm gonna skip using that as you suggested.

I am working with memory constrained devices so I think I will try to keep the buffer small, maybe or I too, noticed a big performance improvement going from reading very small chunks to somewhat larger ones. I was mostly curious about the optimal size, I'm not sure it makes a big difference at a certain point, either.

Regards, Drew. You showed up just in time for the waffles! And this tiny ad:. Boost this thread! So again, without knowing what you're doing, it's impossible to know what you might be doing wrong. CP, BaseFont. William Brogden. Looks to me like it is the PDF combining that uses all the memory, not the servlet output stream.

Now live: A fully responsive profile. Reducing the weight of our footer. Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled.



0コメント

  • 1000 / 1000