gpt4 book ai didi

http - WebSphere 响应缓冲

转载 作者:可可西里 更新时间:2023-11-01 16:06:40 33 4
gpt4 key购买 nike

我正在向 WebSphere 的 response.getOutputStream() 写入一个大型响应(数百 Mb)。看起来 WebSphere 在将其提供给客户端之前总是将整个输出流数据存储在一些内部内存缓冲区中。所以我的 servet 处理(生成数据)在几秒钟内完成,而浏览器可能仍在下载半小时。在此期间,整个响应都保留在内存中。

是否可以避免这种缓冲?我宁愿有更多的 servlet 线程等待输出流,也不愿浪费 Gb 的内存。

我的 Web Sphere 版本是 8.5.0。

我试过设置内容长度和分块响应 - 都是一样的,仍在缓冲。我的 TCP 传输链设置默认使用 32 kb 响应缓冲区,但不知何故被忽略了。

最佳答案

同时在 WAS web 容器中找到了答案 custom properties .

By default, the web container uses asynchronous writes to write response data in chunks up to the response buffer size. For larger responses that are greater than the response buffer size, the web container continues to buffer response data into memory while waiting for an asynchronous write of a response data chunk to complete. This process can result in part of a large response held in memory, which can lead to high memory usage and potentially an out of memory error. An application server hang might also occur when a server is simultaneously processing more requests than web container-defined threads.

If the com.ibm.ws.webcontainer.channelwritetype property is set to sync, synchronous writing is used, otherwise asynchronous writing is used by default. With synchronous writing, response data are written synchronously in chunks of up to the value of responsebuffersize and no response data are buffered into memory while waiting for a synchronous write of a response data chunk to complete. As a result, the approximate maximum amount of response data that is held in memory is equal to the responsebuffersize multiplied by the number of web container threads. The maximum number of requests that can be processed simultaneously by the web container is limited by the number of web container threads. Additional requests are queued, waiting for a request that is in process to complete.

The responsebuffersize web container custom property defines the maximum amount of response data written by the web container in a single chunk, and is 32k by default. As a result, it is used to change the number of writes needed by the web container to send complete response data. However, if an application flushes response data, any response data held by the web container is immediately written irrespective of the responsebuffersize.

Use the following name-value pair to write chunks of data using synchronous writes.

com.ibm.ws.webcontainer.channelwritetype async

关于http - WebSphere 响应缓冲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21023280/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com