JDK-2169851 : Slow performance using HttpURLConnection for upload
  • Type: Backport
  • Backport of: JDK-6720866
  • Component: core-libs
  • Sub-Component: java.net
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2008-11-21
  • Updated: 2010-04-04
  • Resolved: 2009-01-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 7
5.0u17-rev b09Fixed 7Fixed
Comments
EVALUATION PROBLEM CAUSE: java.net.HttpURLConnection uses sun.net.www.httpChunkedOutputStream which sends data in chunks which size is set with java.net.HttpURLConnection.setChunkedStreamingMode(int size). The problem with the current implementation is that the chunk headers are being buffered in the lower 8k buffer and then if there is a write of larger than 8K the lower buffer needs to be flushed first then write the chunk data, then the footer will be buffered again in the lower 8k buffer, and subsequently flushed. As a result java.io.BufferedOutputStream calls native SocketWrite() more then once to send one data chunk. This has an impact on performance. SOLUTION: Buffering the whole chunk (header,data,footer) in ChunkedOutputStream would allow to write the complete chunk in one go, if it is greater than 8K then it will by pass the lower buffer. FIX DESCRIPTION: The main idea is that write() method collects data in a buffer. When a size of collected (stored) data reaches preferredChunkSize the data (as a complete one chunk) get flushed to an underlying stream in one go. So internal buffer of ChunkedOutputStrem never needs to be re-allaocated to store more then a one data chunk and that's why CR 6526165 and CR 6631048 problem doesn't exist in this version of ChunkedOutputStream.
21-11-2008