AI RAG microservices architecture design pattern



I'm building a stack of microservices with Java and SpringBoot to hold the main logic of my AI RAG service using langchain4j and Bedrock. For now since I'm starting I'm building one microservice that will hold the data ingest logic from the documents uploaded by the users. This documents will be saved in an S3 bucket and also transform to embeddings and saved in the DB. Then in this service I will put also the logic of the chatbot so the users can get the response of their answers when they send the requests.

Should I separate this and create one microservice for the data ingest and another one for the chatbot Q&A logic to avoid performance issues in the future?


1 Answer


For multiple reasons, you want to have multiple microservices and keep them small and loosely coupled. It's all about separation of duties.

See for best practices

Having small microservices (which is a pleonasm ;-) ) has multiple advantages on the side of NFRs (Non-Functional Requirements):

  • better security: the execution roles associated to lambda can have reduced privileges
  • performances and scalability can be managed in a more granular fashion
  • high-availability: you can have different strategies for your different microservices.

Yes, it's more work upfront but, if you build for the long-term, it will pay back multiple times over the course of the life of your service.



profile pictureAWS
answered 3 months ago
  • I see! Thanks man! One final question, if my chatbot microservice needs to access the db to get some data, it should call the main data ingest microservice that is inserting the data into the DB to get the response. Or should the second microservice also map the db and the same table to get that data directly without calling the data ingest microservice?

  • My take is that you should keep the ingest service independent from read requests: you can separate concerns and avoid write permission when unneeded. So, it is better from my standpoint to reads from the chatbot service.

  • I see, thanks man!

  • Interesting project that you are building with leading-edge techs! Good luck. Thanks for accepting my answer.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions