Big worlds: streaming, LOD and interest management

Grow Beacon Yard to three zones without growing every player's bill. Pick streaming modes per model, integrity modes and pre-fetching, SLIM level of detail, a per-zone draw-call budget, and interest management for the drone stream.

Lab lesson, about 75 minutes, 8 steps

By the end you can

  • Choose a ModelStreamingMode for each kind of model in a three-zone yard, and the Workspace streaming settings around them
  • Keep players out of unloaded areas with StreamingIntegrityMode and pre-fetch destinations with RequestStreamAroundAsync
  • Use SLIM level of detail where it applies, and budget draw calls per zone with instancing in mind
  • Send your own streams only to players who need them, with zones and a hysteresis band

Before this: The network budget: measure, batch, pack, Mobile: streaming, memory and draw budgets

1The yard grows to three zones

At m14-ship the yard is one walled square, and streaming is already on. The project file sets it on Workspace:

      "$className": "Workspace",
      "$properties": {
        "Gravity": 196.2,
        "StreamingEnabled": true,
        "StreamingMinRadius": 128,
        "StreamingTargetRadius": 512
Figure 1.1

Instance streamingInstance streamingThe engine sends each client only the Workspace content near that player, and can remove distant content when memory is short.Think of it as stage sets built as you walk. sends each client only part of Workspace. Parts inside StreamingMinRadius of the player stream in first and never stream out. Parts out to StreamingTargetRadius stream in when there is room. The docs recommend the defaults of 64 and 1,024 studs for most games, and say the space between the two acts as a buffer if new content stops arriving for a moment1. Beacon Yard chose 128 and 512 because the whole square fits inside 128.

Roblox Studio
Studio Play of Beacon Yard at m14-ship with the camera pulled far back, the Streaming panel of the Network Stats overlay open, and coloured regions around the character marking the minimum and target streaming radii.
Figure 1.2.

The Streaming debug view (Shift+Ctrl+F3, then Shift+1 until the fourth panel): the coloured regions are the minimum and target radii around you.

The design module's blockout grows the map to three zones linked in a line: WestApron, CentralYard and NorthVault (see Prototype fast: paper, greybox, blockout). Now the radii start to matter, and so does everything else in this lesson.

With Beacon Yard's StreamingMinRadius of 128, a scrap stack 100 studs from your character has streamed in. Can it stream out while you stand still?

  1. No: regions inside StreamingMinRadius never stream out
  2. Yes: anything can stream out when memory is low
  3. Yes: parts stream out after 60 seconds unused
  4. No: nothing streams out while StreamingEnabled is on
Answer

No: regions inside StreamingMinRadius never stream out. Inside StreamingMinRadius content streams in first and stays. A bigger minimum radius costs memory and server bandwidth for every player, which is why the docs suggest 64.

Open this step in lesson mode · Link to this step · This confused me

2Choose a streaming mode per model

Each Model chooses how it streams with ModelStreamingMode1:

ModeWhat happensUse it for
Nonatomic (default)Parts stream in and out on their own. With Workspace.ModelStreamingBehavior set to Improved, the model arrives with its first eligible partScenery: scrap piles, walls, crates
AtomicEvery original descendant arrives together and leaves togetherThings a client script reads as a unit, such as a crawler's root and health bar
PersistentSent after join, never streamed outVery rare: a few parts client code must always reach
PersistentPerPlayerPersistent for players added with AddPersistentPlayer, Atomic for othersA personal object only its owner must always see

Two more rules from the docs change Beacon Yard's choices. Instances a client script creates are exempt from streaming out unless they sit under a server-created instance, so the client-built drones from the network budget lesson never stream out by themselves; DroneClient must remove them. And atomic grouping only applies to the first replication: parts added to an atomic model later stream normally.

Match each Beacon Yard model in the three-zone yard to the streaming mode that fits.

  1. A crawler: the client reads its root part and health attribute together
  2. Forty scrap crates scattered across the north vault
  3. The beacon pedestal the first-minute guide beam points at from anywhere
  4. A drone model DroneClient builds from the stream
Answer

A crawler: the client reads its root part and health attribute together: Atomic; Forty scrap crates scattered across the north vault: Nonatomic; The beacon pedestal the first-minute guide beam points at from anywhere: Persistent; A drone model DroneClient builds from the stream: None: client-created, so DroneClient removes it. Atomic for units a script reads, Nonatomic for scenery, Persistent only for the rare part every client must reach (wait for Workspace.PersistentLoaded before reading it), and client-created models are yours to clean up.

Open this step in lesson mode · Link to this step · This confused me

3Outrunning the stream

A player can move faster than content arrives: a speed boost down a long corridor, or a gate that moves them into another zone. StreamingIntegrityMode decides what happens then2:

  • Disabled: never pause. The player can fall through a floor that has not arrived.
  • MinimumRadiusPause: pause all client simulation until content up to the minimum radius has streamed in.
  • PauseOutsideLoadedArea: pause the player only when part of their bounding box is outside the loaded area. The docs recommend this one.

When the server knows where a player is about to go, it can ask for that area first with Player:RequestStreamAroundAsync(position, timeOut)3. It yields while it works, so call it before moving the character:

Request, then moveA cyan gate box leads to a copper request box that pre-fetches the vault, which leads to a copper move box that pivots the character.serverthenGateplayer steps inRequeststream the vaultMovePivotTo
Figure 3.1. Ask for the destination first; the integrity mode then rarely has to pause anyone.
luau
-- Server: the zone gate into NorthVault.
local function sendThroughGate(player: Player, target: CFrame)
	player:RequestStreamAroundAsync(target.Position, 2)
	local character = player.Character
	if character and character.Parent then
		character:PivotTo(target)
	end
end

Player:AddReplicationFocus() keeps an extra area loaded until you remove it, but each focus costs the server streaming work: one player with nine moving foci can cost as much as ten players1. Turning on Workspace.PredictiveStreamingMode lets the engine pre-fetch likely spawn points and places a player just left, on top of your own requests.

Two versions of the NorthVault gate, with StreamingIntegrityMode set to PauseOutsideLoadedArea. What does the player see?

-- Version A
character:PivotTo(target)
player:RequestStreamAroundAsync(target.Position, 2)
 
-- Version B
player:RequestStreamAroundAsync(target.Position, 2)
character:PivotTo(target)
  1. A: a pause screen while the vault streams in. B: usually no pause, because the area was requested first
  2. A and B look the same, because PivotTo waits for streaming
  3. A: the player falls through the floor. B: a pause screen
  4. B pauses longer, because the request yields first
Answer

A: a pause screen while the vault streams in. B: usually no pause, because the area was requested first. Request, then move. The docs show the same order for a teleport by CFrame: pre-fetch the destination so the integrity mode rarely has to pause anyone.

Open this step in lesson mode · Link to this step · This confused me

4Level of detail and SLIM

Streaming leaves holes in the distance. Model.LevelOfDetail fills them with lightweight stand-ins. Its newest option, SLIM (Scalable Lightweight Interactive Models), sends the model to a cloud service that builds composite meshes at several levels of detail; clients draw those when the real model has streamed out, or when the composite is cheaper to draw. It cuts draw calls, triangles and memory4.

SLIM has prerequisites and limits, all from the docs:

  • StreamingEnabled on, the place saved to Roblox (not a local file) and Team Create on.
  • Static models only: adding or removing parts, changing materials or animating at runtime stops SLIM from drawing the model correctly.

A separate tip from the streaming techniques page helps both streaming and SLIM: group parts that belong together, such as all the parts of a stack, and keep the spatial extent of each model under about 64 cubic studs, so the whole model is more likely to stream in together5.

That second rule matters for Beacon Yard. MapBuilder builds the yard in code when the server starts. A model created at runtime is not in the saved place for the cloud service to process, so the new zones' scenery has to be authored as models in the place (the team tooling lesson's plugin can build them in Edit mode from the zone data) before SLIM can help.

