如何使用Kubernetes上部署的服务的延迟来扩展部署? [英] How to use latency of a service deployed on Kubernetes to Scale the deployment?

查看:73
本文介绍了如何使用Kubernetes上部署的服务的延迟来扩展部署?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在GCP的Kubernetes上部署了一个简单的spring boot应用程序.该服务公开给外部IP地址.我正在使用JMeter对该应用程序进行负载测试.这只是一个返回TrueFalse的http GET请求.

I have a simple spring boot application deployed on Kubernetes on GCP. The service is exposed to an external IP address. I am load testing this application using JMeter. It is just a http GET request which returns True or False.

我想随时间获取延迟指标,以将其反馈给Horizo​​ntalPodAutoscaler以实现自定义自动缩放器.我该如何实现?

I want to get the latency metrics with time to feed it to HorizontalPodAutoscaler to implement custom auto-scaler. How do I implement this?

推荐答案

由于您提到了Custom Auto Scaler.我会建议这个简单的解决方案,它利用您可能已经拥有的一些工具.

Since you mentioned Custom Auto Scaler. I would suggest this simple solution which makes use of some of tools which you already might have.

第一部分::将创建服务或cron或任何基于时间的触发器,这些触发器将定期向已部署的应用程序发出请求.然后,该应用程序会将结果指标存储到持久性存储或文件或数据库等中.

First Part: Is to Create a service or cron or any time-based trigger which will on a regular interval make requests to your deployed application. This application will then store the resultant metrics to persistence storage or file or Database etc.

例如,如果您使用简单的Apache Benchmark CLI工具(也可以使用Jmeter或生成结构化o/p的任何其他负载测试工具),则将获得单个查询的详细结果.使用此链接可以得到结果以供参考.

For example, if you use a simple Apache Benchmark CLI tool(you can also use Jmeter or any other load testing tool which generates structured o/p), You will get a detailed result for a single query. Use this link to get around the result for your reference.

第二部分是同一脚本还可以触发另一个事件,该事件将检查根据您的要求配置的延迟或响应时间限制.如果响应时间低于配置的值刻度,而响应时间低于缩小的比例.

Second Part Is that this same script can also trigger another event which will check for the latency or response time limit configured as per your requirement. If the response time is above the configured value scale if it is below scale down.

缩小规模的逻辑可能更琐碎,但我将留给您.

The logic for scaling down can be more trivial, But I will leave that to you.

现在要实际扩展部署,可以使用Kubernetes API.您可以参考官方文档或此答案以了解详细信息.这是一个简单的流程图.

Now for actually scaling the deployment, you can use the Kubernetes API. You can refer to the official doc or this answer for details. Here's a simple flow diagram.

这篇关于如何使用Kubernetes上部署的服务的延迟来扩展部署?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