Skip to main content

Part of the Kontiki suite — a compact open-source stack for teams that need ops without the heavy stack.

Full suite overview → https://kontiki-org.github.io/

Ops demo → kontiki-monitor Quickstart.


Overview

Kontiki is a Python runtime for distributed services: a small surface (@http, @rpc, @on_event, @task) over a shared model for identity, routing, delivery, fleet health, configuration, and testing. Services talk through a message mesh (AMQP via aio-pika and asyncio); you express intentions in Kontiki terms, not broker topology by hand.

Kontiki turns recurring distributed-service decisions into platform conventions. Configuration, service identity, RPC, event delivery, fleet health, flow correlation, and testing follow the same model across services, so each new service does not have to redesign the same plumbing.

  • One model from dev to production: merged YAML config, cli.run, and the same entrypoint decorators in tests (kontiki.testing mocks on the bus) and in production.
  • Design interactions as messages: RPC for request/reply; events for async work. On @on_event, delivery is explicit — default (one instance per message, competing consumers), broadcast=True (every instance), in_session=True (one pinned instance via a session).
  • Route by event_type: the event name is the routing contract; deployment identity (kontiki.service_name, kontiki.peers) and environment-specific names live in config, not in code.
  • Fleet registry: heartbeats, degraded state (degraded_on), exception tracking, and orchestrator live probes (GET /live/{service_name}). The bus runs without a registry; operating the fleet coherently assumes one.
  • Integrated operations: correlate flows with flow_id, browse the fleet in KontikiTUI, alert from registry signals with kontiki-monitor.

The decorators are the visible API; most of the leverage sits one layer deeper.

For gotchas, controlled failures (rpc_error), and patterns beyond this overview, see docs/advanced-features.md. For a feature-by-feature reference, see docs/features.md.

Mental model (short)

Need Reach for
Sync API @http / @rpc
Async reaction @on_event
Time-driven work @task
One instance handles an event default @on_event (competing consumers)
Every instance handles it @on_event(..., broadcast=True)
One pinned instance @on_event(..., in_session=True) + open_session
Route an event explicit event_type
Caller target from deploy config RpcProxy(..., peer="…") / open_session(peer="…") → kontiki.peers
Fleet health registry + degraded_on
Cross-service debug flow_id → filter in KontikiTUI Logs
Tests on the bus kontiki.testing
Gateway into Kontiki from FastAPI, etc. standalone Messenger

Kontiki suite

Kontiki is not only the Python runtime: the suite carries the same model into scheduling, fleet visibility, and alerting — so development, deployment, and day-to-day ops stay on one conceptual stack.

Component Role
Kontiki (this repo) Service runtime — entrypoints, messaging, registry client, config, testing
kontiki-scheduler Declarative cron on the bus — static YAML schedules publish {name}.schedule_task.requested (replaces external crontab)
kontiki-tui Terminal UI over the registry and local logs — browse services, filter by flow_id, inspect events and exceptions
kontiki-monitor Fleet checks, registry signals, and host disk alerts

When services register with the Kontiki registry, KontikiTUI gives a live picture of the fleet from the terminal:

KontikiTUI — services overview

Quickstart

Install Kontiki (via pip or Poetry):

pip install kontiki

Define a simple service. The service class wires entrypoints; a delegate holds business logic (recommended pattern — see docs/features.md):

from kontiki.delegate import ServiceDelegate
from kontiki.messaging import Messenger, on_event, rpc
from kontiki.runner import cli


class MyDelegate(ServiceDelegate):
    async def setup(self):
        pass  # optional: init from self.container.config

    def process(self, payload):
        return {"processed": payload}


class MyService:
    name = "compute-api"  # optional: overridden by kontiki.service_name in config
    delegate = MyDelegate()
    messenger = Messenger()

    @rpc
    async def compute(self, x):
        return self.delegate.process(x)

    @on_event("example.thing.happened")
    async def on_thing(self, payload):
        result = self.delegate.process(payload)
        await self.messenger.publish("example.thing.processed", result)


def run():
    cli.run(MyService, "Example Kontiki service.", version="0.1.0")

Expose it as a CLI command in pyproject.toml:

[tool.poetry.scripts]
my_service = "myapp.main:run"

Run your service:

my_service --config config.yaml

RPC plus a chained event — the shape most meshes grow from. In production, peers resolve from config (kontiki.peers), delivery modes are set on handlers, and the registry tracks the fleet. See examples/events/broadcast/, examples/events/session/, and examples/registry/.


Documentation

  • Features: docs/features.md
  • Advanced features (patterns & gotchas): docs/advanced-features.md
  • Configuration reference: docs/configuration.md
  • Example configuration: docs/kontiki-config.example.yaml
  • Contributing guidelines: CONTRIBUTING.md
  • License: LICENSE

Kontiki requires RabbitMQ. You do not declare exchanges or queues yourself — decorators and config declare the topology. To start a broker locally:

make run-amqp

Examples

Examples can be run via the Makefile (see targets such as run-rpc-service, run-rpc-example, run-simple-events-service, etc.).

Feature Example path
Basic RPC examples/rpc/
Simple events examples/events/simple/
Broadcast events examples/events/broadcast/
Event serialization examples/events/serialization/
Session-based events examples/events/session/
Periodic tasks examples/task/
Service registry (admin + client) examples/registry/
Heartbeats & degraded mode examples/heartbeat/
HTTP entrypoints examples/http/simple/

Misc

Kontiki did not come out of a naming workshop but from the album Kontiki by the band Cotton Mather. If you enjoy vintage 4-track indie pop as much as microservices, you should check it out.

Metadata

Release files for kontiki 1.10.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 kontiki 1.10.0
File Size Uploaded
kontiki-1.10.0.tar.gz 44.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kontiki 1.10.0
File Interpreter ABI Platform
kontiki-1.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 106.8 kB

Release files / kontiki-1.10.0.tar.gz

Download URL kontiki-1.10.0.tar.gz
Size 44.1 kB
Tags Source
SHA-256 checksum
How to use checksums
494bcd5592d559506ecdeff446977b01b23941b4735ed4a0e214a1ea2202761e
BLAKE2b-256 checksum
How to use checksums
1d903be8086d33d53225b790cca8ebce1b2ef53673f3f5e980509ddece5ac701
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.13.7 Linux/6.8.0-139-generic

Release files / kontiki-1.10.0-py3-none-any.whl

Download URL kontiki-1.10.0-py3-none-any.whl
Size 62.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc6d7df24aa2daf34ab522767b7a892fbae02fa4684d60b8669e422e3af32d05
BLAKE2b-256 checksum
How to use checksums
4d9e3b923998746d008e1911e44ebd1cac4e595a1498649a7322c394f59a54b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.13.7 Linux/6.8.0-139-generic

Release history Release notifications | RSS feed

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.16.0

2 release files

1.15.0

2 release files

1.14.0

2 release files

1.13.0

2 release files

1.12.0

2 release files

1.11.1

2 release files

This release

1.10.0 This release

2 release files

1.9.0

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

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