Why won't setting LevelOfDetail to SLIM inside MapBuilder.luau, on scrap models it creates when the server starts, give Beacon Yard SLIM stand-ins?

  1. SLIM builds its composites in the cloud from models saved in the place; models created at runtime are not there to process
  2. SLIM only works on avatars
  3. LevelOfDetail can only be set by a LocalScript
  4. SLIM needs StreamingEnabled, which Beacon Yard has off
Answer

SLIM builds its composites in the cloud from models saved in the place; models created at runtime are not there to process. Author static zone scenery as models in the place, set LevelOfDetail to SLIM there, and keep runtime-built parts for things that change.

Open this step in lesson mode · Link to this step · This confused me

5A draw-call budget per zone

A draw call is one set of instructions from the engine to the graphics chip, and each has real overhead, so fewer per frame is cheaper. The engine instances identical meshes: MeshParts with the same MeshContent share one draw call when their SurfaceAppearance is identical, or (with none) their TextureContent is identical, or (with neither) their material is identical. You can see the current count under Render Stats > Timing in Studio, or with Shift+F2 in a client6.

So a zone's scenery has a cost you can estimate before you build it: count the instancing groups.

Luau
-- One entry per kind of scrap prop planned for the north vault.
local props = {
	{ mesh = "Crate", surface = "Rust", count = 30 },
	{ mesh = "Crate", surface = "RustRed", count = 10 },
	{ mesh = "Pipe", texture = "PipeTex", count = 12 },
	{ mesh = "Pipe", texture = "PipeTexDirty", count = 8 },
	{ mesh = "Barrel", material = "Metal", count = 25 },
	{ mesh = "Barrel", material = "Metal", count = 5 },
}
 
local groups, total = {}, 0
for _, p in props do
	local look = p.surface or p.texture or p.material
	local key = p.mesh .. "|" .. look
	groups[key] = (groups[key] or 0) + p.count
	total += p.count
end
 
local n = 0
for key, count in groups do
	n += 1
end
print(string.format("%d props, %d instancing groups", total, n))
Figure 5.1. Run it in the lesson view or in the Studio command bar.

This counts one part of the cost (lights, shadows and transparency add work of their own), and it is the part you control while placing props. Studios set a draw-call budget per zone on their weakest target phone and check it with Render Stats while standing in each zone.

In the cell above, how many instancing groups do the 90 props make?

Answer

5 groups. Crate|Rust, Crate|RustRed, Pipe|PipeTex, Pipe|PipeTexDirty and Barrel|Metal: five groups. Merging the two pipe textures into one would save a group without changing the count of props.

Open this step in lesson mode · Link to this step · This confused me

6Your own streams need interest management

Streaming covers instances. It does not cover your remotes. If you broadcast the drone stream with FireAllClients, a player in the north vault receives updates for a drone in the west apron. At m15-scale every drone and viewer uses CentralYard. At m16-design-pass, DroneService picks the nearest ZoneLayout box and uses its zone links. Deciding who receives what is interest managementInterest managementDeciding which players receive which updates, so each one gets what matters to them instead of everything.Think of it as walkie-talkies with a channel per zone and a limited range., and for your own streams you write it.

Server sideInterest management for your own streams is walkie-talkies with a channel per zone and a limited range.
In the pictureIn Roblox
A drone's walkie-talkieThat drone's snapshots in the server's stream
One channel per zone, linked zones shareRecipients only in the drone's zone or a linked zone
Limited rangeGround-plan distance up to ENTER_RANGE
Keep hearing a little further once tuned inKeep receiving up to LEAVE_RANGE (hysteresis)

See the whole analogy cast

Give every drone a walkie-talkie. Each zone has its own channel, and linked zones can hear each other. A player hears a drone only on a channel they can reach and within range. Once they can hear it, they keep hearing it a little further out, so a player standing right on the edge does not hear it cut in and out.

Think of it as Walkie-talkies with a channel per zone and a limited range

Who hears the droneA copper drone box in CentralYard sends to a cyan WestApron player box through a linked zone, while a shared NorthVault box far away receives nothing.snapshotWestApron100 studs: sendDroneCentralYardNorthVault150 studs: no
Figure 6.1. Linked zone and in range: send. Same map, wrong zone or too far: do not.

The band between starting and stopping is hysteresisHysteresisUsing a different threshold to switch something on than to switch it off, so a value near the line does not flicker.Think of it as a thermostat that heats below 19 degrees and stops at 21, instead of clicking on and off at 20.. Beacon Yard starts sending a drone at 120 studs and stops at 140, on the ground plan, so height does not count.

Server sideRemember: Interest management for your own streams is walkie-talkies with a channel per zone and a limited range.

On the walkie-talkie, ENTER is the range where you start hearing a drone and LEAVE is the range where you lose it. A player walking out from 125 to 135 studs keeps hearing the drone they already had, while a player who walks in from far away only picks it up at 120. Write it:

Luau with roblox-lite (not Roblox)
local ENTER, LEAVE = 120, 140
 
-- viewers: { id, position }. current: ids that received the last update.
local function recipients(dronePos: Vector3, viewers, current)
	local result = {}
	for _, v in viewers do
		-- Flat distance; ENTER to start, LEAVE to keep.
		if (v.position - dronePos).Magnitude <= ENTER then
			result[v.id] = true
		end
	end
	return result
end
 
local drone = Vector3.new(0, 4, 0)
local viewers = {
	{ id = 1, position = Vector3.new(30, 3, 0) },
	{ id = 3, position = Vector3.new(0, 3, 130) },
	{ id = 4, position = Vector3.new(0, 3, 150) },
	{ id = 5, position = Vector3.new(10, 154, 0) },
}
local set = recipients(drone, viewers, { [3] = true, [4] = true })
local ids = {}
for id in set do
	table.insert(ids, id)
