Améliorer le temps de réponse de la passerelle en tirant parti de Cloud CDN
Utiliser un NEG sans serveur pour API Gateway
Un groupe de points de terminaison du réseau (NEG) spécifie un groupe de points de terminaison backend pour un équilibreur de charge. Un NEG sans serveur est un backend qui pointe vers un backend sans serveur hébergé par Google, comme Cloud Run, App Engine ou API Gateway.
Un backend de NEG sans serveur pour API Gateway peut représenter :
Une instance API Gateway
Groupe de passerelles configurées avec la même configuration d'API
La figure ci-dessous montre comment les NEG sans serveur peuvent être utilisés dans le modèle Cloud Load Balancing :
Comme illustré dans un exemple précédent, un service de backend peut être géré par plusieurs NEG sans serveur. Chaque NEG sans serveur peut contenir une seule instance API Gateway ou utiliser un masque d'URL pour pointer vers plusieurs passerelles. Étant donné que tous les NEG agissant en tant que service de backend sont utilisés pour l'équilibrage de charge, ils doivent représenter des déploiements de passerelle fonctionnellement équivalents. Par exemple, tous les NEG doivent avoir la même configuration d'API déployée sur chaque passerelle dans différentes régions. Si un service de backend contient plusieurs NEG, l'équilibreur de charge équilibre le trafic entre ces NEG tout en minimisant la latence des requêtes.
Limites sur les NEG sans serveur et API Gateway
Certaines limites doivent être prises en compte lorsque vous utilisez des NEG sans serveur pour intégrer Cloud Load Balancing à API Gateway. En particulier :
Les NEG sans serveur ne peuvent pas être associés à des points de terminaison réseau, tels que des adresses IP ou des ports.
Les NEG sans serveur peuvent uniquement pointer vers des instances API Gateway résidant dans la même région que le NEG.
Les NEG sans serveur peuvent uniquement pointer vers des instances API Gateway créées dans le même projet que l'équilibreur de charge à l'aide du backend de NEG sans serveur.
API Gateway n'est pas compatible avec les paramètres de contrôle Ingress. Par conséquent, il n'est pas possible de désactiver l'accès à votre passerelle API à l'aide d'une URL de passerelle générée par le service et de s'assurer que tout le trafic est géré par l'équilibreur de charge.
Pour en savoir plus sur les restrictions concernant les NEG sans serveur et les services de backend en général, consultez Limites.
Limites sur les NEG sans serveur dans les configurations de service de backend
Un service de backend définit la manière dont Cloud Load Balancing répartit le trafic. La configuration du service de backend contient un ensemble de valeurs, telles que le protocole utilisé pour se connecter aux backends, divers paramètres de répartition et de gestion des sessions, les vérifications d'état et les délais avant expiration. Pour les NEG sans serveur utilisés comme service de backend pour API Gateway, ces paramètres permettent de contrôler précisément le comportement de votre équilibreur de charge.
La définition des ressources d'un service de backend a les conséquences suivantes pour votre conception d'équilibrage de charge :
Les NEG sans serveur ne peuvent pas être utilisés avec d'autres types de NEG dans le même service de backend. Par exemple, vous ne pouvez pas accéder à un cluster GKE et à une instance API Gateway à partir du même service de backend.
Tous les NEG sans serveur combinés dans un service de backend doivent utiliser le même type de backend. Cela signifie que les NEG sans serveur API Gateway ne peuvent être associés qu'à d'autres NEG sans serveur API Gateway, et que les NEG sans serveur App Engine ne peuvent être associés qu'à des NEG sans serveur App Engine.
Un service de backend ne peut contenir qu'un seul NEG sans serveur par région.
Lorsque vous définissez une configuration de service de backend qui dirige vers un NEG sans serveur, les limitations suivantes s'appliquent :
Impossible de spécifier balancingMode.
Le champ healthCheck doit être vide et ne peut pas être spécifié.
Les ports ne peuvent pas être spécifiés.
Seuls les protocoles HTTP et HTTPS sont acceptés.
Les valeurs spécifiées dans les champs liés à utilization ou connection ne sont pas acceptées.
Les champs IAP, cdnPolicy et securityPolicy de la configuration du service de backend sont valides pour les NEG sans serveur. Ces champs peuvent être utilisés pour configurer respectivement Identity-Aware Proxy, Cloud CDN et Cloud Armor avec votre service API Gateway.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/03 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/03 (UTC)."],[[["\u003cp\u003eAPI Gateway can integrate with Global external Application Load Balancer or Classic Application Load Balancer through serverless Network Endpoint Groups (NEGs) to leverage Cloud Load Balancing features.\u003c/p\u003e\n"],["\u003cp\u003eServerless NEGs for API Gateway can represent either a single API Gateway instance or a group of gateways sharing the same API configuration, enabling load balancing between functionally equivalent deployments.\u003c/p\u003e\n"],["\u003cp\u003eThere are several limitations to serverless NEGs for API Gateway, including restrictions on network endpoints, regional scope, and project constraints, along with an inability to disable direct access to API Gateways.\u003c/p\u003e\n"],["\u003cp\u003eBackend services that use serverless NEGs have specific configuration limitations, such as not being able to mix different types of NEGs, and restrictions on \u003ccode\u003ebalancingMode\u003c/code\u003e, \u003ccode\u003ehealthCheck\u003c/code\u003e, ports, protocols, \u003ccode\u003eutilization\u003c/code\u003e, or \u003ccode\u003econnection\u003c/code\u003e-related field settings.\u003c/p\u003e\n"],["\u003cp\u003eDespite the limitations, backend service configurations allow for the integration of Identity-Aware Proxy, Cloud CDN, and Cloud Armor with API Gateway through serverless NEGs.\u003c/p\u003e\n"]]],[],null,["# Load balancing for API Gateway\n==============================\n\n|\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThe integration of [Global external Application Load Balancer](/load-balancing/docs/https) and [Classic Application Load Balancer](/load-balancing/docs/https) support for API Gateway enables your serverless backends to take advantage of all the features provided by Cloud Load Balancing. By combining API Gateway with a global external Application Load Balancer or classic Application Load Balancer using a [serverless Network Endpoint Group (serverless NEG)](/load-balancing/docs/negs), you can:\n\n- Host gateways with custom branded domains\n- Configure TLS for gateways using certificates issued by a preferred certificate authority\n- Create a common entry point for a gateway routing to multiple backends\n- Deploy gateways in multiple geographic regions for high availability without managing URLs for each region\n- Protect gateways with [Cloud Armor](/armor/docs)\n- Improve gateway response time by leveraging [Cloud CDN](/cdn/docs)\n\nUsing a serverless NEG for API Gateway\n--------------------------------------\n\nA [network endpoint group (NEG)](/load-balancing/docs/negs) specifies a group of backend endpoints for a load balancer. A *serverless NEG* is a backend that points to a Google-hosted serverless backend like [Cloud Run](/run/docs), [App Engine](/appengine/docs), or API Gateway.\nA serverless NEG backend for API Gateway can represent:\n\n- An API Gateway instance\n- A group of gateways configured with the same API config\n\nThe following figure shows how serverless NEGs can be used in the Cloud Load Balancing model:\n\nAs illustrated in an earlier example, a backend service can be managed by several serverless NEGs. Each serverless NEG can contain a single API Gateway instance or use a [URL mask](/load-balancing/docs/negs/serverless-neg-concepts#url_masks) to point to multiple gateways. Because all NEGs acting as a backend service are used for load balancing, they should represent functionally equivalent gateway deployments. For example, all NEGs should have the same API config deployed to each gateway in different regions. If a backend service contains several NEGs, the load balancer will balance traffic between these NEGs while minimizing request latency.\n\nLimitations on serverless NEGs and API Gateway\n----------------------------------------------\n\nA few limitations should be considered when using serverless NEGs to integrate Cloud Load Balancing for API Gateway. Most notably:\n\n- Serverless NEGs cannot have any [Network Endpoints](/compute/docs/reference/rest/v1/networkEndpointGroups/attachNetworkEndpoints), such as IP addresses or ports, attached.\n- Serverless NEGs can only point to API Gateway instances residing in the same region where the NEG is created.\n- Serverless NEGs can only point to API Gateway instances created in the same project as the load balancer using the Serverless NEG backend.\n- API Gateway doesn't support Ingress control settings. As a result, there is no way to disable access to your API Gateway using a service-generated gateway URL and ensure that all traffic is handled by the load balancer.\n\nFor more information on restrictions pertaining to serverless NEGs and backend services generally, see [Limitations](/load-balancing/docs/negs/serverless-neg-concepts#limitations).\n\nLimitations on serverless NEGs in backend service configurations\n----------------------------------------------------------------\n\nA [backend service](/compute/docs/reference/rest/v1/backendServices) defines how Cloud Load Balancing distributes traffic. The backend service configuration contains a set of values, such as the protocol used to connect to backends, various distribution and session settings, health checks, and timeouts. For serverless NEGs used as a backend service for API Gateway, these settings provide fine-grained control over how your load balancer behaves.\n\nThe resource definition of a backend service has the following implications for your load balancing design:\n\n- Serverless NEGs cannot be used with other types of NEGs in the same backend service. For example, you cannot route to a GKE cluster and an API Gateway instance from the same backend service.\n- All serverless NEGs combined in a backend service must use the same type of backend. This means API Gateway serverless NEGs can only be combined with other API Gateway serverless NEGs, App Engine serverless NEGs can only be combined with App Engine serverless NEGs.\n- A backend service may only contain one Serverless NEG per region.\n\nWhen defining a backend service configuration that routes to a serverless NEG, the following field limitations apply:\n\n- The `balancingMode` cannot be specified\n- The `healthCheck` field must be empty and cannot be specified\n- Ports cannot be specified\n- Only HTTP and HTTPS protocols are supported.\n- Values specified in `utilization` or `connection`-related fields are not supported.\n\nThe `IAP`, `cdnPolicy`, and `securityPolicy` fields in the backend service configuration are valid for serverless NEGs. These fields can be used to set up [Identity-Aware Proxy](/iap/docs), [Cloud CDN](/cdn/docs), and [Cloud Armor](/armor/docs) respectively with your API Gateway service.\n\nWhat's next?\n------------\n\n- Configure a load balancer with [Getting started with global external Application Load Balancer for API Gateway](/api-gateway/docs/gateway-serverless-neg)\n\n- Walk through [Creating multi-region deployments](/api-gateway/docs/multi-region-deployment) for API Gateway\n\n- Learn more about [Using custom domains](/api-gateway/docs/using-custom-domains)"]]