Skip to main content

mini-aiohttp

A small, dependency-free async HTTP/1.1 client and server built on Python's asyncio.

Features

  • Async client with keep-alive connection pooling per host
  • Async server with routing, keep-alive, and request body limits
  • Connection cap: new connections get 503 when the limit is reached, so memory stays bounded
  • Timeouts on requests and idle connections
  • Chunked response parsing (client) and Content-Length request bodies (server)
  • HTTPS on the client side

Install

pip install .            # from source
pip install .[test]      # with test dependencies

Quick start

import asyncio
from mini_aiohttp import Server, Response, ClientSession

app = Server(max_connections=100_000)

@app.route("/")
async def index(req):
    return Response(200, "Hello")

@app.route("/echo", method="POST")
async def echo(req):
    return Response.json({"got": req.json()})

async def main():
    server = asyncio.create_task(app.serve_forever("127.0.0.1", 8080))
    await asyncio.sleep(0.2)
    async with ClientSession() as s:
        r = await s.get("http://127.0.0.1:8080/")
        print(r.status, r.body.decode())
    server.cancel()

asyncio.run(main())

Running tests

pip install .[test]
pytest

Scaling to many connections

A single Python process can hold tens of thousands of idle keep-alive connections. Reaching 100k needs OS and deployment tuning:

  1. File descriptor limit. Each socket uses one. Raise it before starting: ulimit -n 200000. The server logs a warning if the limit is too low.
  2. Listen backlog. Raise the kernel queue: sysctl -w net.core.somaxconn=65535. The server already requests a backlog of 4096.
  3. Client-side ports. One client machine opening outbound connections to a single ip:port is limited by ephemeral ports (about 28k to 64k). For more, spread load across several source IPs or client hosts.
  4. Multiple processes. Python runs one event loop per process. Start several workers with Server.start(..., reuse_port=True) on Linux to use all CPU cores.
  5. Measure it. Test with a load tool such as wrk, oha, or locust on your own hardware before you rely on any number.

Limits (by design, v0.1)

  • No HTTPS server (put a reverse proxy such as nginx in front).
  • No chunked request bodies on the server.
  • No HTTP/2 or WebSockets.

License

MIT

Metadata

Release files for mini-aiohttp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mini-aiohttp 0.1.0
File Size Uploaded Provenance Actions
mini_aiohttp-0.1.0.tar.gz 8.9 kB With provenance Details for mini_aiohttp-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mini-aiohttp 0.1.0
File Interpreter ABI Platform Actions
mini_aiohttp-0.1.0-py3-none-any.whl Python 3 none any Details for mini_aiohttp-0.1.0-py3-none-any.whl

Total release size: 18.5 kB

Release files / mini_aiohttp-0.1.0.tar.gz

Download URL mini_aiohttp-0.1.0.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2e96c50c4f9a19832bc6c85d308930b94ac57c51434d3518d74d6cda8d182672
BLAKE2b-256 checksum
How to use checksums
5e447e740f5c031bf56e746e3eeac66c1d016667546818beec792c4c91a0dba2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / mini_aiohttp-0.1.0-py3-none-any.whl

Download URL mini_aiohttp-0.1.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1db7c61f1efd368bcceed592f3995e9c72a43b267deac00e71a9378428d7feb5
BLAKE2b-256 checksum
How to use checksums
b86e3b69b5fbae94af74041915e845060720e2b069acaea73a64ccbed18206d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for mini-aiohttp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mini_aiohttp-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page