61071

FastCGI / SCGI pre-fork

I've been trying to implement a web server gateway (for fun and educational purposes) and I have some questions about the core architecture behind FastCGI/SCGI with respect to the pre-fork model.

How do FastCGI/SCGI implementations handle communication in pre-fork scenarios? AFAIK, the gateway only has one socket to connect to the FastCGI server. Normally, there is a parent process that accepts connections from the gateway and hands off the work to one of the pre-forked workers.

Since the connections are established after the children are forked, how are you supposed to have the children use these sockets to communicate with the gateway?

Answer1:

I hope I understood the question.

The server socket should be created by the parent process; when it forks, children inherit that socket making it a shared resource. Then, I suppose, each child tries to accept() connections concurrently.

As a reference I found this document (see "accept serialization") discussing starvation issue when listening on multiple sockets, and this SO discussion on sharing sockets

Answer2:

One options is file descriptor passing over UNIX domain socket. Stevens UNP has basic example.

Recommend

  • Parallel Computing - Shuffle
  • How to navigate between different html pages in Windows 8 Metro application using javascript?
  • Looking for datastructure that maintains a size & purges older elements in the process
  • Play Framework 2.0 correct way to represent a set in a query using Anorm
  • Add filename and length parameter to WCF stream when Transfermode = Stream
  • How to send an std::vector of unsigned char over an UDP socket using boost asio?
  • Implementation of monitors with semaphores
  • Passing uniform webservices through Camel
  • module vs type behavior difference on using F# lambda as actual argument to formal parameter that ex
  • How to read data from socket connection - android
  • With one EDMX file use multiple connection strings that relate to multiple databases
  • Cannot send user message with Spring Websocket
  • How can integers (keys & values) be added and retrieved from a NSDictionary
  • Exposing an enum in a QML signal
  • Rx produce and consume on different threads
  • How to Compose OSGi Based project with C++ based project?
  • Filter on CALayer except for a shape which is an union of (non necessarily distinct) rectangles
  • Autohotkey script running program with command line arguments
  • Search files(key) in s3 bucket takes longer time
  • Detection of framework usage on Mac system?
  • Error in making a socket connection
  • Passing variable arguments using PowerShell's Start-Process cmdlet
  • Dart - Isolate Cross Window Communication
  • Dynamically switching connect in Modelica
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • Redux Form - Not able to type anything in input
  • Force show.bind execution
  • Get history of file changes from TFS to implement custom “blame”-behaviour of exceptions
  • How can I sort a a table with VBA with given text condition?
  • Django rest serializer Breaks when data exists
  • Disable Enter in editText android
  • How to rebase a series of branches?
  • Azure Cloud Service Web Role web pages do not load
  • what is the difference between the asp.net mvc application and asp.net web application
  • How to include full .NET prerequisite for Wix Burn installer
  • Understanding cpu registers
  • How do I configure my settings file to work with unit tests?
  • Linking SubReports Without LinkChild/LinkMaster
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • How do I use LINQ to get all the Items that have a particular SubItem?