Design VirusTotal
Understanding the Problem
🛡️ What is VirusTotal? VirusTotal lets anyone upload a file (or look one up by its hash) and see what dozens of antivirus engines think of it: "58 of 72 engines flag this as Trojan.GenericKD." Security teams use it to triage suspicious attachments, and automated systems query it millions of times a day by hash. The service doesn't decide whether a file is malicious itself; it runs many independent scanners and aggregates their verdicts.
Functional Requirements
Core Requirements
- Users should be able to upload a file (up to a few hundred megabytes) for scanning.
- Each uploaded file should be scanned by many antivirus engines (around 70), and users should see the results as each engine finishes, without waiting for all of them.
- Users should be able to look up a file by its SHA-256 hash and get the latest report instantly, without uploading it.
- Users should be able to request a rescan of a known file, to get verdicts from engines' latest signatures.
Below the line (out of scope)
- Behavioral sandboxing (detonating the file and watching what it does). We'll mention where it plugs in.
- URL and domain scanning, YARA hunting and community comments.
- Account management and billing for API tiers.
Non-Functional Requirements
Core Requirements
- The system should handle about 2 million uploads a day (around 25 per second on average, about 100 per second at peak) and tens of thousands of hash lookups per second.
- The first engine results should appear within a few seconds, and the full report within about 2 minutes at p95.
- One slow or broken engine must not hold up the report or the other engines.
- Uploaded files are malware. They must never execute on our infrastructure outside a controlled sandbox, and a compromised scanner must not be able to reach anything else.
- Uploads and reports must be durable: once we say "file received," we don't lose it.
Below the line (out of scope)
- Strict ordering or exactly-once semantics for engine results; duplicates are harmless if writes are idempotent.
Let's run the numbers, because they point at where the cost is.
- Engine work: 2M files × 70 engines = 140 million scans a day, about 1,600 per second. If an average scan takes 10 seconds (some engines take 1 second, some take a minute on large archives), that's around 16,000 scans running at any moment. That's the scanner fleet, and it's by far the biggest cost.
- Storage: 2M files × an average of 2 MB = 4 TB a day of uploads, about 1.5 PB a year if we kept everything. Many uploads are files we've already seen, which brings us to the key insight.
- Duplicates: popular files (a common installer, a widespread piece of malware) get uploaded over and over. If we identify a file by its SHA-256 hash, every duplicate upload can return the existing report without scanning again.
The cheapest scan is the one you don't run. Hash first: most lookups are answered from existing reports, and a file is only scanned when it's new or someone explicitly asks for a rescan.