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

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.1
File Size Uploaded Provenance Actions
mini_aiohttp-0.1.1.tar.gz 12.1 kB With provenance Details for mini_aiohttp-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 23.5 kB

Release files / mini_aiohttp-0.1.1.tar.gz

Download URL mini_aiohttp-0.1.1.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c64b94c8a6e2f718ff91432735c776a630d1484ecc8ab2dbf0414cb9b0895257
BLAKE2b-256 checksum
How to use checksums
8983323ffb5d0c29b4f7b1be286c4f3dbf718bb8d1561ae35a71eb6689757172
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.1-py3-none-any.whl

Download URL mini_aiohttp-0.1.1-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bdd7c1d0e60e855d6087dc1422fd54a661943f49931560b08f2e17cb808df8d7
BLAKE2b-256 checksum
How to use checksums
25c7065cf0b0d920a0d7ae39e28e68e3a3c404b4996c35acf6f156be84906647
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.1

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