MLSQL新特性:MLSQL-Cluster预览

栏目: 后端 · 发布时间: 5年前

内容简介:MLSQL-Cluster 在v1.1.6版本中发布。随着MLSQL部署的实例愈发的增多,有给各条业务线部署的MLSQL instances group,也有给算法组,研发组等等部署的单独MLSQL instances group. 我们希望所有这些MLSQL 实例能够被:MLSQL-Cluster 实现了相关功能。架构图如下:MLSQL-Cluster 和MLSQL instances 是完全解耦的,对原有实例不需要做什么调整。你需要主动将你的MLSQL 实例信息添加到mlsql-cluster中。比如

前言

MLSQL-Cluster 在v1.1.6版本中发布。随着MLSQL部署的实例愈发的增多,有给各条业务线部署的MLSQL instances group,也有给算法组,研发组等等部署的单独MLSQL instances group. 我们希望所有这些MLSQL 实例能够被:

  1. 统一的管理
  2. 组内的负载均衡
  3. 不同组之间互相借用资源
  4. 同组内的MLSQL 实例数动态调整

MLSQL-Cluster 实现了相关功能。架构图如下:

MLSQL新特性:MLSQL-Cluster预览

WX20181205-105228@2x.png

构建MLSQL-Cluster

streamingpro-cluster
mvn -Pcluster-shade -am -pl streamingpro-cluster clean package
  1. 启动mlsql-cluster:
java -cp .:streamingpro-cluster-1.1.6-SNAPSHOT.jar tech.mlsql.cluster.ProxyApplication -config application.yml

负载均衡

MLSQL-Cluster 和MLSQL instances 是完全解耦的,对原有实例不需要做什么调整。你需要主动将你的MLSQL 实例信息添加到mlsql-cluster中。比如,我现在有一个服务器如下:

name=backend1
url=127.0.0.1:9003
tag=group1,read,write

这台服务器叫backend1, 链接地址是 127.0.0.1:9003 ,归属于group1,并且可读可写。现在我们把这个信息写入到mlsql cluster中:

curl -XPOST http://127.0.0.1:8080/backend/add -d 'name=backend1&url=127.0.0.1%3A9003&tag=read%2Cwrite'

现在,你可以不用去访问原来的9003端口,而是直接访问mlsql cluster了:

# sql=select sleep(1000) as a as t;
# tags= group1
# proxyStrategy=ResourceAwareStrategy|JobNumAwareStrategy|AllBackendsStrategy
curl -X POST \
  http://127.0.0.1:8080/run/script \  
  -H 'content-type: application/x-www-form-urlencoded' \  
  -d 'sql=select%20sleep(100000)%20as%20a%20as%20t%3B&tags=group1'

mlsql cluster 会找到所有有group1标签的MLSQL instances,然后采用某种分发策略做负载均衡。目前支持三种:

  1. ResourceAwareStrategy CPU最空闲的instance将优先获得请求
    2.JobNumAwareStrategy 任务书最少的的instance将优先获得请求
  2. AllBackendsStrategy 所有instances都将获得请求(比如一些注册表,注册信息等)

Dynamic Resoruce Allocation

MLSQL instance 如果开启DRA,那么可以实现自己内部的executor数的动态调整。MLSQ-Cluster 主要是在MLSQL 实例上做调整。比如A业务后端有两个MLSQL 实例,每个实例有10个worker节点。前者控制的是这10个worker节点,MLSQL-cluster 则控制的是实例数。为了使用该功能,你只需要通过

/monitor/add 接口添加DRA 参数:

"name" -> "jack-monitor",
          "tag" -> "jack",
          "minInstances" -> "1",
          "maxInstances" -> "3",
          "allocateType" -> "local",
          "allocateStrategy" -> "JobNumAwareAllocateStrategy"

监控名叫jack-monitor, 监控具有jack标签的组,最大最小实例数在1-3之间,新增的实例采用local模式运行,触发策略是JobNumAwareAllocateStrategy。 根据JobNumAwareAllocateStrategy策略为: 如果jack组的所有请求实例在N个周期内都一直没有空闲的,那么触发新的实例分配。

接着我们需要告诉系统,哪里有资源,这可以通过 /ecs/add 接口:

"ip" -> "127.0.0.1",
    "keyPath" -> "./ssh/private-key",
    "loginUser" -> "root",
    "name" -> "backend2",
    "sparkHome" -> "/home/spark",
    "mlsqlHome" -> "/home/mlsql",
    "mlsqlConfig" ->
      """
        |{"master":"local",
        |"name":"mlsql",
        |"conf":"spark.serializer=org.apache.spark.serializer.KryoSerializer",
        |"streaming.name":"mlsql",
        |"streaming.driver.port":"9003",
        |"streaming.spark.service":"true",
        |"streaming.platform":"spark"
        |}
      """.stripMargin,
    "executeUser" -> "webuser",
    "tag" -> "jack"

比较特殊是,我们需要proxy机器能够免密码登录到所有可以运行spark-submit命令的机器上。之后会根据这些配置启动新的实例,并且自动注册到代理列表中。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Once Upon an Algorithm

Once Upon an Algorithm

Martin Erwig / MIT Press / 2017-9-8 / GBP 22.95

How Hansel and Gretel, Sherlock Holmes, the movie Groundhog Day, Harry Potter, and other familiar stories illustrate the concepts of computing. Picture a computer scientist, staring at a screen and......一起来看看 《Once Upon an Algorithm》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

在线进制转换器
在线进制转换器

各进制数互转换器

URL 编码/解码
URL 编码/解码

URL 编码/解码