简体   繁体   中英

Calling Python machine learning service from Java as an OS process or micro service via REST

I am building a web application for business management as a side project and i face an architecture problem. My application will be an Angular web client communicating with a kotlin/java spring back-end via REST. One of the modules of the application will be time series forecasting of sales/orders, and because of the ease of development and the piles of documentation that exists online, i want to build that module in python. That module will generate dynamic html plots that i want to serve to the client. So my question is, it would be better if i do the python part as a stand alone rest micro service with Flask or it's ok to just put the python code inside the java project and call it using ProcessBuilder? Thanks in advance :)

My view will be to create a microservice with Python Flask with certain REST endpoints for obtaining the results and let java application interact with python based microservice for machine learning. The main advantage with this approach will be the separation of concern and deployment will be independent and you can leverage the benefits of microservice architecture.

Although it is also possible to bundle python code inside java or you can use jython, any changes in either in java code or in python code will add extra overhead for deployment. Bundling additional non java code will be another overhead for different OS systems like Windows, Mac and Linux.

You can check the following links for reference.

https://www.datacamp.com/community/tutorials/machine-learning-models-api-python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM