Skip to main content

Asteri: High Performance Python Web Server

Project description

🌟 Asteri Web Server v1.1.1

Asteri is a high-performance, production-ready Python web server designed with a rich and intuitive CLI argument system. Asteri supports various protocols ranging from WSGI and ASGI to binary uWSGI.

✨ Key Features

  • Multi-Protocol Support: HTTP/1.1, HTTP/2 (Full Frame Support), WSGI, ASGI, and uWSGI.
  • Rich Worker Types:
    • sync: Standard synchronous workers.
    • gthread: Thread-based workers for better concurrency.
    • gevent: Asynchronous workers based on greenlets (extremely high performance).
    • asgi: Full support for modern async applications (FastAPI, Starlette).
  • Professional Auto-Reload: Event-driven reload system using watchdog.
  • Process Management: Daemon mode, PID files, and User/Group switching.
  • Security: Easy-to-configure SSL/TLS (HTTPS) support.
  • Premium Status Dashboard: Real-time server health monitoring at /asteri-status with a modern glassmorphism UI.
  • Colored Access Logs: Visual feedback for HTTP status codes (2xx, 4xx, 5xx).

📊 Performance Benchmark

Asteri is built for speed. In local benchmarks, both Asteri (Sync) and Asteri (ASGI) outperformed Gunicorn and Uvicorn in throughput and latency.

Server Name Type RPS (Requests Per Second) Latency (ms)
Asteri (Sync) WSGI 23.71 2108.39
Asteri (ASGI) ASGI 23.47 2130.29
Asteri (Gevent) WSGI 22.84 2189.49
Uvicorn ASGI 22.73 2199.27
Gunicorn (Sync) WSGI 22.06 2266.41

Benchmark conducted with 1000 requests and 50 concurrent connections.

🚀 Installation

git clone https://github.com/IshikawaUta/asteri.git
cd asteri
pip install -e .

🛠️ Basic Usage

Run a WSGI application:

asteri myapp:app

Run with 4 workers and bind to multiple ports:

asteri myapp:app -w 4 -b 127.0.0.1:8000 -b 127.0.0.1:8001

📚 Running Examples

Asteri includes several examples to get you started with different frameworks and protocols.

Flask (WSGI)

Run with thread-based workers:

python3 -m asteri example_flask:app -k gthread -w 4 -b 127.0.0.1:8000

FastAPI (ASGI)

Run with modern async workers:

python3 -m asteri example_fastapi:app -k asgi -w 4 -b 127.0.0.1:8000

Production with Nginx (uWSGI)

Run Asteri in uWSGI mode (automatic detection) and use the provided example_uwsgi_nginx.conf:

python3 -m asteri example_wsgi:app -b 127.0.0.1:8000

📖 Complete CLI Reference

Asteri supports a wide range of arguments for professional-grade control:

🌐 Network

  • -b, --bind ADDRESS: Bind to specific address (e.g., 127.0.0.1:8000). Supports multiple binds.
  • --backlog INT: Maximum number of pending connections (default: 2048).
  • --reuse-port: Use the SO_REUSEPORT socket flag for load balancing.

👷 Workers & Performance

  • -w, --workers INT: Number of worker processes.
  • -k, --worker-class STRING: Type of workers (sync, gthread, asgi, gevent).
  • --threads INT: Number of worker threads for gthread worker class.
  • --worker-connections INT: Maximum simultaneous clients per worker.
  • -t, --timeout INT: Worker timeout in seconds before restart (default: 30).
  • --graceful-timeout INT: Timeout for graceful worker shutdown.
  • --keep-alive INT: Seconds to wait for requests on a Keep-Alive connection.
  • --max-requests INT: Restart worker after N requests (prevents memory leaks).
  • --max-requests-jitter INT: Add random jitter to max-requests.
  • --preload: Load application code before forking workers (saves memory).

🔒 Security & SSL

  • --certfile FILE: Path to SSL certificate file.
  • --keyfile FILE: Path to SSL key file.
  • --ca-certs FILE: Path to CA certificates file.
  • --ssl-version INT: SSL version to use (TLSv1, TLSv1.1, TLSv1.2).
  • --ciphers STRING: SSL Cipher suite to use.
  • -u, --user USER: Run workers as a specific user.
  • -g, --group GROUP: Run workers as a specific group.
  • -m, --umask INT: Bit mask for file mode.

📝 Logging & Debugging

  • --log-file FILE: Path to error log file.
  • --log-level LEVEL: Log granularity (debug, info, warning, error, critical).
  • --access-logfile FILE: Path to access log file.
  • --access-logformat STRING: Custom format for access logs.
  • --capture-output: Redirect stdout/stderr to the error log.
  • --print-config: Print resolved configuration and exit.

⚙️ Process Management

  • -D, --daemon: Run Asteri in the background.
  • -p, --pid FILE: Create a PID file for process tracking.
  • -n, --name STRING: Set a custom process name (visible in ps or top).
  • -e, --env NAME=VALUE: Set environment variables.
  • --reload: Monitor code changes and automatically reload workers.
  • --chdir DIR: Change working directory before loading the app.

🚀 HTTP/2 & Limits

  • --http-protocols STRING: Protocols to support (e.g., h1, h1,h2).
  • --http2-max-concurrent-streams INT: Limit concurrent H2 streams.
  • --limit-request-line INT: Max size of HTTP request line (default: 4094).
  • --limit-request-fields INT: Max number of header fields.
  • --limit-request-field_size INT: Max size of a single header field.

⚙️ Configuration File

You can use a Python file for complex configurations:

# asteri.conf.py
bind = ["127.0.0.1:8080", "127.0.0.1:8081"]
workers = 4
worker_class = "gthread"
timeout = 60
reload = True

Run with: asteri myapp:app -c asteri.conf.py

📊 Status Dashboard

Enable the internal dashboard to monitor worker statistics: Visit http://localhost:8000/asteri-status in your browser.

📜 License

This project is licensed under the MIT 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

asteri-1.1.1.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

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

asteri-1.1.1-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file asteri-1.1.1.tar.gz.

File metadata

  • Download URL: asteri-1.1.1.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for asteri-1.1.1.tar.gz
Algorithm Hash digest
SHA256 b168f6a6f4a98eca31300f6c4bd2267ba521e4e64ea616acfa76af133ac73232
MD5 ca96e9c6ea53702bb0daa9483ba4375d
BLAKE2b-256 2997f24753580b8fb20fcddf2a4791a95d884982a0cff37262f8d89cbabe800d

See more details on using hashes here.

File details

Details for the file asteri-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: asteri-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for asteri-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 450a8092859612aa725ab7c98fd3341e66d1831878c6615bc75c83e405d016e2
MD5 162af55e46d4d89443031c2efabd7f11
BLAKE2b-256 5a036e90857d378a0acbef096a8a72d403636b61c9d7d633df358b711ffe7809

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