首页 > 解决方案 > 如何使用部署在 Kubernetes 上的服务的延迟来扩展部署?

问题描述

我在 GCP 上的 Kubernetes 上部署了一个简单的 Spring Boot 应用程序。该服务暴露给外部 IP 地址。我正在使用 JMeter 对该应用程序进行负载测试。它只是一个返回or的 httpGET请求。TrueFalse

我想随着时间的推移获取延迟指标,以将其提供给 Horizo​​ntalPodAutoscaler 以实现自定义自动缩放器。我该如何实施?

标签: kubernetesgoogle-cloud-platformprometheuslatencygoogle-cloud-stackdriver

解决方案


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

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.

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.

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.

enter image description here


推荐阅读