WebSphere响应缓冲 [英] WebSphere response buffering

查看:132
本文介绍了WebSphere响应缓冲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为WebSphere的response.getOutputStream()编写一个大型响应(数百Mb). 看来,Web Sphere在将其提供给技术人员之前,总是将整个输出流数据存储在某些内部内存缓冲区中.因此,我的服务端处理(生成数据)可以在几秒钟内完成,而浏览器可能仍在下载半个小时.在此期间,整个响应仍保留在内存中.

I'm writing a large response (hundreds of Mb) to the WebSphere's response.getOutputStream(). It appears that Web Sphere always store whole output stream data in some internal in-memory buffers before serving it to the cient. So my servet processing (generating data) finishes in seconds while browser may still be downloading it for half an hour. During that time whole response remains buffered in memory.

是否可以避免这种缓冲? 与浪费Gbs的内存相比,我更希望有更多的servlet线程在等待输出流.

Is it possible to avoid this buffering? I'd prefere more servlet threads waiting for the output stream than wasting Gbs of memory.

我的Web Sphere版本是8.5.0.

My Web Sphere version is 8.5.0.

我尝试设置内容长度和分块响应-都是一样的,仍然在缓冲. 我的TCP传输链设置默认为32 kb的响应缓冲区,但是以某种方式被忽略.

I've tried setting content length and chunked response - it's all the same, still buffering. My TCP transport chain settings are default with 32 kb response buffer, but it is ignored somehow.

推荐答案

与此同时,在WAS Web容器中找到了答案

Meanwhile the answer was found among WAS web container custom properties.

默认情况下,Web容器使用异步写入以最大为响应缓冲区大小的块形式写入响应数据.对于大于响应缓冲区大小的较大响应,Web容器将继续将响应数据缓冲到内存中,同时等待对响应数据块的异步写入完成.此过程可能会导致部分较大的响应保留在内存中,这可能导致较高的内存使用率并可能导致内存不足错误.当服务器同时处理比Web容器定义的线程更多的请求时,应用程序服务器也可能会挂起.

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.

如果com.ibm.ws.webcontainer.channelwritetype属性设置为sync,则使用同步写入,否则默认使用异步写入.使用同步写入时,响应数据以最大为responsebuffersize值的块的形式被同步写入,并且在等待响应数据块的同步写入完成时,没有响应数据被缓冲到内存中.结果,保存在内存中的响应数据的最大数量大约等于响应缓冲区大小乘以Web容器线程数. Web容器可以同时处理的最大请求数受Web容器线程数的限制.其他请求排队,等待正在处理的请求完成.

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.

responsebuffersize Web容器自定义属性定义Web容器在单个块中写入的最大响应数据量,默认值为32k.结果,它用于更改Web容器发送完整响应数据所需的写入次数.但是,如果应用程序刷新了响应数据,则无论响应缓冲区的大小如何,都会立即写入Web容器保存的任何响应数据.

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异步

这篇关于WebSphere响应缓冲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