Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-1083

Preforking python process pool server

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.6
    • 0.7
    • Python - Library
    • None
    • linux. haven't tested on windows

    • Patch Available

    Description

      This patch adds a new server to the python library: TProcessPoolServer, which is a preforking python server.

      this server is sort of a mix between TForkingServer and TThreadPoolServer: It has a pool of workers that are preforked subprocesses.
      This approach allows the user to avoid the python GIL single processor limit in threading applications, and use a high performance server, and at the same time it avoids the need to fork a child process for each connection, as is the case with the forking server.

      I've benchmarked it to be about 5-6 times faster than TThreadPoolServer on a quad Corei7 CPU, and about the same amount faster than TForkingServer if you are not using persistent connections and forking a child for each request.

      The patch also updates the python unit tests to include tests for this server.

      Notes:
      1. Of course this server has the limitations of forking regarding shared state and memory copying.
      2. You should NOT kill the server with kill -9 - as this will not allow the parent process to terminate its children, resulting in orphaned processes that keep your socket open. either run stop() in your app or kill the process with SIGINT. It will respond to ctrl+C however
      3. use setNumWorkers before starting the server to determine how many processes you want to spawn. the default is 10.

      Attachments

        1. TProcessPoolServer.py
          4 kB
          Dvir Volk
        2. TProcessPoolServer.py
          4 kB
          Dvir Volk
        3. TProcessPoolServer.patch
          6 kB
          Dvir Volk

        Activity

          People

            dvirsky Dvir Volk
            dvirsky Dvir Volk
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: