AlgoViz

Inside a logging service

medium 30 min

A logging service carries the log lines of all programs to one place where people can search them.

When it comes up

The moments this idea belongs in a design interview, and the moments it does not.

Signals

When to bring it up

You hearSayBecause
Design a logging systemPipeline with a queue in the middleBursts and outages
Hundreds of servicesTrace id from the entranceJoin lines of one request
Search in a secondInverted index, split by timeTouch little data
Keep for seven yearsTiers and object storageCost
Must not lose audit dataAt least once, confirmed on diskAudit differs from debug

Saying it in the room

  1. Interviewer

    Design a service that stores the logs of all our programs.

  2. You

    How many lines, how fresh, how long kept? Let me assume 100,000 a second of 500 bytes. That is 4.3 terabytes a day.

  3. Interviewer

    Fine. Why not write directly into the index?

  4. You

    Because the index is slowest when things break. A queue in between holds 180 gigabytes for each hour of trouble, before replication, and the programs never notice.

  5. Interviewer

    What if the queue is full too?

  6. You

    Then the agent keeps lines on its disk and drops debug first. I count what was dropped. Audit lines have a path of their own.

Options

Compare your moves

How do lines get from a program to the store?

BreaksEach request writes to the index and waits
How
One network call per line.
Limit
A slow index makes every request slow. An outage stops the shop.
Choose when
Never for normal logs.
WorksAgent sends straight to the index
How
Batches from a local file.
Limit
A long outage fills local disks, and bursts hit the index directly.
Choose when
Small systems.
StrongLocal file, agent, queue, processors, index
How
Each stage confirms, batches and can be late. Dropping follows a rule.
Limit
More parts to run and to watch.
Choose when
Many services or high volume.