Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use advanced functions? #42

Open
FeiYuJun opened this issue Apr 22, 2022 · 3 comments
Open

How to use advanced functions? #42

FeiYuJun opened this issue Apr 22, 2022 · 3 comments

Comments

@FeiYuJun
Copy link

I don't know where to configure service elastic scaling. Can you write a specific exampl?

@cuigh
Copy link
Owner

cuigh commented Apr 22, 2022

You must enable Prometheus in system settings. Swirl use service labels to support autoscaling. For example:
image

@FeiYuJun
Copy link
Author

FeiYuJun commented Apr 22, 2022

swirl.scale标签配置
image
cpu监控值
image
创建服务

docker service create \
    --name control_dutall-cloud-control-api-impl \
    --publish mode=ingress,target=9098,published=5004,protocol=tcp \
    --env 'JARMEM=512M' \
    --env 'JARPORT=9098' \
    --label 'swirl.scale=min=1,max=5,cpu=1:100' \
    --container-label 'com.docker.stack.namespace=control' \
    --mount type=volume,source=vl_dutalljava,destination=/home/log/ \
    --update-parallelism 1 \
    --update-delay 1m0s \
    --update-failure-action pause \
    --update-order stop-first \
    --rollback-parallelism 1 \
    --rollback-delay 10s \
    --rollback-failure-action pause \
    --rollback-order stop-first \
    --restart-condition on-failure \
    --restart-delay 5s \
    --restart-max-attempts 2 \
    --restart-window 2m0s \
    dutall-cloud-control-api-impl:test-18

问题:

  1. 如上图,我已经配置了 swirl.scale标签,同时对应的服务cpu监控值也获取到了,但不知道哪里有问题,服务没有执行扩容?
  2. 暂时只有更具cpu来触发是吗?
  3. 多久检测一次cpu是否触发条件?
  4. cpu=30:50 意思是,触发伸缩条件是: 30< cpu值 <50
  5. cpu触发值设置,有什么最佳区间值吗?

@cuigh
Copy link
Owner

cuigh commented Apr 24, 2022

  • 暂时只支持根据 CPU 触发,因为我还没找到其它因子的普适应用场景。
  • Swirl 会每分钟检测一次,如果服务在 1 分钟内的平均 CPU 达到指定阈值,就会进行伸缩,这个动作默认每 3 分钟最多执行一次(可通过 window 参数配置)。
  • cpu=30:50 表示当 CPU 占用大于 50% 时,服务将会进行扩容(一次增加一个或多个实例,可通过 step 参数进行配置),当 CPU 占用下降到小于 30% 时,服务将会进行收缩(一次减少一个或多个实例,可通过 step 参数进行配置)。所以你的问题应该是出在 cpu=1:100 这个设置上,服务的 CPU 占用从没有达到扩容的阈值。CPU 的触发值设置得根据服务自身的常规占用率、峰值占用率和集群的总体资源情况进行设置,上限和下限适当拉开距离,比如 cpu=20:60。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants