Subjects Questions Quizzes Pricing
Overview Read Practice

Practice — Concurrency vs Parallelism (5 questions)

Beginner Short answer Free

Concurrency vs Parallelism

Define concurrency and parallelism precisely, and explain the relationship between them. Give one concrete example where a system is concurrent but not parallel.

Intermediate Short answer Free

Threads vs Processes

Compare threads and processes across memory, communication cost, and crash isolation. When would you deliberately choose multiple processes over multiple threads?

Intermediate Open Free

The GIL and Workload Choice

A Python service has two hot paths:

  1. A route that computes SHA-256 hashes over large in-memory buffers in a tight Python loop.
  2. A route that fans out to five external HTTP APIs and aggregates the responses.

For each path, would you use threads, asyncio, or multiprocessing? Justify each answer in terms of the GIL.

Advanced Open Free

Sharing One Async Session

The following async handler crashes under load with InvalidRequestError: This session is provisioning a new connection; concurrent operations are not permitted:

a, b, c = await asyncio.gather(
    get_top_subjects(db),
    get_top_questions(db),
    get_categories(db),
)

Explain the root cause in terms of concurrency, and give two different correct fixes.

Intermediate Short answer Free

How One Thread Serves Many Users

If an asyncio web server runs on a single thread with a single event loop, how can it serve thousands of simultaneous users without blocking? What is the eventual bottleneck for database-heavy endpoints?