3 Tier Application Workflow - DevOps Perspective

3 Tier Application Workflow - DevOps Perspective

After hitting URL in the browser what goes behind the scene from DevOps Engineer point of view.

Components Involved in a 3-Tier Architecture

  • Frontend (Presentation Layer): The user interface, typically a web application running in a browser.

  • Backend (Application Layer): The business logic and application processing.

  • Database (Data Layer): The storage of data

Request Flow

  1. User Request from Browser:

    • The user types the URL of the web application into the browser or interacts with the web app to perform a search.
  2. DNS Resolution:

    • The browser sends a DNS query to resolve the domain name (e.g., www.example.com) to an IP address.

    • The DNS server responds with the IP address of the load balancer or the ingress controller.

  3. Load Balancer:

    • The request hits a load balancer (e.g., AWS ELB, Google Cloud Load Balancer) which distributes incoming traffic to various nodes in the Kubernetes cluster.

    • The load balancer ensures the traffic is distributed evenly based on the configured algorithm (round-robin, least connections, etc).

  4. Kubernetes Ingress Controller:

    • The load balancer forwards the request to the Kubernetes ingress controller.

    • The ingress controller (e.g., NGINX, Traefik) routes the request based on the defined ingress rules to the appropriate service.

  5. Service Routing (Frontend Service):

    • The ingress controller forwards the request to the frontend service (a Kubernetes Service of type ClusterIP or NodePort) responsible for handling HTTP/HTTPS traffic.

    • The service routes the request to one of the frontend pods (running instances of the frontend application) using a proxy (e.g., kube-proxy).

  6. Frontend Pod:

    • The frontend pod receives the request and processes it.

    • For a search query, the frontend application likely sends an internal request to the backend service.

  7. Service Routing (Backend Service):

    • The frontend application sends an internal request to the backend service (another Kubernetes Service).

    • The backend service routes the request to one of the backend pods.

  8. Backend Pod:

    • The backend pod processes the request by executing the business logic.

    • If data retrieval is required, the backend pod queries the database service.

  9. Service Routing (Database Service):

    • The backend pod sends a query to the database service (another Kubernetes Service).

    • The database service routes the request to the appropriate database pod (e.g., MySQL, PostgreSQL).

  10. Database Pod:

    • The database pod executes the query and returns the result to the backend pod.
  11. Backend Response:

    • The backend pod processes the data, applies any necessary business logic, and sends the response back to the frontend pod through the backend service.
  12. Frontend Response:

    • The frontend pod receives the data, processes it (e.g., formats it for display), and sends the final response back to the user’s browser through the frontend service and the ingress controller.
  13. User Receives Result:

    • The browser receives the response and renders the search results to the user.

Let's try to understand this from the Real time example perspective

  • User Request:

  • DNS Resolution:

  • Load Balancer:

    • The request hits the load balancer at 203.0.113.1.

    • The load balancer forwards the request to the ingress controller.

  • Ingress Controller:

    • The ingress controller matches the request to the ingress rule for www.example.com.

    • The request is forwarded to the frontend service frontend-svc.

  • Frontend Service:

    • Service type: ClusterIP

    • The service forwards the request to one of the frontend pods, e.g., frontend-pod-1.

  • Frontend Pod:

    • frontend-pod-1 processes the search request.

    • It sends an internal request to the backend service backend-svc.

  • Backend Service:

    • Service type: ClusterIP

    • The service forwards the request to one of the backend pods, e.g., backend-pod-2.

  • Backend Pod:

    • backend-pod-2 processes the request.

    • It needs to fetch data, so it sends a query to the database service db-svc.

  • Database Service:

    • Service type: ClusterIP

    • The service forwards the query to the database pod, e.g., db-pod-1.

  • Database Pod:

    • db-pod-1 executes the query and returns the result to backend-pod-2.
  • Backend Response:

    • backend-pod-2 processes the data and sends it back to frontend-pod-1.
  • Frontend Response:

    • frontend-pod-1 processes the data, formats it, and sends the final response to the user’s browser via the ingress controller.
  • User Receives Result:

    • The browser renders the search results to the user.

      “Programming is not a zero-sum game. Teaching something to a fellow programmer doesn’t take it away from you.” John Carmack