:Draft:Nameko(Python framework)
Nameko is a microservices framework for the Python programming language. It provides tools and patterns to help developers build services that communicate with each other, perform concurrent operations, and scale when necessary.{{cite web |title=Nameko Documentation |url=https://www.nameko.io/stable/ |website=www.nameko.io |access-date=30 May 2025}}{{cite web |title=Python Microservices Architecture: Implementing Service Discovery and Load Balancing with Nameko |url=https://hackmd.io/@LiLPlZLmT7W5Afh5ahEYmg/rJ5w28l_a |website=HackMD |author=Sophia Emily |date=24 January 2024 |access-date=30 May 2025}} The framework aims to handle boilerplate for a microservice architecture, allowing developers to focus on business logic.
Overview
Nameko services are typically Python classes. Dependency injection, a design pattern where a component's dependencies are provided rather than created by the component itself, is a core concept in Nameko.{{cite tech report |last1=Kaffes |first1=Konstantinos |last2=Humphries |first2=John |title=Profiling Microservices |institution=Stanford University |type=CS244B Project |date=Autumn 2017 |url=https://www.scs.stanford.edu/17au-cs244b/labs/projects/kaffes_humphries.pdf |access-date=30 May 2025}}{{cite web |title=Microservices in Nameko |url=https://codemdc.com/microservices-in-nameko/ |website=CodeMdc |author=Michael Da Costa |access-date=30 May 2025}}
Dependencies, such as connections to other services or system components, are declaratively added to service classes and injected into service instances, known as workers.
Methods within these services are exposed as "entrypoints," which are Python decorators that bind the methods to underlying transport protocols. For example, an @rpc decorator allows a method to be called via RPC, typically over AMQP,{{cite web |title=Top Microservices Frameworks |url=https://dzone.com/articles/top-microservices-frameworks-1 |website=DZone |date=10 May 2021 |access-date=30 May 2025}} while an @http decorator allows a method to be called through an HTTP request. Nameko also supports entrypoints for asynchronous events and WebSockets.
Nameko relies on the eventlet library for its concurrency model, using green threads (userspace threads) to handle multiple requests concurrently within a single process. By default, Nameko uses AMQP as the messaging paradigm for RPC and event notifications, with RabbitMQ commonly serving as the message broker.
Key Features
Service Communication: RPC (Remote Procedure Calls): Offers synchronous communication between services, predominantly using AMQP.
Publish-Subscribe Events: Facilitates asynchronous, event-based communication for broadcasting messages between services.
HTTP and WebSockets: Supports exposing services over HTTP and WebSockets for broader interoperability.
gRPC: Extensible to support gRPC through extensions like nameko-grpc. Nameko itself is designed to be protocol-agnostic, allowing various API styles.{{cite web |title=Nameko RPC & RESTful |url=https://discourse.nameko.io/t/nameko-rpc-restful/317/2 |website=Nameko Discourse |author=mattbennett (Matt Bennett) |date=January 2021 |access-date=30 May 2025}}
Scalability: Nameko is designed for horizontal scaling by running multiple instances of a service. The message broker (e.g., RabbitMQ) can distribute incoming requests across these instances. This relies on a stateless service design for effective load balancing.
Concurrency Model: Nameko uses eventlet for cooperative multitasking with green threads. Each worker (service instance handling a request) runs in its own green thread. This model allows for handling many concurrent I/O-bound operations efficiently within a single process. However, because these green threads are multiplexed onto a single kernel thread, this provides concurrency but not true parallelism on multi-core processors, a common characteristic of many Python frameworks using this approach.
Extensibility: The framework supports custom extensions. Developers can create their own dependency providers to integrate with various databases (e.g., Redis, PostgreSQL) or other external systems, and define custom entrypoints for different transport protocols.
Testing Utilities: Nameko includes tools and fixtures to assist with unit and integration tests, allowing developers to test service logic in isolation and interactions between services.{{cite web |title=Nameko - Assess |url=https://www.thoughtworks.com/radar/languages-and-frameworks/nameko |website=Thoughtworks Technology Radar |date=November 2018 |access-date=30 May 2025}}
Architecture Considerations
In a Nameko-based application, services typically run as independent processes. Communication, such as an RPC call from one service to another, is usually routed through a central message broker like RabbitMQ. This architecture promotes loose coupling, as services do not need direct knowledge of each other's network locations. RabbitMQ also plays a role in service discovery and load balancing by distributing messages to available service instances. This can contribute to a more resilient system, as requests can be handled by other instances if one service instance fails.
Example Service Structure
from nameko.rpc import rpc
class ExampleService:
name = "example_service"
@rpc
def process_data(self, data_payload):
result = f"Processed: {data_payload}"
return result
This structure is similar to examples provided in introductory tutorials for the framework.{{cite web |title=nameko-example/README.md at master · brunorocha/nameko-example |url=https://github.com/brunorocha/nameko-example/blob/master/README.md |website=GitHub |author=Bruno Rocha |date=March 2016 |access-date=30 May 2025}}
Adoption and Current Status
Nameko was recognized by Thoughtworks in their November 2018 Technology Radar in the "Assess" category, described as a "super-lightweight microservices framework" and an alternative to Flask for writing services, noting its limited feature set (WebSocket, HTTP, AMQP) and focus on testability.
The framework has been used in various projects, including in academic and research settings. For instance, a 2023 paper on a distributed platform for EV charging simulation utilized Nameko for microservice communication via RabbitMQ.{{cite journal |last1=Gjika |first1=Albi |last2=Bottazzi |first2=Andrea |last3=Barchi |first3=Giacomo |last4=Avizzano |first4=Carlo Alberto |last5=Passerone |first5=Roberto |title=Distributed Platform for Offline and Online EV Charging Simulation |journal=World Electric Vehicle Journal |volume=14 |issue=11 |pages=307 |year=2023 |date=October 2023 |doi=10.3390/wevj14110307 |doi-access=free }} More recently, a May 2024 paper detailed an accelerator network monitoring system that employed Nameko for managing and invoking its various microservices.{{cite journal |last1=Ma |first1=Xiaoliang |last2=Li |first2=Junlong |last3=Tian |first3=Zhan |last4=Wang |first4=Ruijing |last5=Li |first5=Jianshe |last6=Qin |first6=Qing |title=Accelerator network monitoring system based on microservices architecture |journal=Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment |volume=1065 |pages=169489 |year=2024 |date=May 2024 |doi=10.1016/j.nima.2024.169489 |arxiv=2402.17125 |url=https://www.sciencedirect.com/science/article/pii/S016890022400261X}}
As of late 2021, the latest stable release of Nameko is version 2.14.1 (released December 5, 2021).{{cite web |title=Releases · nameko/nameko |url=https://github.com/nameko/nameko/releases |website=GitHub |access-date=30 May 2025}}{{cite web |title=nameko/nameko |url=https://github.com/nameko/nameko |website=GitHub |access-date=30 May 2025}} Development has continued on a version 3.0.0, with several release candidates (the latest being 3.0.0-rc11 in December 2021) that introduced features like Python 3.10 support and changes to Eventlet integration. Work on the v3.0.0-rc branch has included support for Python 3.11 (merged July 2023).{{cite web |title=feat: Add support for Python 3.11 by mattbennett · Pull Request #764 · nameko/nameko |url=https://github.com/nameko/nameko/pull/764 |website=GitHub |date=11 July 2023 |access-date=30 May 2025}} The main Nameko repository showed commit activity as recently as May 2024.{{cite web | title=Commits · nameko/nameko | url=https://github.com/nameko/nameko/commits/master | website=GitHub | access-date=30 May 2025}}
However, the framework faces some contemporary challenges. As of early 2025, compatibility issues with Python 3.12 have been reported.{{cite web |title=nameko no longer supports the latest python version and will not run on Python 3.12.8 · Issue #785 · nameko/nameko |url=https://github.com/nameko/nameko/issues/785 |website=GitHub |date=8 May 2025 |access-date=30 May 2025}} Additionally, Eventlet, a core dependency for Nameko's concurrency, announced it was entering maintenance mode in July 2024, which may have long-term implications for the framework.{{cite web |title=Eventlet is entering maintenance mode · Issue #774 · nameko/nameko |url=https://github.com/nameko/nameko/issues/774 |website=GitHub |date=8 July 2024 |access-date=30 May 2025}} Some recent (early 2025) listings of top Python microservice frameworks have not included Nameko, suggesting it may be less prominent or considered a more niche option compared to others like FastAPI or Flask for such purposes.{{cite web |title=7 Best Python Frameworks for Microservices To Use In 2025 |url=https://planeks.com/blog/7-best-python-frameworks-for-microservices-to-use-in-2024/ |website=PLANEKS |date=28 February 2025 |access-date=30 May 2025}}
See also
References
{{reflist}}