为什么需要启用负载均衡器才能在GCP中为App Engine启用Cloud CDN?

huangapple go评论90阅读模式
英文:

Why do I need to enable LoadBalancer to enable Cloud CDN for App Engine in GCP?

问题

我目前正在使用Google Cloud Platform中的App Engine,我想要为我的应用程序使用Cloud CDN。在Google Cloud文档中提到,我需要启用负载均衡器才能在App Engine中使用Cloud CDN。当我正在使用无服务器的App Engine时,为什么需要启用负载均衡器?能有人解释一下。

英文:

I am currently using App Engine in gcp,I want is use cloud CDN for my application. In the google cloud docs it is mentioned that i need to enable load balancer to use Cloud CDN for App Engine. Why should I enable load balancer when I am using app engine which is serverless. can someone explain.

答案1

得分: 2

其他回答/评论很好,但您问了“为什么”,所以我将尝试回答。

那么,为什么需要这样做?

因为您需要告诉GCP如何在您的GCP服务之间路由流量,在GCP中,此配置存储在Google Cloud Load Balancer中。

您是正确的,GCP的许多服务(如App Engine)都配备了负载均衡器,可以将其视为Google Cloud Load Balancer的简化版本。它已配置为一些合理的默认设置,并且可以让您立即开始运行,而无需考虑它。您可以从App Engine的设置/ yaml文件中设置一些基本设置,但如果要进行更多设置,那么您需要按照设置Google Cloud Load Balancer的过程进行操作。似乎Cloud CDN并不附带默认的负载均衡器。

我认为,当您为App Engine设置Google Cloud Load Balancer时,它会取代App Engine的默认负载均衡器。我不得不为我的App Engine服务设置Google Cloud Load Balancer,我并没有注意到速度减慢。但是,我认为您不一定需要将App Engine的流量路由通过Google Cloud Load Balancer,只要Cloud CDN位于不同的子域上。

我确实认为John Hanley关于Cloud CDN可能过于复杂的观点是正确的。您可以直接从Google Cloud Storage存储桶中提供静态资产,或者通过在app.yaml中指定static_files条目来实现。这两个选项都更简单且运作良好。

英文:

The other answers/comments are good, but you're asking 'why' so I'm going to try to answer that.

So why do you need to do this?

Because you need to tell GCP how to route traffic between your GCP services and in GCP that configuration lives in Google Cloud Load Balancer.

You were correct that many of GCP's services like App Engine come with a load balancer, think of it as a simplified version of Google Cloud Load Balancer. It comes configured with a bunch of reasonable default settings and lets you get up and running without needing to think about it. There are some basic settings you can set from within App Engine's settings / yaml files, but anything beyond that then you need to go through the process of setting up Google Cloud Load Balancer yourself. It seems that Cloud CDN doesn't come with a default load balancer.

I believe that when you setup Google Cloud Load Balancer for App Engine, that it takes the place of App Engine's default load balancer. I had to setup Google Cloud Load Balancer for my App Engine service and I didn't notice a slow down. But also, I don't think you necessarily need to have your App Engine traffic route through Google Cloud Load Balancer, as long as Cloud CDN is on a different subdomain.

I do believe that John Hanley was correct about Cloud CDN probably being overkill. You can serve static assets directly out of a Google Cloud Storage bucket or by specifying a static_files entry in your app.yaml. Both of those options are simpler and work well.

答案2

得分: 1

根据此官方文档

Cloud CDN(内容传送网络)使用Google的全球边缘网络来为用户提供更近的内容,从而加速您的网站和应用程序。Cloud CDN与全球外部HTTP(S)负载均衡器或全球外部HTTP(S)负载均衡器(经典版)一起工作,向用户交付内容。

> 外部应用负载均衡器提供前端IP地址和接收请求的端口,以及响应请求的后端。
>
> 当用户从外部应用负载均衡器请求内容时,请求会到达尽可能靠近用户的Google边缘网络的GFE。
>
> 如果负载均衡器的URL映射将流量路由到配置了Cloud CDN的后端服务或后端存储桶,那么GFE将使用Cloud CDN。

您可以使用HTTP(S)负载均衡器将静态流量路由到Cloud Storage存储桶,并将Web用户或API客户端路由到您的无服务器后端。这使您能够快速为经常访问的内容提供CDN服务,更靠近用户。

如上所述,要在无服务器源中使用Cloud CDN,您只需在包含无服务器NEG的后端服务上启用Cloud CDN。因此,您需要配置负载均衡器以在GCP中为App Engine启用Cloud CDN。

英文:

As per this official doc

Cloud CDN (Content Delivery Network) uses Google's global edge network to serve content closer to users, which accelerates your websites and applications. Cloud CDN works with the global external HTTP(S) load balancer or the global external HTTP(S) load balancer (classic) to deliver content to your users.

> The external Application Load Balancer provides the frontend IP
> addresses and ports that receive requests and the backends that
> respond to the requests.
>
> When a user requests content from an external Application Load
> Balancer, the request arrives at a GFE that is at the edge of Google's
> network as close as possible to the user.
>
> If the load balancer's URL map routes traffic to a backend service or
> backend bucket that has Cloud CDN configured, the GFE uses Cloud CDN

You can use the HTTP(S) Load Balancer to route static traffic to your Cloud Storage bucket and your web users or API clients to your serverless backend. This allows you to make the CDN
quickly serving regularly accessed content, closer to users.

As explained above, in order to use Cloud CDN with your serverless origin you can simply enable Cloud CDN on the backend service that contains your serverless NEG. So you need to configure LoadBalancer to enable Cloud CDN for App Engine in GCP.

huangapple
  • 本文由 发表于 2023年6月19日 17:25:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76505295.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定