DEV Community

Michael Kwaku Aboagye
Michael Kwaku Aboagye

Posted on

How Nameko makes microservice development less difficult.

Before I proceed with how Nameko, a python framework makes microservice development, let have in mind that microservice is just another way developing software by building services or components separately from each other.

Assuming we have decided to build a Bus Ticketing System with the following components in mind:

  • Register
  • Login(Reset)
  • Email
  • Billing
  • Booking
  • Notification
  • Verification

In a monolithic pattern, a team of software engineers would develop the following functions using a server-side language such as Ruby, Golang, Node.js or Python for all components.

These components would all reside on each instance of web servers backed by a load balancer such as Nginx to prevent DDOS attack.

However, in a microservice pattern, the structure is a bit different. These components could be developed with different server-side languages or frameworks.

Nameko as a microservice framework has made it possible for software developers to implement services with ease with the help of dependency injection.

Dependency injection by Nameko allows software developers to separate code for external entities such as databases, Cached systems from the services code.

For instance, the register service and login service could just call the insert() function or query() function from a mongodb or postgres database.

Also have in mind that both the register service and billing service may have a separate postgres database to store users' details.

This is how nameko make microservice development quite flexible for software engineers without the hustle of clustering services with the backend code.

Top comments (2)

Collapse
 
rhymes profile image
rhymes • Edited

Hi Michael, I didn't know about this tool.

I'm going to link it here for future reference:

nameko / nameko

Python framework for building microservices

Nameko

https://secure.travis-ci.org/nameko/nameko.svg?branch=master

[nah-meh-koh]

A microservices framework for Python that lets service developers concentrate on application logic and encourages testability.

A nameko service is just a class:

# helloworld.py

from nameko.rpc import rpc

class GreetingService:
    name = "greeting_service"

    @rpc
    def hello(self, name):
        return "Hello, {}!".format(name)

You can run it in a shell:

$ nameko run helloworld
starting services: greeting_service
...

And play with it from another:

$ nameko shell
>>> n.rpc.greeting_service.hello(name="ナメコ")
'Hello, ナメコ!'

Features

  • AMQP RPC and Events (pub-sub)
  • HTTP GET, POST & websockets
  • CLI for easy and rapid development
  • Utilities for unit and integration testing

Getting Started

Support

For help, comments or questions, please go to <discourse.nameko.io/>.

Contribute

  • Fork the repository
  • Raise an issue or make a feature request

License

Apache 2.0. See LICENSE for details.


Have you used it in production? By looking at the README it seems like it's very RPC oriented. It's an interesting choice the one of using AMQP as an interchange protocol.

The drawbacks seem to be its requirement of RabbitMQ as a companion server and that by being built on eventlet you have to use special compatible libraries to do I/O.

It's a peculiar and different choice, I guess it also predates asyncio which seems the direction Python is going for async concurrency nowadays.

The DI pattern on which is built is neat, I'm not sure I would use it though, I have the feeling that it's going to be cumbersome to integrate with Nameko from clients written in other languages (though if you're a 100% Python shop it might be the right choice!)

A suggestion, I think your post deserves the following tags:

#python

import antigravity


Collapse
 
rev0kz profile image
Michael Kwaku Aboagye

Thanks, bro. Yes. I'm 100% python backend developer. I use nameko for small projects. yet to do so in production...hopefully this year

You can try it. It is awesome because of its dependency injection mechanism.