POTHEAD


NamePOTHEAD JSON
Version 0.8.12 PyPI version JSON
download
home_pagehttps://gitlab.com/rawler/pothead
SummaryA reverse-http proxy implementation for non-concurrent requests
upload_time2024-01-19 10:40:17
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/5d/74/50afdc1923640caa577bbf88f8167969e4e2318ab0c2096dabbfed8a4155/POTHEAD-0.8.12.tar.gz",
    "platform": null,
    "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",
    "bugtrack_url": null,
    "license": "",
    "summary": "A reverse-http proxy implementation for non-concurrent requests",
    "version": "0.8.12",
    "project_urls": {
        "Homepage": "https://gitlab.com/rawler/pothead"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4f0953324c19667657864454fcd44d4fd8be234f561a5cbdf5d02fcfbb1a3fc6",
                "md5": "eab4adb15c69ddacbbf25f5c3a717ee2",
                "sha256": "a93a833ed1b224fee9e44e262ae8fa65770193a31b37f52cd527a38eaa6ff935"
            },
            "downloads": -1,
            "filename": "POTHEAD-0.8.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "eab4adb15c69ddacbbf25f5c3a717ee2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 35726,
            "upload_time": "2024-01-19T10:40:15",
            "upload_time_iso_8601": "2024-01-19T10:40:15.604494Z",
            "url": "https://files.pythonhosted.org/packages/4f/09/53324c19667657864454fcd44d4fd8be234f561a5cbdf5d02fcfbb1a3fc6/POTHEAD-0.8.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5d7450afdc1923640caa577bbf88f8167969e4e2318ab0c2096dabbfed8a4155",
                "md5": "de31bb659ac23072a204077c6e4c1fe8",
                "sha256": "10502c06423b00e4af0b1e2d15ad89825672d3a7b70e27dd100f1d3a4bc4e64a"
            },
            "downloads": -1,
            "filename": "POTHEAD-0.8.12.tar.gz",
            "has_sig": false,
            "md5_digest": "de31bb659ac23072a204077c6e4c1fe8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 30595,
            "upload_time": "2024-01-19T10:40:17",
            "upload_time_iso_8601": "2024-01-19T10:40:17.451269Z",
            "url": "https://files.pythonhosted.org/packages/5d/74/50afdc1923640caa577bbf88f8167969e4e2318ab0c2096dabbfed8a4155/POTHEAD-0.8.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-19 10:40:17",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "rawler",
    "gitlab_project": "pothead",
    "lcname": "pothead"
}
        
Elapsed time: 0.17327s