You need to make 1,000 HTTP health checks every minute against internal endpoints. Threads or asyncio?
IntermediateScenarioKubernetes, Docker, SSH & fleet automation
Answer
Situation read → High fan-out I/O on a timer.
What I'd do →
- asyncio with
httpx.AsyncClient(or aiohttp), aSemaphore(100), per-request timeouts (timeout=3), andasyncio.gather(..., return_exceptions=True). - Record results as Prometheus metrics (
probe_success, latency histogram) from a long-running process. - Or just deploy Prometheus
blackbox_exporter, which does exactly this.
Why → asyncio handles thousands of sockets in one thread cheaply; threads would need a big pool.
Interview tip → Mentioning blackbox_exporter shows you do not reinvent monitoring.
More on Kubernetes, Docker, SSH & fleet automation
You need a report of every pod in the cluster with no CPU or memory limits. How do you write it?BeginnerYou are asked to write a small operator-like script that adds a label to every new namespace. How do you approach it?AdvancedYou need to restart all Deployments in a namespace that reference a rotated Secret. How?AdvancedYour CI runners keep running out of disk because of Docker images. Write a cleanup plan in Python.IntermediateYou need to run `df -h` on 300 Linux hosts and list any above 85%. Python or Ansible?BeginnerA Python script SSHes to hosts with `AutoAddPolicy`. Security says that is unacceptable. What do you change?Intermediate