如何将 spark AlsModel 部署到 spring 引导微服务中

How can I deploy a spark AlsModel into a spring boot microservice

我想使用 spring 启动创建一个微服务,该微服务能够提供使用之前训练过的 AlsModel 提出的建议。 (与 apache spark mllib 协同过滤) AlsModel 在不适合生产用例的完全独立的环境中进行训练。我们有方法将存储在 hdfs 中的文件或数据传输到我们的服务层(作为文件或传输 sql 数据库中的数据)。 我知道我可以只保存用户和项目特征数据帧,传输它们然后自己计算预测,但我想要一个更简单的解决方案来很好地处理定期更新。在我看来,过程如下:

如果您不想将 spark lib 包含到您的 spring 启动应用程序中。

你可以试试mleap

Deploying machine learning data pipelines and algorithms should not be a time-consuming or difficult task. MLeap allows data scientists and engineers to deploy machine learning pipelines from Spark and Scikit-learn to a portable format and execution engine.

因此您可以使用 mleap 读取 spark 模型,并在您的 spring 启动应用程序中使用它。

有关更多用例,您可以查看此项目sagemaker-sparkml-serving-container。 Amazon SageMaker 还开发了一个完全基于 Java 的服务设置,由 mleap-runtime

提供支持

您有两种可能的解决方案:

1) 使用 Spring 引导应用程序并创建微服务,在微服务内部使用 rest 模板并对 Apache Livy 进行 rest 调用

2) 选项 2 您可以创建 springboot 应用程序并在内部使用 apache spark 和 运行 您的工作,但在这里您可以有一些限制。