stock market

Client-Server Model in System Design: Concepts, Architecture & Examples

Spread the love

The client-server model is a way computers communicate over a network.

  • Client — a device or program that requests a service or information.
  • Server — a computer or program that receives the request and provides the service or information.

Example: When you open a website, your web browser is the client. It sends a request to the website’s server. The server processes the request and sends the webpage back to your browser.

  • A computing model where clients request services and server provide them .
  • Foundation of modern web , database , and application architectures
  • Why is is important ?.
    • a.Enables efficient resource management
    • b.Used in web browsing, email, APIs , databases and cloud services
  • Real world example
    • a.Browsing website
    • b.Sending emails.

Key component of client server Model

  • client
    • the user facing application that send request
    • Example: web browser, mobile app
  • Server
    • A system that processes a request and return some response 
    • Example: web server, database server, and mail server
  • Network
    • The medium that facilitates client and server communication
    • Example: internet, LAN , wi-fi 

How client and server communicate

  • Basic Steps
    • Client send a request (HTTP , Sql query)
    • Request is transmitted over the network
    • Server receive the request and process the request
    • Server send response
    • Client receives and process the response 
  • Types of communication
    • Request / Response Model(HTTP , Rest Api)
    • Persistent connections (webscoket and FTP session)

Request -Response cycle (HTTP Example)

  • Browser request https://example.com
  • DNS resolve domain to IP Address
  • Browser send an HTTP get request to the web server.
  • Web server process request, fetches HTML, queries to database if needed 
  • Server send a response with http response code and web page content
  • Browser renders the web page 
2.Synchronous vs Asynchronous Communication
  1. Synchronous communication
    • Clients waits for response before proceeding
    • Example: A user submits a form and waits for a conformation message.
    • Used in REST Apis, traditional web apps.
  • Asynchronous communications
    • Client does not wait for a response and can perform other task 
    • Example: web sockets for real time chat , Ajax call for background request
    • Used in messaging app , live updates , IOts applications 
3. Stateless and state full Servers
  • Stateless server
    • No memory of past interactions , each request is independent 
    • Example : Rest api , https servers
    • Benefits  : Scalability , easy caching , load balancing 
  • State full server
    • Maintain session information across request 
    • Example : web socket , banking application
    • Personalize  seamless user experience 
4. Forward proxy and Reverse proxy

What is proxy

  • A proxy is an intermediary server between a client and other servers.
  • Proxies help with security, caching, traffic control, and anonymity.
  • Two main types: Forward proxy & Reverse Proxy .

Forward proxy

  • Sits between a client and the internet(used by client)
    • Clients connect to the forward proxy instead of directly accessing websites
    • Can filter content, provide anonymity and cache requests.
    • Common use cases  
      • Bypassing geo restrictions
      • Anonymous browsing (VPNS, TOR)
      • Caching webpages for faster access. 

Reverse proxy.

  • Reverse proxies sits between user and backend servers(used by servers)
  • Clients don’t directly communicate with backend servers – request got through the reverse proxy.
  • Used for load balancing, caching, security, and ssl termination.
  • Common use cases  
    • Load balancing across multiple servers.
    • Caching content to improve speed.
    • DDos protection and security.
5. load balancing

Introduction to load balancing

  • Modern application must handle growing traffic.
  • A single server eventually becomes a bottleneck.
  • Load balancing enables system to scale beyond one machine.
  • It is a functional building block of distributed system.

Scaling challenges:

  • Server resources are finite.
  • Growing traffic increase latency and failure
  • Large servers help only temporarily.
  • Vertical scaling eventually reaches limits

Horizontal scaling creates a New Problems

  • Capacity grows by adding servers.
  • Workload can be shared across machines
  • Users should not choose servers manually.
  • Traffic now needs a distribution mechanism.

Introducing load balancer:

  • A load balancer becomes the system entry point
  • Incoming requests are distributed across server.
  • Traffic is no longer dependent on a single machine.
  • Application can scale more effectively.

Load balancing Enables Reliable Systems.

  • Multiple servers provide redundancy.
  • Failed server can be bypassed
  • Maintenance becomes safer.
  • Availability and resilience improve.
6. Api Gateway

Introduction of API Gateway

  • In modern system architecture, APIS connect clients (web, mobiles. third party apps) to backend services.
  • Directly exposing backend services can lead to performance, security, and management challenges
  • API Gateway is a centralized entry point for all API requests, handling, authentication, routing, caching, and security.

How api Gateways Work.

  • Api Gateway acts as reverse proxy between clients and backend services.
  • It receives API requests, process them and forwards them to correct services
  • Key function includes request transformation, Authentication, rate limiting and response handling.

Benefits of using an API Gateway

  • Security: Protects backend services from direct exposer.
  • Rate limiting prevents abuse and DDos attacks
  • Load Balancing: Distributes traffic efficiently.
  • Caching: Speeds up response times.
  • Request Transformation: Converts request formats, protocols and headers.
  • Logging & Monitoring: Tracks Api performance and security events.

API Gateway: Benefits and Common Use Cases

  • Best Suited for
    • Microservices architecture Multi-client APIs (web, Mobile)
    • APIs requiring security, rate limiting, and monitoring.
  • Not to Use:
    • Simple monolithic apps with minimal API exposure
    • Low-traffic, internal-only services
7. CDNS
  • Definitions: A CDN is a globally distributed network of servers that work together to delivers that work together to deliver content efficiently.
  • Why CDNS exist:
    • Reduces latency
    • Enhances content availability
    • Improves load handling
    • Security

Leave a Reply

Your email address will not be published. Required fields are marked *