« Previous Next »

Thread: FastCGI terminating using POST method

Last post 01-06-2009 3:51 PM by Mike Trader. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 01-06-2009, 1:46 AM

    FastCGI terminating using POST method

     The concept of fast CGi is that the process outlives the request. This is very usefull for situations where a number of requests are required to complete a larger process.

    In this case, I am uploading a larger file (10MB) in chunks. If I tried to do a single POST I would run into the SndTo  TIMEOUT:

    I am using WinHTTP (not WinInet) which supports 4 timeout settings:

    ResolveTO   ' resolving a host name                      
    ConnectTO  ' establishing a communication socket        
    SndTo         ' Total running time for sending data        
    ReceiveTO  ' Total running time for receiving any data
     

    So by breaking the larger file up into 64k chunks I can send them one at a time. Each chunk is a complete HTTP request and response by the client and is serviced by the FastCGI executable.

    But there is a problem. For some reason, the FastCGI executable is terminated after processing each chunk IF the chunk size is larger than about 2500 bytes (determined experimentally)

    To test this, I wrote a simple client that issues n WinHTTP POST request's in a row, each with x bytes of POST data. The results are:

     

    --------  01-05-2009  22:28:17  ---------
     1 Bytes sent= 4000
    FastCGI Reply: Count= 1, ContentLen= 4000

     2 Bytes sent= 4000
    FastCGI Reply: Count= 1, ContentLen= 4000

     3 Bytes sent= 4000
    FastCGI Reply: Count= 1, ContentLen= 4000

     

    Notice the Count variable is allwys 1 because the FastCGi termination IS NOT outliving the request.

    When I lower the number of bytes:

    --------  01-05-2009  22:42:28  ---------
     1 Bytes sent= 2000
    FastCGI Reply: Count= 1, ContentLen= 2000

     2 Bytes sent= 2000
    FastCGI Reply: Count= 2, ContentLen= 2000

     3 Bytes sent= 2000
    FastCGI Reply: Count= 3, ContentLen= 2000

    Now the FastCGI process outlives each request and all is good.

    The three requests take around 2 secs with my current connection.

    All the timouts on the server are 10secs or more:

     [C:\Inetpub\wwwroot\MyServer\cgi-bin\FCGITest.exa]
    QueueLength=999
    MaxInstances=20
    InstanceTimeout=60
    InstanceMaxRequests=500
    IdleTimeout=10
    ActivityTimeout=10
    RequestTimeout=10

     Is there something simple I have overlooked?

     

    When I increase the Chunk Size to 64k, it still only takes about 3/4 seconds to complete:

     --------  01-05-2009  22:58:26  ---------
     1 Bytes sent= 64000
    FastCGI Reply: Count= 1, ContentLen= 64000

     2 Bytes sent= 64000
    FastCGI Reply: Count= 1, ContentLen= 64000

     3 Bytes sent= 64000
    FastCGI Reply: Count= 1, ContentLen= 64000

     4 Bytes sent= 64000
    FastCGI Reply: Count= 1, ContentLen= 64000

    All the data is received ok. 

     

     

     

  • 01-06-2009, 4:29 AM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 10:13 PM
    • Redmond, WA
    • Posts 2,343

    Re: FastCGI terminating using POST method

    Why are you making your life difficult by splitting up your upload in this way?  The winhttp timeout is per send and not the total for the request, so you can easily send the entity body in one request without hitting the timeout?

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 01-06-2009, 3:51 PM In reply to

    Re: FastCGI terminating using POST method

     Hi Anil,

    Thank you for you reply.

    This is an EXAMPLE of a use of chunked xfer.

    In this example, if i need to upload a 100MB file over a consumer connection, it could take hours, so breaking it up into smaller pieces makes sense from a TIMEOUT perspective, and also allows a broken connection to pick up with the last chunk that was sucessfully transfered.

     
    But all of this is irellevant to the problem

    The point is FastCGI is not behaving as expected. My FastCGI process is being terminated depending on the size of the CONTENT_LENGTH.

    Can you explain this?

     

Page 1 of 1 (3 items)
Microsoft Communities