POTHEAD


NamePOTHEAD JSON
Version 0.7.0 PyPI version JSON
download
home_pagehttps://gitlab.com/rawler/pothead
SummaryA reverse-http proxy implementation for non-concurrent requests
upload_time2021-06-11 08:25:42
maintainer
docs_urlNone
authorUlrik Mikaelsson
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            POTHEAD
=======

What?
-----

POTHEAD uses a reverse-http proxy solution to improve request-latency when load-balancing expensive non-concurrent HTTP requests.

### Why?
A certain class of http-backend-requests are poorly served by regular HTTP-load-balancing solutions, wether hashed or round-robin. This class of requests cannot efficiently over-use resources in the worker, for example due to breaking RAM-limits, or concurrency causing non-optimal CPU cache use. In a traditional forwarding HTTP load-balancer, the worker can throttle incoming requests by slowing down "accept"-rate, but doing so would increase latency and potentially leave free workers unused. One prime example is transcoders of audio, video or images, which is typically CPU-intensive and cache-sensitive.

### How?
POTHEAD solves this problem by employing "reverse"-HTTP on the worker side. The TCP "client" (the worker initiating the TCP-connection), implements the server side of the HTTP, protocol, waiting for the TCP "server" to initiate the HTTP request. Both the workers and the service consumers connect to a service hub. Requests from the consumers are queued by the hub and dequed when a worker connects. The worker can thus control how many parallel connections to maintain, thereby the concurrency of the requests.

### Why not?
To control the concurrency, the worker might need to employ `Connection: close` in order to accept a new request only when resources are available. This TCP reconnection leads to some overhead in network traffic, latency, and could lead to the TCP "lingering" problem. Therefore it's not recommended to use POTHEAD for requests with less than 50ms of average execution time.

### (Why "POTHEAD"?)
Because PTTH was taken.

Ok, ok. How do I get started?
-----------------------------
This implementation provides a hub based on `aiohttp`. It will open up two ports, one main port for consumers and one for workers. Run with `python3 -m pothead.server`.

It also includes a WSGI-enabled worker-runner, allowing you to host your regular WSGI-app through POTHEAD. Run using `python3 -m pothead.worker --connect <host>:<port> <module>:<app-symbol>`.

The runner have a couple of useful features, one being a gating-based "--poll-jobs" mode, where a `wait_for_slot` implemented on the provided app-object allows the application to dynamically pull jobs matching based on available resources. A standard implementation for CPU-usage-based gating is provided in `pothead.gating`.

Another worker-feature worth mentioning is "--redirect-response". Running in this mode, the worker will automatically and transparently redirect any successful (200) responses from this WSGI-app, to a direct port of the worker. This is useful to avoid the PTTH-broker becoming a bottleneck of network bandwidth.

Run tests with `tox`. If you're on MacOS and the build fails because of missing functionality in the socket package, use a Docker container: `docker build -f dev.Dockerfile -t pothead-dev . && docker run -it -v $PWD:$PWD -w $PWD pothead-dev`.

What then?
----------
How would I know? You tell me.

