Skip to main content

A reverse-http proxy implementation for non-concurrent requests

Project description

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>.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

POTHEAD-0.6.2.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

POTHEAD-0.6.2-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file POTHEAD-0.6.2.tar.gz.

File metadata

  • Download URL: POTHEAD-0.6.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.5

File hashes

Hashes for POTHEAD-0.6.2.tar.gz
Algorithm Hash digest
SHA256 4f47b2a6edc1c6bedef5027664dcaa7b8467375aee4b4c9756ae1c6ae187d56e
MD5 d402132548b1e1eb5a38ceb69160c5e5
BLAKE2b-256 dc34be2aee949864c572410e85c22b8953d1f3fe1dfb382328c3ac46599c5223

See more details on using hashes here.

File details

Details for the file POTHEAD-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: POTHEAD-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.5

File hashes

Hashes for POTHEAD-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0bb57f4c0ab97bc2cd0e10ce7f4f4894b219ba19384d8e16c1a08d5bcd09c980
MD5 ffbc10e99f5bed2aa3fc287cd73b0ba1
BLAKE2b-256 7524244fd33f3446639d494e3869d7fb56690d2bb213d10cdead8e491e9c9642

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page