大网数据广告活动
服务器运维问答

Horizontal autoscaling rails on GKE - specifically - web server choices and differences with conventional deployments

· 52CE 我爱测

Here's a great writeup on scaling with heroku (and it applies to traditional deployments). Given that we want containerized applications to be single process, how do we get: slow client protection slow response protection in a Ku…

问题原文

原帖链接 · kross · CC BY-SA 3.0

Here's a great writeup on scaling with heroku (and it applies to traditional deployments).

Given that we want containerized applications to be single process, how do we get:

  • slow client protection
  • slow response protection

in a Kubernetes/GKE environment that takes full advantage of horizontal pod autoscaling?

Assume my deployment looks much like the following (credit @nithinmallya4):

I have not yet selected a web server, and by default rackup is serving WEBrick. I was considering just changing this to multi-threaded Puma.

My concern is that the autoscaler works based on CPU, not based on an idea that it is consumed by a current http/s request, so it may not come into play.

  1. Am I understanding the autoscaler correctly?
  2. What is the ideal scale up/down architecture?

Our current thoughts:

  • nginx in a pod sidecar pattern (with a gzip deflater) behind an Ingress.

  • puma in front of rails (in the same image as rails-api), assuming that it would better utilize cpu and trigger autoscale

  • custom metrics for HPA (still need to research this with 1.8)

已采纳解答

原帖链接 · Maks Osowski · CC BY-SA 3.0

On GKE we have been supporting HPA with custom metrics since version 1.9. If you have a group of horizontally autoscaled pods inside your cluster each exporting a custom metric then you can set an average per pod target for that metric.

An example of that would be an autoscaled deployment of a frontend where each replica exports its current QPS. One could set the average target of QPS per frontend pod and use the HPA to scale the deployment up and down accordingly. You can find the documentation and a tutorial explaining how to set this up here: https://cloud.google.com/kubernetes-engine/docs/tutorials/custom-metrics-autoscaling

Kubernetes 1.10 becoming available on GKE will extend the support for custom metrics to include metrics not attached to any Kubernetes object. This will give you the ability to scale a deployment based on any metric listed here, for example number of messages in Google Pub/Sub queue.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-09-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。