You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tim Whittington <ti...@apache.org> on 2011/05/16 00:30:04 UTC

Re: Canceling Download on IIS7 with ISAPI Redirector 1.2.31 causes 100% CPU usage

This sounds like https://issues.apache.org/bugzilla/show_bug.cgi?id=50839

If you can capture a TRACE level log form the Tomcat Connector
(configure in isapi_redirect.properties) and attach it to the bug,
I'll take a look.

cheers
tim

On Sun, May 15, 2011 at 1:20 AM, eurotrans-Verlag
<ve...@t-online.de> wrote:
> Hello everybody,
>
> I stumbled upon a strange problem with the ISAPI Redirector 1.2.31 on
> Windows Server 2008 SP2 (32 bit) with IIS 7.0. The problem is, that when a
> Servlet is generating lots of data (e.g. 200 MB) and a user downloads it
> over the Isapi Redirector/IIS7, and cancels the download, the IIS Worker
> process (w3wp.exe) will have 100% CPU usage for about 30 seconds. However if
> the download is completed normally (not canceled), everything is fine and
> the CPU usage will not go up that far.
>
> The exact Components used are:
> Windows Server 2008 SP2 (32 bit) with IIS 7.0,
> Sun JDK 1.6.0_25,
> Tomcat 7.0.14,
> ISAPI Redirector 1.2.31.
>
> I could reproduce the problem with a clean install of these components.
>
> To reproduce:
> 1. Install Tomcat and the ISAPI Redirector on a Windows Server 2008 SP2 IIS
> 7.0 system, as described in the Tomcat Connectors Documentation
> (The problem occurs with both settings of "enable_chunked_encoding", "true"
> and "false").
>
> 2. Create a Servlet or JSP that produces some huge amount of random data,
> for example:
>
> @WebServlet("/DownloadServlet")
> public class DownloadServlet extends HttpServlet {
>        protected void doGet(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
>                response.setContentType("application/x-msdownload");
>                OutputStream out = response.getOutputStream();
>                Random r = new Random();
>                byte[] content = new byte[1024];
>                for (int i = 0; i < content.length; i++)
>                        content[i] = (byte) (r.nextFloat() * 256);
>                for (int i = 0; i < 200000; i++)
>                        out.write(content);
>                out.close();
>        }
> }
>
> 3. Request the Servlet or JSP through the IIS port with a browser. After
> some seconds, cancel the download.
>
> 4. One thread of the IIS Worker Process (w3wp.exe) will have 100% CPU usage
> for some time (about 30 seconds), before it normalizes to 0%.
> Note that is does not happen every time. Sometimes you will have to repeat
> starting and canceling the download until the problem occurs.
>
> 5. In the ISAPI log, following lines are logged ("log_level"="info"):
> [Sat May 14 14:48:55.654 2011] [3508:3560] [error]
> isapi_write_client::jk_isapi_plugin.c (1210): WriteClient failed with 995
> (0x000003e3)
> [Sat May 14 14:48:55.654 2011] [3508:3560] [info]
> ajp_process_callback::jk_ajp_common.c (1885): Writing to client aborted or
> client network problems
> [Sat May 14 14:48:55.654 2011] [3508:3560] [info]
> ajp_service::jk_ajp_common.c (2543): (worker1) sending request to tomcat
> failed (unrecoverable), because of client write error (attempt=1)
> [Sat May 14 14:48:55.669 2011] [3508:3560] [info]
> HttpExtensionProc::jk_isapi_plugin.c (2217): service() failed because client
> aborted connection
>
> These lines are logged immediately after the client cancels the connection
> (not after the CPU usage of w3wp.exe goes down).
>
> The worker process continues normally after the CPU usage went down.
>
> However, if one would do this repeatedly, it could enable DoS attacks,
> couldn't it?
> What would cause these excessive CPU usages of the IIS worker process when
> the user cancels the download?
>
>
> Thanks for your help.
>
> Konstantin Preißer
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Canceling Download on IIS7 with ISAPI Redirector 1.2.31 causes 100% CPU usage

Posted by Tim Whittington <ti...@apache.org>.
It looks like this is a regression in 1.2.31 - the socket shutdown
code that drained the response message from the AJP socket before
closing it was mis-counting the bytes read, causing a CPU busy loop
until it hit a 30 second cap on lingering byte reads.

I've committed a fix for 1.2.32 and also capped the amount of data
that the socket shutdown will read to 32k, and the total time to drain
the socket to 2s.

cheers
tim

On Mon, May 16, 2011 at 1:09 PM, verlag.preisser@t-online.de
<ve...@t-online.de> wrote:
> Hi Tim,
>
>> This sounds like
>> https://issues.apache.org/bugzilla/show_bug.cgi?id=50839
>> If you can capture a TRACE level log form the Tomcat Connector
>> (configure in isapi_redirect.properties) and attach it to the bug,
>> I'll take a look.
>>
>> cheers
>> tim
>
> Thanks! I will attach a Trace level log from the Redirector there.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Canceling Download on IIS7 with ISAPI Redirector 1.2.31 causes 100% CPU usage

Posted by "verlag.preisser@t-online.de" <ve...@t-online.de>.
Hi Tim,

> This sounds like
> https://issues.apache.org/bugzilla/show_bug.cgi?id=50839 
> If you can capture a TRACE level log form the Tomcat Connector
> (configure in isapi_redirect.properties) and attach it to the bug,
> I'll take a look.
> 
> cheers
> tim

Thanks! I will attach a Trace level log from the Redirector there.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org