Azure Application Gateway: A Detailed and Simple Explanation

Azure Application Gateway is a web traffic management service in Azure that works at the application layer (Layer 7) of the OSI model. It’s designed to control how traffic is distributed to different applications or services running in Azure, especially for web applications. Unlike a traditional load balancer that just distributes traffic, the Application Gateway can make smart decisions based on things like the URL or headers in the request.

Let’s break down its main components and functions in simple terms.


1. Layer 7 Load Balancing

The Application Gateway operates at Layer 7, which means it can inspect and route traffic based on the content of the requests, such as URLs, HTTP headers, or cookies. This allows it to perform more advanced load balancing for web applications.

Example:

If you have a website with different sections (e.g., /shop for shopping, /blog for a blog), the Application Gateway can route traffic to different back-end servers or services based on these URL paths.


2. URL-Based Routing

URL-based routing allows the Application Gateway to route requests to different backend servers based on the URL path. This is helpful when you have different parts of an application or multiple applications hosted on the same domain.

Example:

  • Requests to example.com/shop can be routed to one set of servers.
  • Requests to example.com/blog can be routed to another set of servers.

This ensures traffic is directed to the appropriate backend, making it easy to organize multiple applications under one gateway.


3. Web Application Firewall (WAF)

The Application Gateway includes a Web Application Firewall (WAF), which adds an extra layer of security by detecting and blocking common web vulnerabilities like SQL injection or cross-site scripting (XSS). WAF protects your web applications from known security threats.

Key Features:

  • Protects against common attacks on web applications.
  • Helps you comply with security standards like OWASP (Open Web Application Security Project).

4. SSL/TLS Termination

SSL/TLS termination offloads the SSL processing from the backend servers to the Application Gateway. This means the Application Gateway decrypts the incoming traffic, allowing it to read and route requests based on the content, and then sends it to the backend server without encryption. It can also re-encrypt traffic if needed before sending it to the backend.

Benefits:

  • Reduces the load on backend servers by handling SSL decryption at the Application Gateway level.
  • Simplifies certificate management because you only need to manage certificates at the Application Gateway rather than each server.

5. Autoscaling

Application Gateway can automatically scale up or down based on the amount of traffic it’s handling. This helps manage traffic spikes and ensures your application remains available and performs well under varying load levels without requiring manual adjustments.

Benefits:

  • Cost-effective because you only pay for the resources you need.
  • Scalable to handle high traffic without downtime.

6. Session Affinity

Session Affinity, also known as cookie-based affinity, ensures that a user’s requests are consistently routed to the same backend server for the duration of their session. This can be useful for applications that store session data on a specific server.

Example:

If a user starts interacting with a shopping cart on one server, session affinity keeps routing their requests to that same server, ensuring their shopping cart data remains available.


7. Health Probes

Health Probes check if the backend servers are working correctly. The Application Gateway regularly sends requests to each server in the backend pool to see if they’re up and running. If a server is unhealthy, the gateway will stop sending traffic to it until it recovers.

Benefits:

  • Ensures traffic is routed to healthy backend servers only.
  • Helps maintain high availability of applications.

8. Multi-Site Hosting

With multi-site hosting, you can use one Application Gateway to manage multiple domains. For example, you can set it up to route traffic for example.com to one backend pool and traffic for example2.com to another. This is efficient for managing multiple applications under different domains.


How It All Works Together: A Simple Scenario

Imagine you have an online business with three main sections on your website:

  1. Shopping section (example.com/shop).
  2. Blog section (example.com/blog).
  3. Support section (example.com/support).

Here’s how the Azure Application Gateway can handle this setup:

  • URL-Based Routing: The Application Gateway checks the URL path. Requests to /shop go to one group of servers, /blog to another, and /support to another. This ensures that traffic is directed to the correct service.
  • SSL Termination: SSL/TLS termination is done at the Application Gateway level, reducing the load on backend servers.
  • Web Application Firewall (WAF): Protects the site from attacks, ensuring that malicious traffic is blocked.
  • Session Affinity: Keeps each user’s session on the same backend server, so their data (like items in a cart) stays consistent.
  • Health Probes: Continuously check the backend servers, so if any server goes down, the Application Gateway will reroute traffic to healthy servers.

Difference Between Azure Load Balancer and Application Gateway

  • Azure Load Balancer: Works at Layer 4 (Transport Layer), distributing network traffic based on IP addresses and ports. It’s useful for evenly distributing traffic but doesn’t inspect or route based on the content.
  • Azure Application Gateway: Works at Layer 7 (Application Layer) and makes routing decisions based on URL paths, headers, and cookies, making it ideal for web applications.

Conclusion

Azure Application Gateway is designed for web applications, providing advanced routing, security, and load balancing features that help ensure high availability, scalability, and security. It’s especially useful for applications with complex routing needs, like multiple services or sections under the same application.

Comments