Chapter 14. State and Sessions
In the previous eleven blocks, each value lives inside a single request. You fill it in, click once, get a result, then wait for the next one. To carry a value across two clicks (say “the three entries the user just recorded”), you need a variable that survives across requests to store it in.
A value can live in a component’s value, in the server-side State, or in the browser’s BrowserState. The difference between the three is not in how you write them, but in “is it still there after a refresh” and “can someone else opening it see it”.
This is harder than it looks. “Remembering” splits into three layers. Between two clicks it is the component’s value; from a page opening to closing it is the session; for a person coming back next time it is persistence. Three layers, three ways of storing; mix them up and you get all kinds of “why did it disappear” problems.
The sample adds a twelfth block to the workbench: the state module. It writes the same line into two places at once, one on the server and one in the browser, then tests them with four actions — record an entry, read both sides, refresh, and wait for it to expire. All four actions run in a real browser, and the numbers in the figures are the displayed values read after each step.
14.1 State Initial Values and Write-Back
State is an invisible component. It draws nothing, the front end cannot get its value; you declare it, put it in an event’s inputs and outputs, and that is all.
var notes = gr.State(JsonNode.Parse("[]"), timeToLive: 30, deleteCallback: OnDropped);
var local = gr.BrowserState(JsonNode.Parse("[]"));
The first line is server state. An empty array is the initial value, it lives 30 seconds, and OnDropped runs when it is dropped. The second line is browser state, with the same initial value and no other parameters. Neither is displayed, so they can be written anywhere in the UI. The sample puts them at the start of “State view”; readers cannot see them on the page.
Why not just use a local variable? Say you write List<string> notes = [] outside the handler functions and have all of them use it. That code compiles and runs, and then it gives itself away when a second person opens the page. That list is one per process; two users add to it and each can see the other’s entries. The “first entry” the first person recorded is there for the second person to read after a refresh.
This is the first reason state components exist: separation by session. The framework gives each session its own value, which a local variable cannot do. The second reason is that it follows the framework’s lifecycle. You can set a lifetime, get a callback when it is dropped, and have it cleared when the session ends; a static list just keeps growing.
Open the page configuration and this state contributes only two things: time_to_live is 30, and delete_callback is null (a callback cannot be written into configuration). There is no value. A state’s value belongs to the session, not the page. This is unlike every component before it: every other component has a value in its configuration, and this one does not.
What type is the value? gr.State takes a JsonNode, because a state’s value is simply a JSON tree — array, object, string, or number. When it is passed to a handler function, a JSON array becomes an object[] with one scalar per element.
(object[], object[], string, string) Remember(object[] notes, object[] local, string text)
{
var mine = StateBook.Items(notes).ToList();
mine.Add(text.Trim());
var theirs = StateBook.Items(local).ToList();
theirs.Add(text.Trim());
return ([.. mine], [.. theirs], Panel("Server state", mine), Panel("Browser state", theirs));
}
Four return values: the two states’ new values and the text for two panels. The first two land in the states (stored, not shown), the last two in the panels (shown). Get this division clear. State is an output component too, except that its “displaying” is “storing”.
Reading and writing are declared separately, so there are three ways to use it.
- In both inputs and outputs: read it, change it, write it back — the most common;
- In inputs only: read-only. The handler function gets the value but cannot change it. Writing it back has no effect either, because nothing receives it;
- In outputs only: write-only. Good for an action like “Clear”, where the handler function returns an initial value and does not need to read first.
The bindings look like this.
memo.Add.Click(Remember, [kept.Notes, kept.Local, kept.Input],
[kept.Notes, kept.Local, kept.Server, kept.Browser], apiName: "Record");
memo.Read.Click(ReadBoth, [kept.Notes, kept.Local], [kept.Server, kept.Browser], apiName: "Read both");
memo.Drops.Click(ShowDrops, null, [kept.Dropped], apiName: "View callback");
“Record” reads two states plus an input box and writes back two states plus two panels; “Read both” only reads and does not write state, so the states are not in its outputs; “View callback” reads nothing and writes only one panel.
The order has to match too. The order in inputs decides the parameter order, and the order in outputs decides where the return values go; the sample’s two states come first on both sides, so Remember’s first two parameters and first two return values are both them. Get this order wrong and there is no error, only values written into the wrong components. Write an array into a panel and text into a state and you can see it at a glance in the UI, but to track it down you have to think of this layer first.
The sample’s panel order matches the order of the two states: server panel first, browser panel second. That way, when reading the code, “which parameter goes with which output” needs no flipping back and forth — you can match them at a glance. Once there are many components, this consistency is worth more than saving a few lines of code.
Figure 14-1 shows it after clicking “Record” twice: two entries on the server on the left, two in the browser on the right, with the same content.
Figure 14-1 Two entries recorded on the same page, one copy stored in each place
The two states are written in the same block of code with the same line, and look like twins; but the only thing they share is “the way they are written”. The next four sections are all about the layer where they part company: where they live, how long they live, who can see them, and what happens when they fill up. Reading those two lines side by side is faster than reading four pages of explanation.
Why “two copies” and not “one shared list”? Because the two states are two stores to begin with. The server one is in process memory, the browser one is in localStorage; writing the same line into both is two writes. That also explains every difference that follows. They are two different things.
The initial value has a wrinkle too. gr.State’s initial value is one copy per session. Two sessions reading the same component each get their own copy; they do not share the same mutable object. So “write an empty array as the initial value” is safe, and you will not get “session A changes the array and session B changes with it”. The framework guarantees this; the app does not have to write its own clone.
14.2 State Lifetime and Cleanup
timeToLive is a number of seconds; leave it out and it is infinite, with the value kept until the session ends. The sample writes 30 so you can see it disappear within two minutes.
Its starting point is easy to misremember. It counts from the moment the value is written, not from the last read. That is, a state written once and then read every ten seconds expires 30 seconds after it was written, not “30 seconds after the last read”. This rule comes from the Python version, on the grounds that “the lifetime belongs to the value, not the session”. Two states can each have their own lifetime without affecting each other.
From that follows a finer rule: a state that has only ever been read and never written never expires, because it has no “write time” to count from. The sample’s two states start at their initial values, with nobody having written to them. If you only click “Read both”, that empty array can stay forever. To start the clock, you have to write once.
This difference matters in real applications. A “loaded model” state is written once when loading and only read afterwards, so it counts from load time and is released when the time is up. A “currently selected row” is written once per user click, restarting the clock, and only expires when the user leaves it alone. Both use the same parameter, but the meaning differs depending on how you write.
What happens when it expires? The value goes back to its initial value (an empty array in the sample) rather than becoming null or throwing. The next time a handler function reads it, it gets [], just as when it was created. So in code, “expired” shows up as “the value is gone” — no error, no notice.
To do something at that moment, use deleteCallback.
static void OnDropped(object? value) => StateBook.Dropped(value switch
{
object[] items => items.Length == 0 ? null : items[^1]?.ToString(),
JsonArray array => array.Count == 0 ? null : array[^1]?.ToString(),
null => null,
_ => value.ToString(),
});
It is called once when the value is dropped, with that value as its argument. Note that it is “the value before it was dropped”, so you can see what was stored last. The sample uses it to record one entry: how many times it ran and which item was dropped last.
That count is one per process, not one per session. It is not state, just a diagnostic number. So callbacks from two sessions add to the same number, which does not conflict with “state is separated by session” — the count never belonged to any session. That is where the line in Figure 14-2, “Drop callback ran 1 time, and the last one dropped was ‘an expiring entry’”, comes from.
Figure 14-2 Expiry: the server goes back to 0 entries, the browser still has them, and the callback ran once
The callback is good for more than counting. In a real application it is the right place for “releasing”. If a state holds a database connection, an open file, and a loaded model, dropping the value is exactly when you close them. It is the app’s one and only chance to learn that “this value is gone”.
Two things to know when using it. First, it may run on any thread. Cleanup happens in the framework’s sweep, not on your request’s thread, so anything the callback touches must be thread-safe, or the callback should only do light work like “record an entry, send a signal”. Second, it should not throw. The sweep is batched: if one callback throws, cleanup of the values behind it may be cut short. The sample’s callback only increments a counter, precisely to avoid trouble.
One more counterintuitive point: timeToLive is not a cache eviction policy. It means “this value lives this long”, not “throw it away first when memory is tight”. To control memory you use the two session-store numbers in 14.6, not a short life on every state. Mix the two and you get things like “the user is halfway through a form and the value suddenly disappears”.
Session end is another route. Closing the page does not clear the session immediately. ClosedTimeToLive defaults to one hour, leaving time for “refresh and pick up where you left off”. Past that, the session and its values are dropped together, and the callback still runs.
The two routes are “whichever comes first”: if the value expires first it takes the value route; if the session closes first, the session goes once that hour is up. So a written value lives at most until “last write + max(lifetime, one hour after close)”; a value that was never written has no starting point and can only follow the session.
One thing to keep straight: timeToLive only applies to State. BrowserState has no such parameter; its “lifetime” is decided by the browser. As long as the user does not clear the cache or switch browsers, it is always there. To give it an “expiry time” you have to store a timestamp in the value yourself and compare it when reading. The framework does not do it for you, because browser storage has no concept of expiry in the first place (localStorage, unlike a cookie, cannot carry an expiry time).
14.3 BrowserState and Browser-Side Storage
BrowserState puts the value in the browser, specifically in localStorage. That one move changes its nature.
- It crosses sessions. Refresh, open another tab, close and reopen — the value is still there;
- It follows the browser. Switch browsers or machines and it is gone;
- It uses no server memory. Ten thousand users each with their own copy put no load on the server at all.
Figure 14-3 shows it after “switching to a new session”. The previous page recorded two entries; this page is a new session, so those two are invisible on the server (the server has only 1 entry, recorded on this page). All three are still in the browser, and the first two are exactly the ones from the previous page.
Switch browsers as well (Figure 14-4) and both sides start from one entry. The browser side has one entry, because it switched to a different localStorage and the first two simply do not exist in the new browser.
Figure 14-3 Switch sessions: the server starts from 0, the browser continues with the previous page’s three entries
Figure 14-4 Switch browsers: the browser side goes back to zero too
This component has two more parameters whose defaults you should know. storageKey is the key it uses in localStorage; leave it out and one is generated at random. Random is so two apps on the same domain do not collide — each reads its own.
What if two apps share a key? The one opened later reads the value the earlier one stored and treats it as its own. If the types do not match it errors; if they do match, that is worse — it carries on using someone else’s data as its own. So when running several apps on one domain, do not skip this parameter. Giving each app an explicit name is steadier than relying on the random value (the random value changes after a process restart, and the old key is left in the browser with nobody to clean it up).
secret is the key the browser uses to encrypt its own copy; leave it out and it too is generated at random. It is in the configuration because the browser needs it — both encryption and decryption happen on the browser side. So what it protects is “keeping the string in localStorage from being casually turned into a readable value”; what actually stops “changing” and “reading” is the server-side wrapper.
A random secret has a side effect too. After a restart the browser cannot decrypt its own stored copy, which is as good as losing it. To keep it across restarts you have to give a fixed secret. But then the browser layer’s encryption is effectively public (anyone can see the secret). Fortunately the server-side wrapper is unaffected — its key is not in the configuration. So “across restarts” hinges on that server key. It lives in the process, and once the process changes it is gone.
A third parameter does not appear in the signature, but it decides how this component works: the server wraps the value with a key of its own. What the browser stores is the wrapped string, which it cannot read — it simply stores it as-is and sends it back as-is; when the server receives it, it can verify “was this wrapped by the server?”. A value that was altered, or forged by the client, fails verification and is treated as the default.
So the claim “browser state can be changed by the user” is only half true. The user can change the string in localStorage, but after that the server rejects it. That is a different matter from Chapter 12’s “type limits are only for experience”: that one really has no defense, this one genuinely blocks it.
What does it defend against? An example: a state holds “which pages this user may see”. If it could be changed, the user would set it to “all” and bypass permissions. The wrapper closes that path. The client cannot compute that key; changing a single byte fails verification. But what is blocked is “tampering”, not “reading”. The user can still see their own content (by decrypting with secret), so permission data does not belong here — it belongs in server state.
There is capacity too. localStorage is on the order of a few MB per domain (it varies by browser), and once it is full setItem throws. A list of a few hundred items is fine; a cache of a few MB will fail. And the failure shows up as “it did not save”, not “an error for you to see”. So browser state suits things that are “small and need to cross sessions”: preferences, drafts, last position.
Browser state has one more detail with multiple tabs. Two tabs share the same localStorage but each has its own page memory. Tab A writes, and tab B does not know right away — it still holds what it read when it opened. To make it see the change you have to refresh, or re-read in the change event. localStorage has no “cross-tab push” of its own; for live sync you add a layer yourself (for example listening for the browser’s storage event, which is front-end work).
So “browser state crosses sessions” needs a qualifier. What it crosses is “reopening”, not “being open at the same time”. Two tabs changing it at once: the later write overwrites the earlier, the same principle as the server state in 14.5.
Open the page configuration and this component contributes three things: default_value (used when the browser has stored nothing yet, an empty array in the sample), storage_key (a random sixteen characters unless you specify one), and secret (also a random sixteen characters). There is no value either. Like State, its value is not on the page, it is in the browser.
“Server wraps, browser stores” comes down to this in localStorage: the browser gets a string of characters it cannot read, stores it, reads it back, sends it back unchanged, and never interprets what is inside. The wrapping uses the server’s key, generated at process start and never serialized. So two things hold at once: an altered value fails verification (the client cannot compute that key), and the content cannot be read either (the client has no key). secret is another layer: the browser uses it to encrypt its own copy, and even if someone uses secret to peel off that outer layer, inside is still the server-wrapped string, and the content stays unreadable.
One side effect while we are here: because the value is wrapped, the same data takes up a little more room in the browser than raw JSON (encoding plus a verification tag). It does not matter for small things, but count that layer in when you are pushing against the capacity limit.
One more easy-to-miss point: that key belongs to the process. After the app restarts the key changes, and old values stored in the browser fail verification and are all treated as defaults. So BrowserState survives refreshes and survives tabs, but not a restart. To survive a restart it would have to be server state plus real persistence — that is, a database.
14.4 Choosing Between State and BrowserState
Lay the differences above out in a table and you no longer have to guess which one to pick.
Figure 14-5 Three ways of storing, and whether each survives in six situations
The “still there or not” in the table comes from running this chapter’s sample: same machine, same browser, same run, trying refresh, a new tab, and a different browser once each.
One row in the table deserves its own look: refresh. Many people assume server state survives a refresh, since it is on the server. Run it once and you find it does not. A refresh is a new page load, hence a new session; the previous page’s values are still in memory, but the new page cannot reach them. So “still there after a refresh” is something only browser state can do.
That follows from the definition of “session”. To keep using a value after a refresh you have to put it in the browser, or use real external storage (a database plus some identifier like a session id). The former is BrowserState’s job; the latter you write yourself.
How to choose? Split it by “who does this value belong to”.
- Temporary data belonging to this session (the few entries just recorded, a half-finished intermediate result, the currently selected row) goes in
State. It follows the session and should be gone when the session is gone, takes no browser space, and the user cannot change it. - Preferences belonging to this person (theme, the last page opened, which panels were collapsed) go in
BrowserState. They are there after a refresh and after closing and reopening the browser, with nothing for the server to remember. - What belongs in neither (orders, balances, things other people can see) goes in a database. None of the three ways of storing crosses machines, and none covers “switch computers and carry on”.
There is a third option that is easy to forget: do not store it. Do not store a value you can compute from something else — the current time, the length of a list, the sum of two inputs. Once stored, you have to maintain its consistency: the user changes an input and you must remember to sync the state; miss one place and two numbers in the UI no longer agree. Chapter 13’s chat is handled exactly this way. The history lives in the chat component’s value, with no extra state copy, so there is no “two copies disagreeing” problem.
One more kind is most often misused: treating State as storage. It looks handy (a dictionary, put anything in it, and it crosses events), but it does not survive a restart, nor the hour after a session closes. Store “the user’s history” in it and the day after launch you get feedback saying “the records are gone”. That is what the last line of this section — “to cross machines, cross browsers, cross restarts, all three fall short” — is about.
Another common mismatch is the reverse: putting something that belongs on the server into the browser. Take “is this user an administrator?”. Browser state can be read and changed by the user (changed values are rejected, but reading is possible), so putting identity information in it is like pinning the permission table on the door. The test is simple: would it be a problem if the user saw this value? If yes, put it on the server.
When you actually choose, ask three questions in this order.
- Does this value need to survive a refresh? If not, use the component’s value; you do not even need to create a state.
- Yes, and only this page uses it? Use
State. - Yes, and the user wants to see it next time they open the app? Use
BrowserState, provided it is something the user may see.
If it fails all three, then it is “cross machines / cross restarts”, and it belongs in a database.
14.5 The Practical Boundaries of Session Isolation
How are sessions divided? The result of running it is this: one session per page load. A refresh is a new session, and so is another tab. So in Figure 14-3 that new page starts server state at 0. It never saw the previous page’s values at all.
Technically, when a page first connects the server gives it an identifier, and every request after that carries it back; change the page and you change the identifier, so naturally you cannot read the previous session’s values. How that identifier is carried and where it is stored is an internal framework matter the app does not need to know. But “one identifier per page” is what determines everything below.
Where did the previous page’s values go? They are still in server memory, attached to a session nobody will ever visit again. They are cleared only when one of two things happens: its lifetime runs out (if timeToLive was set), or the hour after the session closes runs out. So “old values vanish immediately after a refresh” is an illusion; what changes is only “whether they can be read”.
This boundary needs stating clearly, because the word “session” makes people think of a browser window or a logged-in user. In this framework it is closer to “one page load”. Two tabs in the same browser are two sessions; a refresh is another session too.
So “two sessions do not share state” is verified in the sample like this: the first page records two entries, and the second page sees only the one it recorded itself. The second page did not “clear” the first. The first page’s values are still in server memory, just with nobody pointing at them; only when its lifetime runs out, or the hour after the session closes runs out, are they dropped.
The screenshot in Figure 14-3 is exactly that verification: only one entry on the server on the left (recorded on this page), three in the browser on the right (the first two from the previous page). Same code, same component, and the new session cannot see the previous session’s two entries. This is the most direct evidence of “isolation” — no logs to read, no inference needed. What it checks is “after the previous session closed”, not “two tabs alive at the same time”; the latter can also be checked with the sample (open two tabs, record one entry in each, read each), it just cannot be captured in one screenshot.
Verifying it yourself is easy too. Open two tabs, record one entry in each, and click “Read both” in each. On the server side each sees only its own entry; on the browser side both see everything (because they share the same localStorage). That difference is exactly the one from 14.3: server state is divided by session, browser state by browser.
Inside a single session there is one more boundary: reads and writes are not a transaction. Two events run at once, both start from the same old value, each adds its own entry, and both write back. The later write wins, and the earlier entry is lost.
Take a concrete case. The state holds ["a"]; two handler functions run almost simultaneously, both read ["a"], one adds b giving ["a","b"], the other adds c giving ["a","c"]; two writes come back and the latter is what remains. b is gone. This is the inevitable result of “one value per session”: both writes “replace the old with the computed result”, with no merge step.
To serialize them you have to make them queue up. That is what the concurrency limit in Chapter 15 is for. Or simply do not let two events write the same state. Make “Record” a single action: two user clicks are two requests, and the queue handles them in order without concurrency. The sample does the latter — one button, one write.
One more boundary that is easy to confuse: a session is not a user. The same user opening two tabs gets two sessions with their own state; opening on another computer is two sessions again. The framework has no concept of “user” — that belongs to authentication (Chapter 20) and the database. So a requirement like “remember this user” cannot be met with state; it needs a real identity.
When does a session count as “closed”? Once the page is closed, the front end’s long-lived connection drops, the framework takes that as the session ending, and starts the one-hour countdown. The detection can be a few seconds late (connection timeout), or misjudge once because of a refresh. On refresh the old connection drops and a new one is built, which looks like “closed and opened again”. That is why an hour is kept after closing: better to hold on a little longer than to wipe values while the user is refreshing.
14.6 Session Store Capacity and Expiry
A session and its values live in a “session store”. The default implementation is a dictionary in memory, and two numbers decide its size.
Capacity. How many sessions to keep at most, 10000 by default. Past that it drops the least recently used one. “Least recently used” means “not accessed for the longest time”, nothing to do with age.TimeToLive. How long a session may sit idle before it expires; unset by default, which means never.
Both numbers live in SessionStoreOptions. gr.Launch() uses the defaults, so the sample runs on the defaults too; to change them you go through host registration (Chapter 21). The options.SessionStore inside AddGradioCore is it — set the two properties directly.
Why not add two parameters to gr.Launch()? Because the session store can be swapped out wholesale. The in-memory implementation suits a single machine; a multi-instance deployment needs shared storage (say Redis). SessionStoreOptions is two numbers for people “using the in-memory implementation”; swapping the implementation is a different matter, done through dependency injection. Keeping the two apart is what stops the interface from bursting with parameters. The in-memory implementation alone is enough for this chapter.
The capacity number looks large, but a quick calculation tightens it. Ten thousand sessions, each holding a hundred-item list, is a million records resident in memory; at a hundred bytes each, that alone is a hundred megabytes. Multiply by each session’s own overhead (connection, configuration copy, remembered component values) and even an app “nobody uses” can take up several hundred megabytes.
So capacity and state size are a pair. With small things in state, ten thousand is generous; with large things, that number has to come down. Turn it down and the behavior is “drop the least recently used session” — a session, note, not a single value. When a session is evicted, all of its states go together, and deleteCallback still runs (it is the notice that “a value was dropped”, whatever the reason). So the resource-releasing code in the callback runs in all three cases: “expired”, “session closed”, and “evicted”. That is exactly why it is more reliable than “manual cleanup elsewhere”.
TimeToLive is another ruler: how long a session may be idle before it expires. Leave it unset and a user who walks away with the page open leaves the session sitting there until capacity fills and it is evicted. Set it to, say, half an hour and an abandoned session is reclaimed after half an hour, so memory is not filled up by “opened and never closed” tabs. Tuning both numbers together is what counts as “under control”: capacity governs the upper bound, idle expiry the lower bound (how long before an unused one is let go).
These two numbers have an easily confused neighbor: ClosedTimeToLive, the “keep for one hour after the session closes”. It is a property of each session, not a setting of the store, and cannot be tuned from here. You can remember the three like this: TimeToLive governs “the person is still here but stopped using it”, ClosedTimeToLive governs “the person left but may come back”, and Capacity governs “there are simply too many, which goes first”.
The sample runs on the defaults, so it cannot demonstrate “capacity full, session evicted”. That would need ten thousand sessions, all open at once. This tier can only be covered by reading the contract and doing the arithmetic; there is no button to click. That is where this tier’s boundary lies: demonstrate what can be demonstrated, and for what cannot, say plainly that it is a contract — do not pretend you have seen it.
One last note on why the defaults are so generous. Ten thousand sessions with no expiry is the “get the app working first” setting. For local development or a small internal team, nobody ever hits the limit. Before a real launch, recalculate both numbers against your own concurrency and the state size per session; if the calculation says to change them, change them in the host registration.
14.7 Chapter Summary
State is a server-side, invisible component. Its value never reaches the page; a handler function receives object[] (a JSON array), and putting it in outputs is “storing it”. The initial value is one copy per session; timeToLive counts from the write and returns to the initial value on expiry; deleteCallback is the app’s one chance to learn “the value is gone”, which makes it the right place for resource-releasing code.
BrowserState puts the value in localStorage. It crosses refreshes and tabs and follows the browser; the server wraps it with a process-level key, and an altered value that fails verification is treated as the default; after an app restart the key changes and old values are no longer recognized.
The three ways of storing each have their own lifespan. A component’s value lives one request, State lives one session (plus the hour after close), and BrowserState lives until this browser is replaced. To cross machines or restarts, all three fall short.
Sessions are divided by page load. A refresh and a new tab are both new sessions, so server state “disappears” in both cases; two sessions record their own entries without interfering. Concurrent reads and writes within one session are not a transaction — the later write wins.
The session store has two numbers: capacity (ten thousand by default, dropping the least recently used past that) and idle expiry (never by default). They live in SessionStoreOptions and are changed through host registration.
Three things from this chapter.
- A component’s own value lives one request and is gone on refresh. It is the input and output of “this operation”, not memory.
Statelives one session (plus the hour after close), divided by page load; its value is on the server, invisible and unchangeable to the user; on expiry it returns to the initial value, anddeleteCallbackis the only notice.BrowserStatelives until this browser is replaced, divided by browser; its value is in localStorage and the user can see it (so do not put secrets there), altered values are rejected, and after an app restart the old values are no longer recognized because the process key changed.
One more thing they share: none of the three is persistent. To cross machines, restarts, and users you have to connect a database yourself. What the framework gives you is “remember within a session”, not “save forever”.
By this chapter, every block of the workbench can remember its own things. What is still unsolved is “ten people arriving at once”. The next chapter covers queues and concurrency: whether requests queue up, how many run at the same time, and what happens when that is exceeded.