FastCGI for Desktop Applications

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Event

    FastCGI for Desktop Applications - Presentation Transcript

    1. FastCGIfor Desktop Applications
    2. Development Considerations
      Fast to develop
      Same language
      Same code at each end
      Reliable
      Scalable
      Zero Configuration (Ports, Firewalls etc)
      No additional support load
    3. Windows Libraries
      1 Application Side – HTTP ->(TCP/IP)
      (TCP is optimized for non-real-time applications such as file transfer)
      • - WinINet
      • - WinHTTP
      2 Server Side: (IIS)
      • - ISAPI
      • - CGI
      • - FastCGI
    4. WinHTTP
      • Designed to provide client side HTTP services
      • More secure and robust than WinINet
      • Fewer dependencies on platform-related APIs
      • Supports HTTP/1.1 chunked transfer support for HTTP responses.
      • Geared towards a non-interactive environment
      • Called with the Win32 API set or a COM interface
      • Secure Sockets Layer (SSL) functionality
      • Unique Error codes
      WinINet
      • Legacy library
      • Designed for interactive message dialogs
      • Supports FTP, URL caching and persistent cookies
      1. WinInet Vs WinHTTP
      • FastCGI is not proprietary
      • FastCGI is portable across multiple languages, with zero code changes
      • A FastCGI app is an isolated process (no web server reset)
      • A Poorly written FastCGI app won't crash the web server.
      • FastCGI app servers can run on different hosts from the web server (allows for extremely high performance, distributed web sites.)
      • FastCGI app servers can run on many OS's
      • FastCGI is Mature
      • FastCGI on IIS is actively developed and well supported by Microsoft
      ISAPI vs CGI/FastCGI
      • FastCGIvs CGI (powerpoint)
      • Persistence – Retains Context
      • Now with SIGTERM Handler (pipes)
      • FastCGI will outperform standard CGI
      • (by a factor of 4:1 ~200 rps vs. ~50 rps)
      • You don't lose your context:
      • Allows efficient caching,
      • Share results between requests
      FastCGI
    5. The main task of converting a CGI program into
      FastCGI program is separating the initialization
      code from the code that needs to run for each request.
      The structure should look something like this:
      • - Initialization code
      • - Start of response loop
      '
      ' body code
      '
      • - End of response loop
      Writing a FastCGI Application
      • FCGX_InitRequest()
      • Initializes a FastCGI instance
      • FCGX_Accept_r()
      • Blocks until a new FastCGI request is received
      • FCGX_PutStr()
      • Return a valid HTTP header
      • Return nBytes of text/data
      FastCGI Library Functions:
    6. Hello World in BASIC
      #INCLUDE "FCGX_Header.bas"
      FUNCTION WINMAIN
      LOCAL Count as LONG
      LOCAL sReply AS STRING
      LOCAL FCGXReq AS FCGX_REQUEST '// FCGX Structure
      '// Open Databases
      CALL FCGX_InitRequest(FCGXReq, 0, 0)
      DO '// Main Request processing loop
      INCR Count
      IF FCGX_Accept_r(FCGXReq) < 0 THEN EXIT LOOP '//Execution blocked until HTTP request arrives
      sReply = "Content-Type: text/html"+$CRLF+$CRLF '// The reply begins with a valid HTTP header
      sReply = sReply + “Hello World, Count=" + STR$(Count)
      FCGX_PutStr( STRPTR(sReply), LEN(sReply), FCGXReq.pOut)
      LOOP
      '// Close Databases etc here
      END FUNCTION
    7. Hello World in C++
      #include <libfcgi2.h>
      int main( ) {
      req FCGX_REQUEST;
      int count(0);
      string sReply ;
      ostringstreamss;
      // Open Database
      FCGX_InitRequest( req, 0, 0 );
      while (true) {
      if( FCGX_Accept_r(req) < 0 ) break; // Execution is blocked until a Request is received
      count++;
      ss << count; // Typesafe conversion to text
      sReply = "Content-Type: text/html Hello World " + ss.str();
      FCGX_PutStr( sReply.data(), sReply.size(), req->pOut) ;
      }
      // Close Database
      return 0;
      }
      • Completely new library
      • Gracefull exit – close databases etc
      • The 'SignalBeforeTerminateSeconds' property in fcgiext.ini determins timing of the SIGTERM notification event to be sent by the Web Server to this library under IIS
      • Request Method is available as an int(4 byte signed integer)
      • CONTENT_LENGTH is available as an int(4 byte signed integer)
      • GET method Query String is directly available
      • Open access to input/output buffers
      Libfcgi2 - SIGTERM
    8. SQL requests can generate large responses!
      XML introduces severe bloat
      An example framework for interacting with a
      database on a server
      - Chunks
      - Encryption/Compression
      - Binary Data
      Chunk Protocol:
      HEADER
      DATA BODY
      STRINGS
      Remote SQL
    9. Request/Response Model:
      Authorization
      Feature control
      Billing
      Updating
      Data transfer
      Pushing marketing content
      Deter Piracy
      Example Application
    10. http://www.coastrd.com/
      http://www.fastcgi.com/
      http://www.aprelium.com/
      http://forums.iis.net/
      WebSites

    + Coast Research & DevelopmentCoast Research & Development, 1 month ago

    custom

    180 views, 0 favs, 0 embeds more stats

    The web is playing an increasingly important role f more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 180
      • 180 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 0
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories