Tempdb is a system database that SQL Server recreates from model on every instance start, and its architecture is best understood as a set of allocation mechanisms—data files, uniform extents, mixed extents, allocation caches, and version stores—that are optimized for high-concurrency temporary allocation rather than for durable storage. The condition that matters most: tempdb holds no user-durable data, so correctness in designing for it depends on the SQL Server version and on which features (row versioning, In-Memory OLTP, contained availability groups) are enabled, because those change which internal stores exist and where contention arises.

What tempdb is, and what it is not

Tempdb is a system database, present on every instance, and it is recreated at startup from the model database. That single fact drives most of its behavior. Objects meant to persist cannot live there: a table created without a # prefix in tempdb is dropped at restart, and even objects you deliberately create in tempdb do not survive a service restart. Tempdb stores three broad categories of content:

User temporary objects: local and global temporary tables (#t, ##t), table variables, table-valued parameters, and cursors. Internal objects: worktables and workfiles built by the optimizer and execution engine for sorts, hash joins, hash aggregates, spools, and some index builds. Version stores: the row-versioning store that supports snapshot isolation, read-committed snapshot isolation (RCSI), online index operations, triggers using OUTPUT, Multiple Active Result Sets (MARS), and—when enabled—accelerated database recovery (ADR) and the version store used by In-Memory OLTP.

Because tempdb is shared by every database and every session on the instance, it is a global contention point. Much of its architecture exists to reduce that contention: allocation bitmap pages, allocation caches, and the version-store cleanup mechanism are all concurrency controls, not durability features.

A useful distinction for anyone coming from a normal user database: tempdb is not a scratchpad for large reporting or ETL workloads by design intent. It can hold large sorts and spills, but those are consequences of execution plans, not recommended storage. The architecture is tuned for many small, short-lived allocations at high concurrency, and performance problems usually come from allocation contention or version store growth rather than from raw storage throughput (though autogrowth pauses can also hurt).

Files, filegroups, and why multiple data files exist

Tempdb can have multiple data files and, in current supported versions, one log file. The default install creates one data file (tempdev) and one log file (templog), usually sized small. A common production practice is to create multiple, equally sized tempdb data files, typically one per logical processor up to a modest cap, and to set them all to the same initial size with fixed, equal growth increments. The reason is not that tempdb stripes more efficiently by magic; it is that SQL Server's proportional-fill algorithm distributes new allocations across data files, and equal sizing with equal growth keeps that distribution even.

Two architectural details matter here. First, global allocation pages—GAM, SGAM, and the page-free-space (PFS) pages—are shared structures that track which extents are free across the whole database. Multiple files do not create independent GAM/SGAM/PFS sets; those page types exist per file, but allocation decisions consult them on a shared basis. The practical benefit of multiple files is spreading the I/O and the allocation activity across files, which reduces hot spots on any single file's allocation bitmaps.

Second, the tempdb log file is special. In SQL Server 2019 and later, and in Azure SQL Database, tempdb log behavior changed to reduce log contention—most notably, the log no longer needs the same level of synchronous flushing for certain internal operations that it once did, and parallel log writes were introduced. Versions before those changes behave differently, so "how tempdb logging works" is version-dependent. This is a place where a general answer must stop: the precise logging and recovery semantics for tempdb differ across major versions, and the exact feature set should be checked against the version in use.

Allocation units: uniform extents, mixed extents, and the allocation cache

SQL Server allocates space in extents of eight 8-KB pages (64 KB). Two kinds of extents exist:

Uniform extents are owned by a single object. Once an object grows past a threshold, it gets dedicated extents. Mixed extents are shared among up to eight small objects, each taking one page. They exist to avoid wasting a full 64 KB for a tiny table.

This is where tempdb's most famous architectural wrinkle appears: the shared GAM and SGAM pages. Because every new small table or table variable needs a page from a mixed extent, and because the GAM/SGAM pages that track mixed-extent availability are shared, many concurrent sessions creating small temp tables can serialize on those pages. SQL Server mitigated this over time. The key change relevant to architecture is the introduction of allocation caches—specifically, the tempdb allocation cache (sometimes described in the context of "mixed extent allocation" improvements introduced around SQL Server 2016 and refined later) that lets sessions cache pages and extents locally, reducing contention on the shared bitmaps. There is also a per-session cache for user objects and a separate cache for internal objects.

A related structure is the PFS (Page Free Space) page per file, which records free space per page. Contention on PFS and on the shared allocation pages historically caused the classic PAGELATCH waits on tempdb (for example, on pages in the 2:1:1 or 2:1:3 ranges—GAM and SGAM pages). The architectural response is a mix of allocation caches and, in some versions, a reorganized allocation scheme for certain object types. The precise thresholds and page identities differ by version and should be confirmed against that version's documentation; they should not be repeated as fixed numbers without checking.

The design lesson: tempdb contention is usually allocation contention, not data-page contention. If you see heavy PAGELATCH_UP or PAGELATCH_EX waits concentrated on tempdb allocation pages, you are looking at architecture-level behavior, and the fixes—more data files, trace flags that alter allocation behavior in specific versions, or reducing the number of small-object allocations—target that layer.

The version store: a subsystem inside tempdb

The version store is the part of tempdb that exists to support row versioning. When a session needs a consistent read (snapshot isolation or RCSI), or when an operation generates row versions (online index rebuilds, triggers using OUTPUT, MARS, and some others), SQL Server writes row versions into tempdb. Each version record carries the transaction sequence number and a pointer to the previous version, forming a chain. Readers walk the chain to find the version visible to their snapshot.

The version store is not a single object. Architecturally it is a set of internal allocation units managed by the engine, with a background cleanup task (the version store cleaner) that removes versions no longer needed by any active transaction or snapshot. Cleanup can lag if there is a long-running transaction or an open snapshot that prevents version removal. That lag is the mechanism behind the familiar symptom "tempdb is full because the version store cannot be cleaned up," and it is a transaction-scope problem, not a tempdb sizing problem.

Two further points separate the version store from user temp tables:

1: Version store usage is invisible to most monitoring of tempdb free space. It shows up as internal object usage, so a tempdb that appears "full" may be full because of version store growth caused by a long transaction in a completely different database. 2: The version store exists only to the extent that versioning features are used. A database with no snapshot isolation, no RCSI, no online index operations, and no OUTPUT-using triggers may use almost none of it. This is why "how big should tempdb be?" cannot be answered without knowing which features are enabled—the version store's footprint is workload-dependent.

In-Memory OLTP adds a separate, memory-optimized version store mechanism with its own checkpoint files, and ADR adds a persistent version store (PVS) that, in SQL Server 2019 and later, can be redirected to a separate filegroup. When ADR is enabled, the version store architecture changes: some versioning moves from tempdb into the persistent version store, which is exactly the kind of version-dependent detail that makes a blanket "tempdb architecture" answer misleading.

Transaction log and recovery behavior

Tempdb's log behaves unlike a user database's log. Because tempdb is recreated at startup, there is no need to recover it after a crash—there is nothing to recover. SQL Server uses this to reduce logging and log-flush overhead for tempdb operations. In practice, this means tempdb's log is used for rollback and for the operations that require it, but the engine does not maintain the full durability guarantees that user-database logging provides. The precise rules are version-dependent (the 2019 change to tempdb log behavior is the notable example), so an architect should treat "tempdb logging is cheap" as a general principle and confirm the specifics for the deployed version.

A practical consequence: you generally should not rely on tempdb log growth patterns the way you would monitor a user database's log. Tempdb log space is recycled aggressively, and the log file's growth is driven by concurrent transaction size and rollback requirements, not by a durable log chain.

Configuration that follows from the architecture

Putting the architecture to work yields a small set of configuration choices that follow directly from the structures above:

Pre-size the data files and set equal, fixed growth increments. Autogrowth during peak load causes pauses and can fragment the allocation pattern. Equal sizing keeps proportional-fill balanced. Use multiple data files, but not more than the workload needs. The old advice of "one file per core" is a starting point, not a law; the goal is to reduce allocation contention, and beyond a point more files add management overhead without benefit. Modern versions with allocation caches reduce the pressure that motivated large file counts. Keep the version store in mind when sizing. If RCSI, snapshot isolation, online index rebuilds, or ADR are in use, tempdb must accommodate version store growth, and cleanup depends on transaction scopes elsewhere on the instance. Separate tempdb onto appropriate storage if I/O is a factor, but understand that the dominant tempdb waits are often latches (allocation) rather than I/O. Avoid unnecessary small temp objects at high concurrency when you can, because each one touches the allocation machinery; this is an architectural mitigation, not a rule against temp tables.

Where this answer stops, and what causes confusion

The main ambiguity is version. Tempdb's allocation-cache behavior, log behavior, and version-store options (such as ADR's persistent version store) changed across SQL Server releases, and Azure SQL Database and Managed Instance have their own variations. Any specific threshold, trace flag, or page identity should be verified for the exact version and platform in use. A second ambiguity is workload: tempdb architecture looks different in a small OLTP application than in a data warehouse with large spills or in a system with heavy RCSI use. A third is the frequent conflation of "tempdb is full" with "tempdb is undersized"—as noted, version store retention and long-running transactions can fill tempdb even when its files are generously sized. The stable architecture—rebuild-from-model on startup, shared instance-wide usage, extents and allocation caches, version store, and reduced-durability logging—is what this answer covers; the version-specific tuning parameters are what must be checked locally.