DEV Community

Nemanja Djuric
Nemanja Djuric

Posted on

Help with Microservices

Hello, this is my first post here.

I am building a small deezer/spotify clone for my own purposes. I have a huge CD collection, ripped to various music formats.While doing that, I'll try to implement a Microservice Architecture. I've seen netflix basically outsourcing most of the tools I want, but I want to do it myself and I'd like to see if there are opinions on it.

My choice of technology is Python Flask and Apache Kafka.
I implemented all of the following stuff as a separate Flask Application
So, as any microservice architecture needs is

Service registry

It's an app, which will publish its location to the kafka topic, so all of the services could reach it. It has a REST api for registering, and fetching services.

API Gateway

It's an app, that has a REST api, which will take the request from the frontend, check if the service is up and exist, and forward it to the appropriate one. One thing that's certainly missing is probably loadbalancer, but let's leave that for now.

Now the services. I am thinking about, how to decouple them correctly, for example.

Users

This definitely is a separate microservice, it has login and register API, and keeps track of the users in it's own database.

Now on to the tricky stuff. Now I suppose this stuff is very opinionated, but I'd like to hear what others think of it.

Records

Records service is basically 3 GET API's from where you can fetch artists/albums/tracks lists. That is fine, but for my platform I need to keep the path of every song. I would put that in an other table and connect those two with foreign key so I could keep my "database per service pattern" around. And actually the RECORDS Microservice should not use the table with paths!
Now the problem I am having is, I'd like to have a service that will update these db's occasionally, and my thought is, where would that service run?

Playlist

Playlist service takes care of the already mentioned path database, it would publish messages to Kafka broker, that contains the paths to the songs.

Player

Player consumes Kafka messages and plays the song one after another.

Analytics

This is the service that concerns me the most. How do I decouple it from the rest, when basically it should analyze everything that is happening in all services. Is actually the solution that all of the services have a log Kafka topic that they will publish their stuff to? And the analytics constantly consumes those messages in their own table?

I'd like to hear more opinions about this. Am I overusing Kafka or using it exactly as it's supposed to?

Thanks a lot!

Top comments (0)