02 Client Server Architecture - gannurohith/devops-interview-wiki GitHub Wiki
📁 02 - Client-Server Architecture (Basic to Intermediate Q&A)
-
What is Client-Server Architecture? A model where clients request services and servers provide them, typically over a network.
-
What are the main components of this architecture?
- Client: initiates requests
- Server: processes and responds
- Network: facilitates communication
-
Can you give real-world examples of client-server systems?
- Web browser (client) ↔ Web server (e.g., Apache, Nginx)
- Mobile app ↔ Backend API
-
How does HTTP fit into client-server architecture? HTTP is the protocol enabling client-server communication over the web.
-
What is a stateless server? A server that doesn't retain session data between requests. Each request must contain all necessary info.
-
How is state managed in stateless systems? Via tokens (JWTs), cookies, or external stores like Redis.
-
What’s the difference between client-server and peer-to-peer architecture?
- Client-server: centralized control.
- Peer-to-peer: equal nodes, no central authority.
-
What are some benefits of client-server architecture?
- Centralized management
- Easier scaling and maintenance
- Security policies can be enforced
-
What are common challenges in this model?
- Server bottlenecks
- Single point of failure
- Latency over networks
-
How do load balancers support this architecture? Distribute requests among multiple servers to improve performance and availability.
-
How does DNS fit into client-server communication? Resolves human-readable names (e.g., google.com) to IP addresses needed to connect to servers.
-
What is an API in this context? An interface through which clients interact with server logic (e.g., REST or GraphQL APIs).
-
What are some client-side technologies?
- HTML, CSS, JavaScript
- React, Angular, Flutter
- What are some server-side technologies?
- Node.js, Python, Java, PHP
- Databases: MySQL, MongoDB
-
What is latency and how does it impact this model? Latency is delay in communication, which can cause slowness or timeouts.
-
How do retries and timeouts work between client and server? Clients often retry failed requests; timeout defines how long they wait before giving up.
-
How is data secured between client and server? Use of HTTPS (TLS encryption), token-based auth (OAuth2, JWT).
-
What is a reverse proxy? A server that sits in front of backend servers, forwarding client requests and possibly caching responses.
-
Can clients talk to multiple servers at once? Yes, using multithreading, async calls, or service meshes.
-
How are microservices deployed in client-server models? Each service acts as a mini-server, often exposed via API Gateway.
-
What is a 3-tier architecture?
- Presentation (client)
- Logic (application server)
- Data (database server)
-
How are sessions handled in client-server systems? Through cookies, tokens, or session IDs stored on client or server.
-
What’s the role of a firewall in this model? Filters network traffic to protect servers from unauthorized access.
-
How does caching work between client and server? Data stored temporarily (e.g., in browser or CDN) to reduce repeat server hits.
-
What is a WebSocket and how does it enhance this model? A protocol enabling real-time, bi-directional communication between client and server.
02. Client-Server Architecture (Q&A)
-
Explain the differences between monolithic, 3-tier, and microservices architectures. Answer: Monolithic apps have all components in one package; 3-tier apps separate frontend, backend, and database layers; microservices break functionality into independent, small services that communicate via APIs, providing scalability and fault isolation.
-
What are the components of a client-server model in modern web architecture? Answer: Clients (browsers, mobile apps), servers (web servers, app servers), APIs, databases, load balancers, and sometimes CDNs and reverse proxies.
-
A client is experiencing high latency. How do you troubleshoot? Answer: Check client logs, server performance, network latency using
ping
,traceroute
, browser dev tools, load balancer metrics, and server-side metrics via CloudWatch or similar tools. -
How would you handle session persistence in a load-balanced architecture? Answer: Use sticky sessions or external session stores like Redis to persist session data across servers. Best practice is stateless apps with shared storage.
-
Describe the role of an API gateway in client-server communication. Answer: API Gateway centralizes API requests, handles routing, rate limiting, authentication, caching, and transforms requests/responses across microservices.
-
How does DNS resolution impact client-server interactions? Answer: DNS resolves domain names to IPs. Slow or misconfigured DNS can delay or block client access. TTLs affect caching and failover behavior.
-
What is the difference between synchronous and asynchronous communication? Answer: Synchronous requires immediate response (e.g., HTTP), while asynchronous allows decoupling via queues (e.g., Kafka, SQS), improving resiliency.
-
How can you secure data in transit between client and server? Answer: Use HTTPS (TLS 1.2+), validate certificates, enable HSTS, disable weak ciphers, and optionally implement mutual TLS (mTLS).
-
What’s the difference between REST and gRPC in client-server APIs? Answer: REST uses JSON over HTTP; gRPC uses Protobuf over HTTP/2. gRPC is faster, supports bi-directional streaming, and is ideal for microservices.
-
What are WebSockets, and when would you use them? Answer: WebSockets offer full-duplex communication between client and server. Use them for real-time apps (e.g., chat, live dashboards).
-
Describe a real-world incident involving server overload. How was it resolved? Answer: Example: sudden traffic spike from campaign; resolution involved autoscaling, adding CDN caching, and queueing low-priority tasks.
-
What is TCP slow start? How can it affect latency? Answer: TCP slow start limits initial data to prevent congestion, gradually increases. High latency on new connections until ramp-up.
-
How does TLS termination work on a load balancer? Answer: The load balancer decrypts traffic (terminates TLS), then forwards plain HTTP to internal services, reducing CPU load on apps.
-
In microservices, how do services discover each other? Answer: Via service discovery tools like Consul, Eureka, DNS-based discovery, or built-in cloud service registries (e.g., AWS Cloud Map).
-
Describe common failure scenarios in a distributed client-server architecture. Answer: Timeouts, network partitioning, resource saturation, DNS resolution failure, misconfigured SSL, rate limiting issues.
-
How do you implement API versioning to avoid breaking clients? Answer: Use URI-based versioning (
/v1/api/
), headers (Accept-Version
), or query parameters. Maintain old versions for backward compatibility. -
What is a reverse proxy? Give an example using Nginx. Answer: Reverse proxy forwards client requests to backend servers. Example:
location /api/ {
proxy_pass http://backend:8080;
}
-
Describe 3 strategies for rate limiting API traffic. Answer: Token bucket, leaky bucket, and fixed window counters. Can be implemented in API gateways, proxies, or server middleware.
-
How does caching affect client-server performance? Answer: Reduces backend load and latency. Types: browser cache, CDN, reverse proxies, and app-level caches (Redis, Memcached).
-
Explain eventual consistency and where it applies. Answer: Data may not be immediately consistent across nodes (e.g., in distributed databases like DynamoDB), but will converge over time.
-
What is a circuit breaker pattern in client-server apps? Answer: Prevents continual retrying to a failed service. Opens circuit on repeated failures, allows recovery checks before resuming traffic.
-
What is a service mesh and how does it help? Answer: Manages service-to-service traffic, with features like retries, observability, TLS, and load balancing. Example: Istio, Linkerd.
-
How would you monitor client-side errors effectively? Answer: Use tools like Sentry, Raygun, or browser logging with ELK/CloudWatch. Track JS exceptions, failed API calls, user behavior.
-
What is the difference between a proxy and a gateway? Answer: Proxy forwards traffic without inspection or policy. Gateway can transform, authenticate, authorize, and monitor requests.
-
What is MTLS and how does it differ from TLS? Answer: TLS authenticates server only. mTLS authenticates both server and client using certificates. Ideal for internal microservice communication.