Reference library

Microservices patterns

Service boundaries, discovery, inter-service calls, and decomposition patterns.

1 match
Microservices patterns easy

How to Compose Parallel API Calls in Python with asyncio.gather

Compose multiple mock API responses in parallel using asyncio.gather with per-service simulated latency.

asyncio concurrency api
Python
import asyncio
import random
import time

async def mock_api(name: str, delay: float) -> dict:
    await asyncio.sleep(delay)
    return {"service": name, "value": random.randint(1, 100)}

async def fetch_all():
    services = {
        "users": mock_api("users", 0.2),
        "orders": mock_api("orders", 0.3),
      …
15 0 Open

Browse by section

Each section groups closely related Python snippets.

Microservices patterns — Python code examples

What you will find here

This page collects microservices patterns snippets — short, copy-ready Python you can paste into our free online IDE and run without installing anything. Each sample includes a plain-English explanation and the full source code.

Samples vs tutorials and challenges

Samples are quick reference — one concept per page. For step-by-step teaching, use our Python tutorials. To test yourself, try quizzes or coding challenges. Clean up style with the Python formatter.