简体   繁体   English

在 GKE 中,如何使用负载均衡器最小化连接时间

[英]In GKE, how to minimize connect time with Load balancer

In GKE, for cost-saving, I usually put the node number to zero.在 GKE 中,为了节省成本,我通常将节点号设为零。 When I autoscale nodes(or say add) and run the pods.当我自动缩放节点(或说添加)并运行 pod 时。 It takes more than 6-7 mins to connect to Loadbalancer and up the URL.连接到 Loadbalancer 并启动 URL 需要 6-7 分钟以上。 That's why health checks in the waiting state.这就是为什么在等待的 state 中进行健康检查的原因。 Is there any way to reduce the time?有什么办法可以减少时间吗? Thanks谢谢

In short not really.总之不是真的。 Spinning up time of nodes is not easily controlled, basically it is the time that will take for the VM to be allocated, turned on, boot the OS and do some other stuff related to Kubernetes (like configuration, adding to node pool, etc) this takes time.节点的启动时间不容易控制,基本上是分配、打开、启动操作系统和做一些其他与 Kubernetes 相关的事情(如配置、添加到节点池等)所需的时间这需要时间。 In addition to Pods spinning up time which depends on the Docker image (size/dependencies etc).除了取决于 Docker 映像(大小/依赖性等)的 Pod 旋转时间。

Scaling down your application to zero nodes is not very recommended.不建议将您的应用程序缩减到零节点。 It is always recommended to have some nodes up (don't you have other apps running on the GKE cluster? Kubernetes clusters are recommended to have at least 3 nodes running).始终建议启动一些节点(您没有在 GKE 集群上运行其他应用程序吗?Kubernetes 集群建议至少运行 3 个节点)。

Have you considered using Cloud Functions?您是否考虑过使用 Cloud Functions? Is it possible in your case?你的情况有可能吗? This the the best option I know of for a quick scale up and zero scale down.这是我所知道的快速放大和零缩小的最佳选择。 And in general you can keep some kind of “ping” to the function to keep it “hot” for a relatively cheap price.通常,您可以对 function 保持某种“ping”,以相对便宜的价格使其保持“热”。

If none of the options above is possible (id say keeping your node pool with at least 3 nodes operating, is best as it is takes time for the Kubernetes control plan to boot).如果上述选项均不可行(例如,保持您的节点池至少有 3 个节点在运行,这是最好的,因为 Kubernetes 控制计划启动需要时间)。 I suggest starting with reducing the spinning up time of your Pods by improving the Docker image - reducing its size etc.我建议首先通过改进 Docker 图像来减少 Pod 的旋转时间 - 减小其大小等。

Here are some articles on how to reduce Docker image size这里有一些关于如何减小 Docker 图像大小的文章

https://phoenixnap.com/kb/docker-image-size https://phoenixnap.com/kb/docker-image-size

https://www.ardanlabs.com/blog/2020/02/docker-images-part1-reducing-image-size.html https://www.ardanlabs.com/blog/2020/02/docker-images-part1-reducing-image-size.html

After that I will experiment with different machine types for node to check which one is spinning the fastest - could be an interesting thing to do in any case之后,我将为节点试验不同的机器类型,以检查哪个机器旋转得最快——无论如何这可能是一件有趣的事情

Here is an interesting comparison on VM spinning up times这是一个关于虚拟机启动时间的有趣比较

https://www.google.com/amp/s/blog.cloud66.com/part-2-comparing-the-speed-of-vm-creation-and-ssh-access-on-aws-digitalocean-linode-vexxhost-google-cloud-rackspace-packet-cloud-a-and-microsoft-azure/amp/ https://www.google.com/amp/s/blog.cloud66.com/part-2-comparing-the-speed-of-vm-creation-and-ssh-access-on-aws-digitalocean-linode- vexxhost-google-cloud-rackspace-packet-cloud-a-and-microsoft-azure/amp/

If Cloud Functions is not an option, you might want to look at Cloud Run (which supports containers and scales to zero) or GKE Autopilot (which does not scale to zero, but you can scale down to low resource and it will autoscale up and down as needed)如果 Cloud Functions 不是一个选项,您可能需要查看 Cloud Run(支持容器并缩放到零)或 GKE Autopilot(不缩放到零,但您可以缩减到低资源,它会自动扩展和根据需要向下)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM