Preparing your design workspace

Loading the problem and your latest saved attempt…

Design Distributed Article Word-Count Aggregation

Dispatch article-count work across unlimited or bounded servers and publish one exact total.

Problem statement

For this exercise, assume a caller submits a unique batch ID and a list of unique article IDs and wants the exact sum of their word counts. A supplied worker operation startCount(serverId, articleId) returns a handle whose status can be polled and whose terminal success contains that article's count.

Each server runs at most one article at a time. With abundant servers, all articles may run concurrently; with a finite pool, the system must schedule queued articles as servers become free.

A batch publishes one terminal result only after every article has one accepted successful count, and retries or duplicate completions must not double count. Design durable orchestration, APIs, state, dispatch, aggregation, and recovery.

Article storage, word tokenization, editing articles during a batch, billing, and worker implementation are outside scope.

What to build

  1. Accept an idempotent batch of unique article IDs and expose queued, running, succeeded, or failed progress.
  2. Dispatch each article to an available server while respecting one active article per server.
  3. Publish one exact total after one accepted successful result per article without duplicate counting.

At scale

  • Assume a batch contains up to 100,000 articles and the finite pool contains from 1 to 500 servers.
  • An article count takes from one second to five minutes and may time out or return a duplicate completion.
  • Support 100 concurrently active batches while preventing one large batch from permanently starving the others.
  • Batch metadata and accepted per-article counts must survive coordinator restarts for 30 days.