Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CubeProxy/lua/init_worker_phase.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-- In OpenResty, math.randomseed should be called in the init_worker phase.
-- Without this, all worker processes would start with the same seed (typically 1),
-- causing math.random() to return the same sequence of values across all workers.
-- This is critical for cache TTL jitter and other randomized behaviors to ensure
-- they are truly distributed and don't lead to synchronized stampedes.
math.randomseed(ngx.now() * 1000 + ngx.worker.id())

local function monitor_cache_usage()
local cache_free_space = ngx.shared.local_cache:free_space()
ngx.shared.local_cache:set("cache_free_space", cache_free_space)
Expand Down
Loading