Solutions Architecture Java/Python AI?

0

Hi Guys!

I already have the core of my app working in Java - SpringBoot with a microservices architecture and is working very good. The gateway is done in SpringBoot too in my case and we have everything deployed in a VPC. Now I've developed a POC in Python with Langchain and AWS Bedrock following the RAG flow for the AI and the POC is working very good too. I want now to take that POC and create a new API for the AI related services, should I do it with Python and FastAPI for example and integrate with the main stack? Or it makes sense to make it too in Java and SpringBoot since my main stack is done in that tech and it will be faster to integrate everything?

I know that Python is much more powerful for AI related things as I already saw in the POC I build.

What is the best approach?

Thank you guys!

1 Answer
3
Accepted Answer

Hi,

If my understanding is right, you are using the Lambda function as an API or an integration layer to broker the requests towards bedrock. In this case, you are using Python [in lambda] only to utilise the AWS Python SDK (boto3) and the Langchain python libaries. Technically speaking, you could use the AWS SDK for Java and Langchain Java libraries as well [which is a 1:1 replacement of what you have done in Python]. Also, Python here is not used in the context of it's AI/ML prowess i.e. you are not using it for data exploration, analysis, aggregation, cleaning, model training etc.

So, the question is really long-term maintainability v/s short-term agility. From a long-term pov, I would suggest you move to AWS Java SDK and Langachain for java and convert your lambda to Java as well, this will help harmonise the tech skills required to maintain the E2E stack.

Hope this answers your question!

Thanks

profile pictureAWS
Rama
answered 3 months ago
profile picture
EXPERT
reviewed a month ago
  • Hi!

    I see, yeah for long-term maintainability I was thinking of Java at least for this RAG approach. So I will build it in Java then. If in the future we need to do data exploration, analysis, aggregation, cleaning, model training etc. I could create another service in Python focused on that side and communicate it with the one in Java if needed right?

  • Hi

    For data exploration, analysis, aggregation, cleaning, model training building a service in AWS Lambda is not a good fit [it has a 15 min timeout- not suitable for long running jobs]. You may want to use python as your primary programming language with Glue, SageMaker, EMR, ECS etc. These are the services which offer the ability to handle data processing for ML at scale.

    So, you can continue to use Lambda to form a backend for your web application, this can continue to be in Java. Lambda will then work with the data/ML outputs created by Glue, SageMaker, EMR, ECS etc.

    You can look at a simple example on this blog https://aws.amazon.com/blogs/machine-learning/call-an-amazon-sagemaker-model-endpoint-using-amazon-api-gateway-and-aws-lambda/

    Thanks

  • Thank you so much Rama! ;)

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