In this article, we will understand internals of apache kafka, building event driven microservices using kafka and many more things.
Let's first understand that how services communicate with each other. Imagine two backend services: Service-A and Service-B. If Service-A has to pass some data to Service-B, then a very simple way which we all should know is using REST APIs, and that is correct. How does that work? Service-B will expose api endpoints and Service-A will call those APIs. Now, imagine a situation that Service-A has to pass the same data to one more service now alongwith Service-B (which it is already doing). Again very simple, the new service (let's call Service-C) will expose its APIs and Service-A will call those.
Now are you able to imagine the issue with above approach?
Well, let me point out some issues.
- In future, if we want to add more services then code in Service-A needs to be changed to configure the API endpoints of the new services.
- Service-A is making a lot of API calls now which does not seem to scalable.