Nameko Microservice with Flask and Fastapi (docker)

In this story the whole process of building the microservice app with nameko that has both flask and fastapi as web service, is going to explained.

This project is developed on docker container and is going to be deployed with kubernetes. The repo for this project is here.

Services

There are three services in this microservice app:

Fibonacci calculator

As it can be seen here, this service is going to calculate the Fibonacci of a number.

First this task class needed to be added:

This class added the fibo function to a eventlet thread so it can calculate it in the background and do not lock a thread.

Then by using nameko rpc feature this service is registered into rabbitmq and could be accessible from other service.

Flask service

This service is going to get the number from user and ask the fibo service to calculate it.

Fastapi Service

This service is also like flask but this framework is an asynchronous web app framework and the implementation is like this:

In the NEXT part the deployment on kubernetes is explained.

References:

doing some data engineering