如何将 spark AlsModel 部署到 spring 引导微服务中
How can I deploy a spark AlsModel into a spring boot microservice
我想使用 spring 启动创建一个微服务,该微服务能够提供使用之前训练过的 AlsModel 提出的建议。 (与 apache spark mllib 协同过滤)
AlsModel 在不适合生产用例的完全独立的环境中进行训练。我们有方法将存储在 hdfs 中的文件或数据传输到我们的服务层(作为文件或传输 sql 数据库中的数据)。
我知道我可以只保存用户和项目特征数据帧,传输它们然后自己计算预测,但我想要一个更简单的解决方案来很好地处理定期更新。在我看来,过程如下:
- 在 spark 集群中训练模型
- 将模型保存到文件(pmml 格式??)
- 将文件传输到服务层
- spring 引导微服务只是在某些框架的帮助下加载文件(不引入 spark 依赖项)
- 享受 spring-boot 让一切变得简单的魔法 ;-)
如果您不想将 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 调用
- https://community.cloudera.com/t5/Community-Articles/How-to-Submit-Spark-Application-through-Livy-REST-API/ta-p/247502
- https://livy.apache.org/
- https://livy.apache.org/examples/
- https://github.com/vaquarkhan/apache-livy-spark-spring-app
2) 选项 2 您可以创建 springboot 应用程序并在内部使用 apache spark 和 运行 您的工作,但在这里您可以有一些限制。
我想使用 spring 启动创建一个微服务,该微服务能够提供使用之前训练过的 AlsModel 提出的建议。 (与 apache spark mllib 协同过滤) AlsModel 在不适合生产用例的完全独立的环境中进行训练。我们有方法将存储在 hdfs 中的文件或数据传输到我们的服务层(作为文件或传输 sql 数据库中的数据)。 我知道我可以只保存用户和项目特征数据帧,传输它们然后自己计算预测,但我想要一个更简单的解决方案来很好地处理定期更新。在我看来,过程如下:
- 在 spark 集群中训练模型
- 将模型保存到文件(pmml 格式??)
- 将文件传输到服务层
- spring 引导微服务只是在某些框架的帮助下加载文件(不引入 spark 依赖项)
- 享受 spring-boot 让一切变得简单的魔法 ;-)
如果您不想将 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 调用
- https://community.cloudera.com/t5/Community-Articles/How-to-Submit-Spark-Application-through-Livy-REST-API/ta-p/247502
- https://livy.apache.org/
- https://livy.apache.org/examples/
- https://github.com/vaquarkhan/apache-livy-spark-spring-app
2) 选项 2 您可以创建 springboot 应用程序并在内部使用 apache spark 和 运行 您的工作,但在这里您可以有一些限制。