Lesson 5 of 5
Servers and the Cloud
Step inside modern hyperscale data centres and discover how cloud computing powers the modern web.
Learn it
When people talk about the 'cloud', they don't mean real clouds in the sky! The cloud is simply thousands of super-powerful computers sitting in giant, climate-controlled warehouses called data centres.
Instead of running a website on one computer in an office, companies rent space in these giant facilities across the globe. If millions of people visit at once, the cloud automatically starts up extra servers to handle the crowd.
Key terms
- Data Centre
- A dedicated facility designed to house large clusters of computer servers, networking gear, and storage arrays.
- CDN (Content Delivery Network)
- A geographically distributed network of proxy servers that cache content close to end users.
- Load Balancer
- A device or software service that distributes incoming network traffic across multiple backend servers.
- Serverless Computing
- A cloud execution model where cloud providers automatically manage machine resource allocation on demand.
Architecture of a Scalable Cloud App
Follow how millions of simultaneous user requests are handled without crashing.
- 1DNS Geo-Routing: User queries are directed to the geographically closest edge server on a Content Delivery Network.
- 2Static Asset Cache Hit: Images, stylesheets, and cached videos are returned immediately from the edge without hitting the origin.
- 3Load Balancer Ingress: Dynamic requests pass to a load balancer, which distributes traffic evenly across healthy server instances.
- 4Auto-Scaling Worker Pool: As traffic spikes, auto-scaling groups boot up additional container replicas in seconds.
- 5Database Read Replicas: Database queries are split between master write nodes and distributed read replicas for speed.
Simulating a Round-Robin Cloud Load Balancer
pythonclass LoadBalancer:
def __init__(self, servers):
self.servers = servers
self.index = 0
def get_server(self):
server = self.servers[self.index]
self.index = (self.index + 1) % len(self.servers)
return server
lb = LoadBalancer(["Server-Alpha", "Server-Beta", "Server-Gamma"])
for request_id in range(1, 5):
target = lb.get_server()
print(f"Request {request_id} routed to -> {target}")The load balancer cycles sequentially through healthy cloud instances using modular arithmetic, ensuring no single server gets overwhelmed.
Try it
Look at the Load Balancer code. What will be printed when Request 4 is processed?
pythonservers = ['Cloud-A', 'Cloud-B']
# Round-robin distribution for 4 requests:
# Request 1 -> Cloud-A
# Request 2 -> Cloud-B
# Request 3 -> Cloud-A
# Request 4 -> ?Challenge
Extend the Load Balancer class to check a 'healthy' boolean flag for each server, skipping any servers that are currently offline.
Pick whichever way suits you — every mode earns the same bonus XP.
Write at least 40 more characters to submit.
Mark your own work
Guided walkthrough — 0/5 clues revealed
- Clue 1 locked — reveal it only if you get stuck.
- Clue 2 locked — reveal it only if you get stuck.
- Clue 3 locked — reveal it only if you get stuck.
- Clue 4 locked — reveal it only if you get stuck.
- Clue 5 locked — reveal it only if you get stuck.
Each clue costs 5 XP (never below 25 XP). You'd earn 50 XP right now.
Extension: Implement a weighted load balancer where more powerful servers handle a higher percentage of requests.