Files arriving per minute
The maths behind it
Closed-form estimates beside what the simulation measured.
A retailer asks for something that sounds routine: collect the files from its POS devices every night. This is an educational walk-through of how an architect turns that request into a solution. The scale is unknown, so we uncover and classify the requirements, then model devices and files in symbols using the mathematics of queues. We compare options in the same symbols, turn the model into a decision rule, and only then draw the architecture. At the end you can run the model yourself.
A retailer asks for something that sounds routine:
“Every night, collect the files from our POS devices and deliver them to our collection point.”
That is the whole brief. It is tempting to answer straight away with a product, a diagram or an upload script. An architect resists that. A request names a need, not a design. And at this point we don't even know the scale: the estate could be fifty stores or fifty thousand.
So we won't size anything yet. We will build a model, a description of devices and files in symbols, that gives the right answer at any scale. The numbers can be plugged in later, once they are known. This piece follows the method one step at a time:
The first conversations are questions. Which files? From which devices? When do they exist? Where must they end up, and by when? What are we not allowed to change? The answers fall into four classes that every architecture framework recognises.
Look at what this has done. Nothing has been designed or drawn, and the scale is unknown. Yet we know any solution must respect a device budget, a time window, and four shared resources: the site uplink, the VPN hub, the inspection layer and the landing storage. And every unknown is a number we can give a symbol. That is where modelling starts.
Modelling means describing the problem so precisely that it can be calculated, without yet knowing the numbers. We do it in three steps: name the things, name the unknowns, and derive the quantities that matter.
Strip the problem down and only five kinds of thing remain:
| Symbol | What it is | How we'll find out |
|---|---|---|
| S | Number of sites | Store register |
| d | Devices per site | Asset inventory or device management |
| f | Files per device per night | POS application settings |
| s | Size of one file | Sample a week of files, and keep the largest sizes too |
| B | Site uplink bandwidth | Network team, measured after close |
| σ | Spread of start times around close | Observed, and later a design choice |
| q | Chance a single attempt fails | Transfer logs, with 4G sites separate |
| C | Capacity of the narrowest shared resource | VPN hub and inspection specifications, then a load test |
| Tw | The window, from close to when files are needed | Finance and operations |
From those symbols alone, we can write down every quantity a design must handle:
| Quantity | Formula | Plain meaning |
|---|---|---|
| Files per night | F = S · d · f | How much work there is to do |
| Volume per night | V = F · s | How many bytes must cross the path |
| Site drain time | τ = d · f · s / B | How long one site's uplink takes to send its files |
| Capacity floor | C ≥ V / Tw | The least capacity that could ever work, even if load were perfectly smooth |
| Peak arrivals | R ≈ N / (σ√2π) | How fast senders start at the busiest moment (N senders) |
| Sites sending at once | L ≈ R · τ | Little's law: arrival rate × time each spends |
| Peak bandwidth on the path | L · B ≈ S · τ · B / (σ√2π) | What the VPN hub and inspection must carry at the peak |
| Finish time | ≈ 3σ + τ | When almost every site is done |
That table is the model. It knows nothing about any particular retailer, and it works for any S, d, f, s or B. The six results below are the mathematics behind it: why these formulas, and why they can be trusted.
When many devices each send occasionally and independently, their combined arrivals behave like a Poisson process, whose rate is just the sum of the individual rates (the Palm–Khintchine theorem). You don't need to predict any single device to predict the estate. This is the branch of mathematics Agner Erlang founded in 1909 to size Copenhagen's telephone exchanges, and it is still used to size call centres, web servers and payment switches.
Files appear at close, so each source starts at the scheduled time plus a small random offset. If the offsets follow a bell curve with spread σ, the arrival rate takes the same shape, and its peak is:
Two rules follow. The peak grows in step with the estate: double the sources, double the peak. The peak shrinks as the spread widens: double σ, halve the peak. The daily average doesn't appear at all, which is why sizing for the average fails.
The number of arrivals in any one second is random, with mean m and standard deviation √m. The noise relative to the signal is 1/√m, so the model becomes more accurate as the estate grows. Because the scale is unknown, this matters: the model is safe to use at any size, and most trustworthy at the largest.
| Devices in one time zone | Peak files per minute | Peak files per second | Swing in the busiest second (1 s.d.) |
|---|---|---|---|
| 1,000 | 532 | 9 | ±34% |
| 10,000 | 5,319 | 89 | ±11% |
| 200,000 | 106,383 | 1,773 | ±2.4% |
| 1,000,000 | 531,915 | 8,865 | ±1.1% |
| 10,000,000 | 5,319,149 | 88,652 | ±0.3% |
The table assumes f = 2 and σ = 1.5 minutes.
Each shared resource has a service rate μ, and its utilisation is ρ = λ / μ. In the simplest queue model (M/M/1), the average number of requests waiting or in service is:
Little's law, L = λW, links the number in the system, the arrival rate and the time each spends there. It is how the model counts sites sending at once.
If each attempt fails independently with probability q, and a device tries up to k times:
Randomised retries add load gently. Retries that fire in lockstep recreate the pulse moments later (the “thundering herd”). And if failures rise with load, retries cause failures that cause retries: congestion collapse.
Every file passes the same chain of shared resources. Throughput is capped by the link with the smallest capacity, and the time is the sum of the time at each link. That is why the model carries a single C, the narrowest link, and checks the peak against it.
When the closed forms get tangled (several zones, retries layered on retries), we simulate every device and count. That is a Monte Carlo simulation, and it is what the simulator at the end of this page runs, with the formulas and the simulated results side by side.
A model is only as good as its assumptions. Each failure below makes the real peak larger than the modelled one, so an architect checks them before trusting the numbers.
| It holds when… | It breaks when… | What to do |
|---|---|---|
| Devices act independently once the schedule fires. | A carrier or regional outage fails thousands of devices at once, and they all recover together. | Model failures as shared events, and expect a second pulse at recovery. |
| The number of sources is large. | The thing being sized is small, such as one site's uplink. | Size small pieces from simulated percentiles, not the mean. |
| Failures don't depend on load. | Timeouts rise as a link saturates, so q grows with ρ. | Keep peak ρ well below 1, cap retries, and push back explicitly. |
| Files are similar in size. | A few huge files dominate, and files grow on peak trading days. | Use the largest observed s, not the average. |
| Start times really are random. | Every device is scheduled for exactly 00:00, or a firmware rollout reboots them all together. | Add a deliberate random offset. Never rely on accidental spread. |
| The schedule is fixed. | Late trading before Christmas or 24-hour stores move each site's close. | Trigger on each site's actual close, not a fixed clock time. |
Only now do we design, and we design more than one answer. Each option is a different shape of queue, so each can be written in the same symbols and compared before anyone builds anything.
A central server connects to each site in turn, c sites at a time, and pulls the files. It is a serial queue, so the time grows in step with the number of sites:
It is simple and centrally controlled. But the central server is a single point of failure, and it needs connections into every site, which many security teams won't allow.
Each device hands its files to the in-store server over the LAN. The server bundles them and sends once. The estate now has S senders instead of S · d, and the devices do almost no work:
Every device uploads its own files to the landing storage with a short-lived pre-signed URL. That makes S · d senders, the classic storm. The site uplink still limits each site, so peak bandwidth is the same as option B, but the inspection layer and SIEM see a new session for every file:
Because the scale is unknown, we plug in three illustrative estates and see how each option behaves. All three use the same assumptions: one time zone, f = 2 files of s = 5 MB, B = 20 Mbit/s, σ = 1.5 minutes, and c = 10 for option A.
| Quantity | Small 50 sites × 10 | Medium 2,000 sites × 40 | Large 20,000 sites × 50 |
|---|---|---|---|
| Devices | 500 | 80,000 | 1,000,000 |
| Volume per night, V | 5 GB | 800 GB | 10 TB |
| Site drain time, τ | 40 s | 160 s | 200 s |
| A · time to finish | ≈ 3 min | ≈ 9 h | ≈ 4.6 days |
| B, C · time to finish | ≈ 5 min | ≈ 7 min | ≈ 8 min |
| B, C · sites sending at once | ≈ 9 | ≈ 1,400 | ≈ 17,700 |
| B, C · peak bandwidth on the path | ≈ 180 Mbit/s | ≈ 28 Gbit/s | ≈ 355 Gbit/s |
| B · new sessions at inspection | ≈ 13 per min | ≈ 9 per s | ≈ 89 per s |
| C · new sessions at inspection | ≈ 4 per s | ≈ 709 per s | ≈ 8,865 per s |
The model now teaches something no single number could: the best option depends on scale. At small scale the storm hardly exists and the simplest design wins. At medium and large scale, option A runs out of time, while B and C finish quickly but hit the path with a synchronised burst far beyond any VPN hub. None of them fails at the cloud. And none of them changes σ, the one term that sets the height of the pulse.
Other differences don't depend on scale: option C needs an agent and a credential on every device, B needs one per site, and A needs one central identity with access into every site. A fourth possibility is to buy a managed file transfer (MFT) product. It still implements one of these shapes, so the same model applies.
Without the scale, the architect's output is not a single design but a decision rule: two inequalities that any future numbers can be tested against.
Rule ② is the key engineering move. σ is not just an observation: we can choose it, by giving each site a random offset after close. It is the cheapest lever in the model. Here is the rule applied to the three estates, assuming the narrowest shared resource carries C = 1 Gbit/s and the window is Tw = 6 hours:
| Estate | ① Capacity floor | ② Spread needed | Decision |
|---|---|---|---|
| Small | ≈ 2 Mbit/s ✓ | σ ≥ 0.3 min, which natural spread already gives ✓ | Keep it simple. Option A or B, no storm engineering needed. |
| Medium | ≈ 300 Mbit/s ✓ | σ ≈ 43 min, finishing in about 2.2 h ✓ | Option B with a random offset per site. |
| Large | ≈ 3.7 Gbit/s ✗ | σ ≈ 530 min, finishing in about 27 h ✗ | No option fits one 1 Gbit/s hub. Change the path: for example six regional hubs, each needing σ ≈ 90 min and finishing in about 4.5 h, or a route agreed with security in which inspection happens in the cloud. |
This is the point of modelling. The large estate is ruled out by rule ①, a single division, before anyone argues about products. The fix (more capacity, or splitting the path) falls straight out of the formula.
Only now, with a rule that chooses, does it make sense to draw the path a file takes. For a medium estate the rule chooses option B, and the architecture looks like this, labelled in the model's own symbols:
Every term in the model becomes a specific engineering decision:
| Term | Engineering decision |
|---|---|
| σ spread | A per-site random offset after close, seeded from the site ID, triggered by each site's actual close rather than a fixed time. |
| Device budget | Devices only copy over the LAN, at low priority, and never during a transaction. Compression happens on the site server. |
| q failure rate | Resumable multipart uploads, idempotent object names (a retry overwrites rather than duplicates), and checksums verified on landing. |
| k retries | Exponential backoff with full jitter, a cap on attempts, and honouring HTTP 429 and Retry-After. |
| C narrowest link | Measure VPN hub and inspection throughput by load test, and agree an inspection policy with security for this known, scheduled traffic. |
| L backlog | Store-and-forward. A site offline overnight keeps its bundle and sends it when the link returns. |
| Tw window | The landing zone absorbs the burst, and event-driven replication forwards to the final cloud at a steady, cost-controlled rate. |
| Evidence | A manifest per site, reconciled against what arrived, produces the morning completeness report. |
The method, in one line: understand the request, classify the requirements, model devices and files in symbols, compare the options in the same symbols, turn the model into a decision rule, and only then draw.
The simulator models every device sending directly (option C) across the three time zones, so you can watch the raw storm and the levers that tame it. Start with the baseline, then try spreading the starts (the σ decision from Part 6), a flaky network, and retries without jitter, and compare the maths table with what the simulation measured. Its “serial relay” row is option A.
Closed-form estimates beside what the simulation measured.
The lesson the numbers teach: size for the peak, not the average. The busiest minute is around 300 times the daily average, yet elastic object storage absorbs it at under 10% of its limit when every site sends in parallel.