Google Cloud (GCP)

3 Mins Read

Understanding Network Endpoint Groups (NEGs) in Google Cloud Load Balancing

Voiced by Amazon Polly

Introduction

Google Cloud Load Balancing is a powerful and flexible solution for distributing traffic across multiple backend instances. In this blog, we will explore Network Endpoint Groups (NEGs), their role in load balancing, and how we configured them in our recent lab experiment.

Stand out from the competition. Upskill with Google Cloud Certifications.

  • Certified Instructors
  • Real-world Projects
Enroll now

What are Network Endpoint Groups (NEGs)?

Network Endpoint Groups (NEGs) are a crucial component in Google Cloud that allow load balancers to route traffic to specific endpoints, such as Cloud Run services, Cloud Functions, or App Engine instances. Unlike traditional backend instance groups, NEGs enable granular traffic routing and better integration with serverless computing.

Types of NEGs:

  1. Zonal NEGs – Used for VM instances with specific network interfaces.
  2. Internet NEGs – Used for backend services hosted outside Google Cloud.
  3. Serverless NEGs – Used for Cloud Run, App Engine, and Cloud Functions.

Why Use NEGs?

  • Fine-grained traffic control: NEGs allow routing traffic to individual services rather than entire instance groups.
  • Multi-region support: NEGs enable distribution of traffic across multiple regions for better availability.
  • Serverless integration: They seamlessly integrate with Cloud Run, App Engine, and Cloud Functions.
  • Optimized performance: Load balancing decisions can be made closer to the request origin, reducing latency.

Lab Exercise: Configuring a Load Balancer with NEGs

Objective

To create an external HTTP Load Balancer with serverless NEGs as backends for routing traffic to multiple Cloud Run services.

Steps Performed

  1. Create Cloud Run Services

We deployed two Cloud Run services in different regions:

# Deploy service in us-central1

# Deploy service in asia-south1

 

  1. Create Serverless NEGs

# Create NEG for us-central1

# Create NEG for asia-south1

  1. Create Backend Services and Attach NEGs

# Create backend service for us-central1

# Create backend service for asia-south1

  1. Create URL Map and HTTP Proxy

# Create URL map

# Create HTTP proxy

  1. Create a Global Forwarding Rule

 

  1. Test the Load Balancer

Once the setup was complete, we obtained the external IP of the forwarding rule and tested it using a browser or cURL command:

curl http://[EXTERNAL_IP]

Observations

  • We observed that traffic was correctly distributed between the two Cloud Run services based on regional availability.
  • The Load Balancer provided a single entry point for multiple backend services hosted in different regions.
  • By using NEGs, we achieved a serverless, scalable, and efficient load-balancing solution.

Conclusion

NEGs provide a powerful mechanism to integrate Google Cloud Load Balancing with serverless and hybrid environments. Our lab experiment demonstrated how NEGs can be used to route traffic efficiently between multiple Cloud Run services deployed across different regions. By leveraging NEGs, organizations can optimize performance, improve availability, and achieve a seamless user experience.

Next Steps

  • Explore additional routing configurations using URL maps.
  • Implement health checks for backend services.
  • Enable logging and monitoring

Freedom Month Sale — Discounts That Set You Free!

  • Up to 80% OFF AWS Courses
  • Up to 30% OFF Microsoft Certs
Act Fast!

About CloudThat

CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.

WRITTEN BY Laxmi Sharma

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!