How Should I manage AI functions and business logic in back-end efficiently
My recent project is a AI Gym trainer app and I am in charge of the back-end. The project purpose is to let user get an AI Gym trainer who guide them daily with personalized suggestions.
The main AI tasks are:
- Normal chatting
- Daily workout session generate
- Body image analysis
- Calorie target
There are some functions that uses RAG. So, it needed to load in the vector db while initializing the project. That's not the main problem I faced. Because of using Pinecone and langchain there were many heavy dependencies that sizes are above 700MB-800MB it took 900s+ just to install the dependencies.
Restarting my server each time feels 4-5s or more delay every time. Also I faced a worse scenario while installing the dependencies on VPS. I faced many conflicts related to the langchain related package. At the end I removed all the version names from requirements.txt then finally I was able to install them.
So, I was wondering if it is ok to run the heavy AI functions on the business logic server or I should create a micro service.
My backend server is using Django and Django Rest Framework.
The initial idea came into my mind is to use a FastAPI simple server to use the AI functions and it will be isolated in the same docker container. And I am exploring more ideas about this issue.