end
table.sort(ids)
print(table.concat(ids, " "))
Figure 6.2. Run it in the lesson view or in the Studio command bar. The lesson view checks it with tests.

Which Beacon Yard messages should still go to every player, whatever zone they are in?

  1. RoundState: the drill phase and its timer
  2. A drone snapshot
  3. An AnnounceService message about a live event
  4. A hit spark where a crawler took damage
  5. A leaderboard refresh
Answer

RoundState: the drill phase and its timer; An AnnounceService message about a live event; A leaderboard refresh. The round, announcements and the leaderboard are about the whole server, so they stay global. A snapshot and a spark only matter to players who can see them.

Open this step in lesson mode · Link to this step · This confused me

7Build it: streaming and drone relevance

Build along

m14-ship to m15-scale

  • default.project.json
  • src/server/CrawlerService.luau
  • src/shared/StreamingPlan.luau
  • src/shared/Relevance.luau
  • src/server/DroneService.luau
  • src/client/DroneClient.luau
  • unit/specs/Relevance.spec.luau
  1. Set ModelStreamingBehavior, StreamingIntegrityMode and StreamOutBehavior in the Workspace properties in default.project.json. Check the synced values in Studio.

    You should see Workspace has Improved, PauseOutsideLoadedArea and Opportunistic after Rojo sync.

  2. Apply StreamingPlan.apply(model) when building the crawler. StreamingPlan maps Crawler to Enum.ModelStreamingMode.Atomic.

    You should see A crawler appears as a complete model on the client.

  3. Use Relevance.recipients to refresh each drone's recipient set in sendSnapshots. Use CentralYard for drones and viewers and pass an empty link list. Enter at 120 studs and leave beyond 140 using horizontal distance. Send one packet per viewer only when it contains a drone. Check linked and unlinked zones separately with unit/specs/Relevance.spec.luau.

    You should see Viewers more than 140 studs from the drone receive no packet for it.

  4. Expire each track using its last arrival time in DroneClient. Discard the sequence baseline on the next packet after more than half a second with no accepted packet.

    You should see A client removes a drone after half a second of silence for that track and can draw it again when packets resume.

  5. Read draw calls from Render Stats > Timing at the yard's centre and record them beside the network budget. Repeat per zone once m16-design-pass supplies the larger yard.

    You should see You have a measured draw-call baseline for CentralYard.

Sending one packet per player with FireClient replaces one FireAllClients call. Why is that usually a win for the drone stream?

  1. Each player's packet holds only the drones they can reach, so the total bytes sent drop as the world grows, even though there are more calls
  2. FireClient is free, while FireAllClients counts against a limit
  3. FireClient packets skip the 1,000-byte limit
  4. It lets the client choose which drones it receives
Answer

Each player's packet holds only the drones they can reach, so the total bytes sent drop as the world grows, even though there are more calls. More calls, fewer bytes. Measure both: if every player can see every drone, per-player packets cost more CPU for no saving, and FireAllClients is fine.

Open this step in lesson mode · Link to this step · This confused me

8Challenges and recap

Other ways pros do this

OptionWhat it isWhen pros pick itTrade-offs
Instance streaming aloneThe engine sends nearby parts; your remotes broadcast.Small maps where every player can see most of the action, like the yard at m14-ship.No code; your own streams still cost every player full price.
Zones plus distance with hysteresisThis lesson's rule for your own streams.A few large zones with clear links, such as Beacon Yard's three.Cheap to compute for tens of players and entities; you keep the zone links up to date.
Spatial gridBucket entities and players into grid cells and check only nearby cells.Hundreds of entities and players where checking every pair costs real server time.More code and edge cases at cell borders; only worth it when profiling says so.
Where does it break?“Walkie-talkies with a channel per zone and a limited range” is a good picture of interest management for your own streams. Where does it stop being true?

It breaks here. Something far away is big enough to see or hear over the wall, such as a huge explosion: players off the channel never get it, though they could see it.

The true model. Relevance is a cheap stand-in for what each player can perceive. Large, loud or server-wide events need a wider rule or a global message.

A drone in NorthVault explodes in a huge flash that players in WestApron should see over the wall. Under the walkie-talkie rule, what goes wrong?

  1. WestApron players are not on the drone's channel, so they never get the event, even though they could see it
  2. Everyone receives the flash twice
  3. The drone keeps sending to WestApron after it explodes
  4. Nothing; distance rules always match what players can see
Answer

WestApron players are not on the drone's channel, so they never get the event, even though they could see it. Interest management guesses what matters to each player. Big events, sounds and anything players can see from far away need their own, wider rule.

Level 1, Apprentice

