user3499836
user3499836

Reputation: 117

Microservices - role of kafka, API gateway, lambda

When following micro-services architecture, where and how kafka is used (for inter-service message communication?) Is my understanding correct as below?

Clients(Webpage) -> through API gateway -> Lamdba -> request to (CRUD) consumer info. Now, should i update the consumer info in Lambda directly with dynamo db, or send an event to kafka which should update data? Should customer service send an event like customer_updated to notify other services of the updates?

Also, my understanding is that, Each micro-service -> has own DB. Any related data with other services should be replicated and saved in the same db. For instance, Customer service can hold data about customer-accounts and related data (or should it only hold id for accounts). What if we want to display in customers page a small subset data related to accounts. Should ids of accounts be fetched after which account info from account service?

Basically two q's but felt they were inter-related.

Upvotes: 0

Views: 1070

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191914

Note: You could replace Kafka with Kinesis, and you would have the same question...

Lamdba could also be replaced with any API server behind a gateway, and the gateway could just be a simple load balancer.

You don't need Kafka or a message queue here, but the main benefits here is that it would decouple your CRUD actions and any other point to point interactions between services and add the ability to have durability and backpressure in the event that downstream services are unable to receive requests.

Regarding databases and displaying state - In Kafka, you would need to join topics then dump to a database table, or dump individual topics, then join from there, depending on your query patterns. Note that you can use one producer to send multiple events to multiple topics in one application/function

Upvotes: 1

Related Questions