License
-------
Copyright 2019 Ulrik Mikaelsson

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.



            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/rawler/pothead",
    "name": "POTHEAD",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Ulrik Mikaelsson",
    "author_email": "ulrik.mikaelsson@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9e/ed/a02518ffda21bf7f0571ce74853911b1e9f3045b49d79a1f238dc951cfa8/POTHEAD-0.7.0.tar.gz",
    "platform": "",
    "description": "POTHEAD\n=======\n\nWhat?\n-----\n\nPOTHEAD uses a reverse-http proxy solution to improve request-latency when load-balancing expensive non-concurrent HTTP requests.\n\n### Why?\nA certain class of http-backend-requests are poorly served by regular HTTP-load-balancing solutions, wether hashed or round-robin. This class of requests cannot efficiently over-use resources in the worker, for example due to breaking RAM-limits, or concurrency causing non-optimal CPU cache use. In a traditional forwarding HTTP load-balancer, the worker can throttle incoming requests by slowing down \"accept\"-rate, but doing so would increase latency and potentially leave free workers unused. One prime example is transcoders of audio, video or images, which is typically CPU-intensive and cache-sensitive.\n\n### How?\nPOTHEAD solves this problem by employing \"reverse\"-HTTP on the worker side. The TCP \"client\" (the worker initiating the TCP-connection), implements the server side of the HTTP, protocol, waiting for the TCP \"server\" to initiate the HTTP request. Both the workers and the service consumers connect to a service hub. Requests from the consumers are queued by the hub and dequed when a worker connects. The worker can thus control how many parallel connections to maintain, thereby the concurrency of the requests.\n\n### Why not?\nTo control the concurrency, the worker might need to employ `Connection: close` in order to accept a new request only when resources are available. This TCP reconnection leads to some overhead in network traffic, latency, and could lead to the TCP \"lingering\" problem. Therefore it's not recommended to use POTHEAD for requests with less than 50ms of average execution time.\n\n### (Why \"POTHEAD\"?)\nBecause PTTH was taken.\n\nOk, ok. How do I get started?\n-----------------------------\nThis implementation provides a hub based on `aiohttp`. It will open up two ports, one main port for consumers and one for workers. Run with `python3 -m pothead.server`.\n\nIt also includes a WSGI-enabled worker-runner, allowing you to host your regular WSGI-app through POTHEAD. Run using `python3 -m pothead.worker --connect <host>:<port> <module>:<app-symbol>`.\n\nThe runner have a couple of useful features, one being a gating-based \"--poll-jobs\" mode, where a `wait_for_slot` implemented on the provided app-object allows the application to dynamically pull jobs matching based on available resources. A standard implementation for CPU-usage-based gating is provided in `pothead.gating`.\n\nAnother worker-feature worth mentioning is \"--redirect-response\". Running in this mode, the worker will automatically and transparently redirect any successful (200) responses from this WSGI-app, to a direct port of the worker. This is useful to avoid the PTTH-broker becoming a bottleneck of network bandwidth.\n\nRun tests with `tox`. If you're on MacOS and the build fails because of missing functionality in the socket package, use a Docker container: `docker build -f dev.Dockerfile -t pothead-dev . && docker run -it -v $PWD:$PWD -w $PWD pothead-dev`.\n\nWhat then?\n----------\nHow would I know? You tell me.\n\nLicense\n-------\nCopyright 2019 Ulrik Mikaelsson\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A reverse-http proxy implementation for non-concurrent requests",
    "version": "0.7.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "78848a03cccde3bbeaa64fba25ded130",
                "sha256": "7bd45c291d633c37bb191cfb76638fb92b002abc94e828a030afcd06c2707606"
            },
            "downloads": -1,
            "filename": "POTHEAD-0.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "78848a03cccde3bbeaa64fba25ded130",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 21225,
            "upload_time": "2021-06-11T08:25:40",
            "upload_time_iso_8601": "2021-06-11T08:25:40.022147Z",
            "url": "https://files.pythonhosted.org/packages/d6/6d/7bc94cab835ad623cbf83c2691a0617d24b4c907316c2addc1b4875bdc55/POTHEAD-0.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "5eee0fd6e6a68b166e99c4b0c92956ef",
                "sha256": "f27115ee3a4238f7a33e08a1b3dc36c541f9900fafaa3e1d82a7254f8739eddb"
            },
            "downloads": -1,
            "filename": "POTHEAD-0.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5eee0fd6e6a68b166e99c4b0c92956ef",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15027,
            "upload_time": "2021-06-11T08:25:42",
            "upload_time_iso_8601": "2021-06-11T08:25:42.638597Z",
            "url": "https://files.pythonhosted.org/packages/9e/ed/a02518ffda21bf7f0571ce74853911b1e9f3045b49d79a1f238dc951cfa8/POTHEAD-0.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-06-11 08:25:42",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "gitlab_user": null,
    "gitlab_project": "rawler",
    "lcname": "pothead"
}
        
Elapsed time: 0.29284s