Challenge

Look at streaming and rendering at m14-ship before you change anything.

Start from
The game at milestone m14 (download)

Done means

  • You opened the Streaming debug panel in a Studio test (Shift+Ctrl+F3, then Shift+1 until the fourth panel shows)
  • You noted the streaming settings it reports and which coloured regions appear around you
  • You wrote down the draw calls from Render Stats at the spawn pad and at the beacon

Hints

  1. Raise StarterPlayer.CameraMaxZoomDistance in Edit mode to see the regions from far out.
  2. Render Stats > Timing shows draw calls in Studio.

Level 2, Builder

Challenge

Fix recipients in the recipients-cell Run above.

Start from
The game at milestone m14 (download)
Check it here
Run the code cell in the lesson view; the challenge completes when it passes. No Studio needed.

Done means

  • Distance is measured on the ground plan, ignoring height
  • A viewer starts receiving inside ENTER and keeps receiving inside LEAVE
  • Every test in recipients-cell passes

Hints

  1. Build a Vector3 with Y set to 0 from the difference, or use X and Z directly.
  2. local limit = if current[v.id] then LEAVE else ENTER
Solution
luau
local ENTER, LEAVE = 120, 140
 
local function recipients(dronePos: Vector3, viewers, current)
	local result = {}
	for _, v in viewers do
		local dx, dz = v.position.X - dronePos.X, v.position.Z - dronePos.Z
		local limit = if current[v.id] then LEAVE else ENTER
		if math.sqrt(dx * dx + dz * dz) <= limit then
			result[v.id] = true
		end
	end
	return result
end
 
local drone = Vector3.new(0, 4, 0)
local viewers = {
	{ id = 1, position = Vector3.new(30, 3, 0) },
	{ id = 3, position = Vector3.new(0, 3, 130) },
	{ id = 4, position = Vector3.new(0, 3, 150) },
	{ id = 5, position = Vector3.new(10, 154, 0) },
}
local set = recipients(drone, viewers, { [3] = true, [4] = true })
local ids = {}
for id in set do
	table.insert(ids, id)
end
table.sort(ids)
print(table.concat(ids, " "))

Why use two ranges (120 to start, 140 to stop) instead of one 130-stud range?

  1. A player standing near 130 studs would cross the line back and forth, and the drone would appear and vanish on every small step
  2. Two ranges send fewer bytes than one
  3. The engine requires a minimum and a target radius
  4. So players in different zones get different ranges
Answer

A player standing near 130 studs would cross the line back and forth, and the drone would appear and vanish on every small step. Hysteresis trades a few extra studs of sending for no flicker. Streaming's minimum and target radii work in a similar spirit.

Level 3, Professional

Challenge

Write the relevance rules in the game repo's challenges/work/relevance.luau, then run the big-worlds challenge through the Course Runner.

Start from
The game at milestone m14 (download)
Grade it
In Studio, press Play, then run game.ServerScriptService.RunGameTests:Invoke("big-worlds") in the server command bar. Copy the pass code from Output.

Done means

  • challenges/work/relevance.luau treats zone links as undirected and blocks unlinked zones
  • recipients uses ground-plan distance with a 120 to 140 stud hysteresis band and returns a new set
  • The big-worlds challenge prints TEST PASS for all twelve checks

Hints

  1. zonesTouch: true for the same zone, or for a link with a and b in either order.
  2. Never write into current; build a fresh table and return it.

Retiring the analogy

You no longer need “walkie-talkies with a channel per zone and a limited range”. Relevance is a cheap stand-in for what each player can perceive. Large, loud or server-wide events need a wider rule or a global message.

Recap

  1. Instance streaming sends each client the parts near it; StreamingMinRadius is the always-kept core, and Beacon Yard sets 128 and 512 in its project file.
  2. Pick ModelStreamingMode per kind of model: Nonatomic for scenery, Atomic for units a script reads, Persistent only for a rare must-have; client-built models are yours to remove.
  3. PauseOutsideLoadedArea keeps players out of unloaded areas, and RequestStreamAroundAsync before a move makes that pause rare.
  4. SLIM gives distant static models cheap composite stand-ins, but only for models saved in a Team Create place, not parts built at runtime.
  5. Budget draw calls per zone with instancing in mind, and send your own streams only to players in a reachable zone and range, with a hysteresis band.

Interest management for your own streams is walkie-talkies with a channel per zone and a limited range, until something far away is big enough to see or hear over the wall, such as a huge explosion: players off the channel never get it, though they could see it.

Next A 50-player server: budgets, Parallel Luau and native code

Open this step in lesson mode · Link to this step · This confused me