- Endpoints join and leave pools automatically as they’re created and destroyed. There’s no need to register your upstreams ahead of time.
- You can pool endpoints with different Traffic Policies. This means that not only can you blue-green and canary deploy your own apps, you can also do that with the Traffic Policies themselves. This helps you dramatically mitigate the risk of gateway changes that so often cause site-wide outages.
When to use endpoint pooling
Endpoint pooling is a good choice when you want to:- Load balance among multiple replicas of the same application, even running in different cloud providers, on-prem, and so on
- Switch from Agent Endpoints to Cloud Endpoints with no downtime (or vice-versa)
- Implement blue-green deployments to reduce risk and rollback times
- Deploy canary versions of your application
- A/B test different versions of your apps with blue-green deployments
- Gradually roll out changes to an endpoint’s Traffic Policy
Quickstart
Agent Endpoints
Create two endpoints with the same URL forwarding to two different ports. ngrok automatically pools them together.Cloud Endpoints
Create two endpoints with the same URL and two different Traffic Policies. ngrok automatically pools them together. First, create two Traffic Policy files,policy-a.yml and policy-b.yml.
policy-a.yml
policy-b.yml
Command line
Command line
Lifecycle
ngrok automatically creates an endpoint pool whenever you create two endpoints with:- The same URL
- The same binding
- Pooling enabled
Enabling pooling
Endpoint pooling is disabled by default. You enable endpoint pooling on a per-endpoint basis. You must enable pooling on each endpoint you want to pool by settingpooling_enabled to true.
Drain and close a pool
A pool exists only while two or more endpoints share its URL and binding, so you drain a pool by stopping endpoints in it. When you stop an endpoint, ngrok stops routing traffic to it, and the remaining endpoints in the pool receive all of the traffic. To list the endpoints in a pool, filter your endpoints by URL:Stop an endpoint in a pool
- Agent Endpoint: Stop the ngrok agent, or remove the endpoint from your agent configuration file or SDK code.
- Cloud Endpoint: Delete the endpoint with
ngrok api endpoints delete <endpoint_id>.
Turn a pooled endpoint into a non-pooled endpoint
You can’t turn off pooling while other endpoints share the URL, so first stop every other endpoint in the pool.-
Cloud Endpoint: After it’s the only endpoint on its URL, update it to turn pooling off.
The URL stays online throughout.
If another endpoint still shares the URL, the update fails with a
400error. -
Agent Endpoint: You can’t change pooling on a running Agent Endpoint.
Stop every Agent Endpoint in the pool, then start a new endpoint without
--pooling-enabled(or withpooling_enabled: falsein your configuration file). The URL is offline between stopping the last pooled endpoint and starting the new one.
Pool size
There’s no limit on the number of endpoints that can be in a pool.Conflicts
If you create a second endpoint with the same URL and binding as an existing endpoint, both the new endpoint and existing endpoint must have pooling enabled. If they don’t, ngrok returns a conflict error when you attempt to start the second endpoint. The URLs of all endpoints in a pool must share the same protocol. For example, you can’t pool the endpointshttps://foo.internal:1234 and tcp://foo.internal:1234 together because they have a different protocol.
For Agent Endpoints, conflicts can only occur when the endpoint starts, because you can’t change the URL or pooling setting of a running Agent Endpoint.
For Cloud Endpoints, conflicts can also occur when you update the URL or pooling setting.
Load balancing
Traffic to pooled URLs is load balanced among the endpoints in the pool. ngrok applies load balancing in two places:- When pooled public and Kubernetes endpoints load balance traffic received from external clients.
- When pooled internal endpoints receive traffic that’s forwarded to them via the
forward-internalTraffic Policy action.
Granularity
ngrok intelligently chooses the load balancing layer automatically for you. Traffic to TCP and TLS endpoints is balanced on a per-connection basis (layer 4). Traffic to HTTP and HTTPS endpoints is balanced on a per-request basis (layer 7). If multiple endpoints in a pool have differenton_tcp_connect phases in their Traffic Policy, ngrok instead load balances on a per-connection basis (layer 4).
Heterogeneous endpoints
Endpoints in a pool can have different Traffic Policies. This lets you run old and new Traffic Policies side-by-side during a transition. It also enables you to roll out new Traffic Policy changes without risking an all-or-nothing deployment. When traffic is balanced among endpoints with different Traffic Policies, ngrok first chooses an endpoint to balance to and then executes the Traffic Policy of the chosen endpoint.Default strategy
ngrok’s default balancing strategy attempts to strike a balance between performance and fairness:- First, it identifies all endpoints in the pool that are in the point of presence closest to where a connection is received.
- Then, it balances connections in a random distribution among those endpoints.
- Endpoint A: Agent Endpoint connected to
eu - Endpoint B: Agent Endpoint connected to
eu - Endpoint C: Agent Endpoint connected to
us - Endpoint D: Cloud Endpoint
- A connection received in
euis balanced among endpoints A, B, and D - A connection received in
usis balanced among endpoints C and D - A connection received in
jpis balanced to endpoint D
Custom strategies
Custom balancing strategies aren’t yet generally available, but you can request Early Access in your ngrok dashboard.
Retries
When a connection or request is balanced to an endpoint in a pool, if that connection or request fails, ngrok doesn’t retry it by sending it to another endpoint in the pool.Wildcard endpoints
Wildcard endpoints don’t pool with non-wildcard URLs. For example, if you have two endpoints online,https://foo.example.com and https://*.example.com, they don’t pool together, and traffic to https://foo.example.com isn’t load balanced.
See the documentation for wildcard endpoints to understand the rules for matching and precedence.
Protocol, binding, and type
- Endpoint pooling supports all endpoint protocols
- Endpoint pooling supports all endpoint bindings
- Endpoint pooling supports all endpoint types (and you can mix types in an endpoint pool)
API
Because ngrok creates endpoint pools on demand when two endpoints share the same URL and binding, there’s no API resource for endpoint pools. Instead, each [Endpoint API Resource](/api-reference/endpoints/list has a read-onlypools field that lists the other endpoints in the same pool as the requested endpoint.