Preparing your design workspace

Loading the problem and your latest saved attempt…

Design an Application Logging Client Library

Keep application logging fast and memory-bounded while the sinks each client selects fail independently or a process shuts down.

Problem statement

For this exercise, assume application processes use a structured logging library. A call supplies a level, message, timestamp and approved context fields.

The library applies a configuration revision, filters levels, removes prohibited context, formats a bounded record and delivers it to every sink the client has configured. A client selects one or more of three sink types: an event table, cloud object storage, and standard output.

Design the client/library architecture and its write path to each selected sink, not the internals of the table or object store or any search product.

Emit must not wait for any sink's I/O. It returns filtered, queued or dropped with a reason; queued means accepted into volatile memory, not durably stored or delivered. The queue has a fixed byte budget.

At saturation, a documented policy may displace queued low-priority records to admit high-priority records, but every drop or eviction is observable by level, sink and reason.

Each selected sink has its own worker that batches in the way that sink needs, with bounded retries and backoff, so a slow or failing sink cannot stall any other sink or grow memory without bound. No exactly-once delivery is promised.

A record uses one coherent configuration snapshot, and that snapshot includes the set of selected sinks. Secrets and prohibited fields must be removed before buffering, and diagnostics must not recursively re-enter the failing logger or reveal raw payloads.

Flush waits only until a caller deadline for the records already admitted when it began, reporting sink progress and any pending or lost records. Shutdown stops admission and drains only until its deadline. A process crash may lose queued memory; a durable disk spool is not required.

The reports behind this exercise name a logging library and, in one case, a client choice among an event table, cloud storage and standard output; API semantics, volatile buffering, sink lifecycle, privacy rules and the targets below are authored practice assumptions.

Event-table and object-store internals, search, legal retention, application business logic and class-by-class implementation are outside scope.

What to build

  1. An application emits a level-filtered, sanitized structured record without waiting for sink I/O and receives a truthful admission outcome.
  2. The library delivers admitted records to each sink the client selected (event table, cloud object storage or standard output) with bounded memory, batching suited to that sink, and independently observable failure or loss.
  3. A caller changes configuration, including the selected sinks, coherently and performs deadline-bounded flush or shutdown with explicit per-sink pending and lost-record results.

At scale

  • For this exercise, assume bursts of 5,000 records per second per process, records at most 2 KB and an 8 MB total in-memory queue budget.
  • For this exercise, target emit p99 below 1 ms without sink I/O and a normal delivery target of 250 ms after admission for the event table and standard output; cloud object storage receives batched files that close at 1 MB or 60 seconds, whichever comes first, and the object-storage sink's open file plus the one file it is uploading count against the 8 MB budget.
  • For this exercise, any one selected sink may be unavailable or slow for minutes. Memory and application latency remain bounded and the other sinks keep progressing, so observable loss is permitted; indefinite queuing or blocking is not.