{"id":92668,"date":"2026-08-10T21:48:48","date_gmt":"2026-08-10T13:48:48","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/92668.html"},"modified":"2026-08-10T21:48:48","modified_gmt":"2026-08-10T13:48:48","slug":"go%e5%86%85%e5%ad%98%e6%b3%84%e9%9c%b2%e6%8e%92%e6%9f%a5%e5%ae%9e%e6%88%98%ef%bc%9arss%e4%b8%80%e8%b7%af%e9%a3%99%e5%88%b08g%ef%bc%8c%e5%b1%85%e7%84%b6%e6%98%af-defer-%e8%b8%a9%e4%ba%86%e9%97%ad","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/92668.html","title":{"rendered":"Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218\uff1aRSS\u4e00\u8def\u98d9\u52308G\uff0c\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751"},"content":{"rendered":"<h2>Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218&#xff1a;RSS\u4e00\u8def\u98d9\u52308G&#xff0c;\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751<\/h2>\n<h3>1. \u5185\u5b58\u62a5\u8b66&#xff1a;\u5bb9\u5668 RSS \u76f4\u5954 8GB \u9650\u989d&#xff0c;K8s \u9891\u7e41\u89e6\u53d1 OOM Killed<\/h3>\n<p>\u4e0a\u5468\u4e09\u6e05\u6668&#xff0c;\u544a\u8b66\u5e73\u53f0\u7a81\u7136\u53d1\u6765\u9ad8\u5371\u901a\u77e5&#xff1a;\u68c0\u7d22\u670d\u52a1\u7684 K8s Pod \u5185\u5b58\u5360\u7528&#xff08;RSS&#xff09;\u5448 45 \u5ea6\u89d2\u6301\u7eed\u6500\u5347&#xff0c;\u4ece\u521d\u59cb\u7684 500MB \u4e00\u8def\u98d9\u5230\u4e86 8GB \u5bb9\u5668\u4e0a\u9650\u3002<\/p>\n<p>\u968f\u540e K8s \u89e6\u53d1\u4e86 OOM Killed \u5f3a\u5236\u6740\u6b7b\u5bb9\u5668\u5e76\u91cd\u542f\u3002\u7136\u800c\u65b0 Pod \u542f\u52a8\u4e0d\u5230\u4e24\u5c0f\u65f6&#xff0c;\u5185\u5b58\u53c8\u518d\u6b21\u8d70\u4e0a\u4e86\u540c\u6837\u7684\u6cc4\u9732\u6b7b\u8def\u3002\u6700\u8be1\u5f02\u7684\u662f&#xff0c;Go \u5b98\u65b9 runtime.MemStats \u4e0a\u62a5\u7684 HeapAlloc&#xff08;\u5806\u5206\u914d\u5185\u5b58&#xff09;\u53ea\u6709 600MB&#xff0c;\u4f46\u7cfb\u7edf\u5c42\u7684 RSS \u7269\u7406\u5185\u5b58\u5374\u8017\u5149\u4e86\u6574\u6574 8GB&#xff0c;\u4e24\u8005\u76f8\u5dee\u4e86\u5341\u51e0\u500d\u3002<\/p>\n<p>\u5de5\u7a0b\u5e08\u56e2\u961f\u9762\u5bf9\u8fd9\u79cd\u60c5\u51b5\u5f80\u5f80\u6478\u4e0d\u7740\u5934\u8111&#xff1a;\u5806\u5185\u5b58\u660e\u660e\u4e0d\u600e\u4e48\u6da8&#xff0c;\u4e3a\u4ec0\u4e48 OS \u7684\u7269\u7406\u5185\u5b58\u5374\u88ab\u6b7b\u6b7b\u5360\u4f4f\u4e0d\u653e&#xff1f;\u503c\u73ed\u5de5\u7a0b\u5e08\u5c1d\u8bd5\u4f7f\u7528\u5e38\u89c4\u7684\u5e94\u7528\u65e5\u5fd7\u6392\u67e5&#xff0c;\u4f46\u4ece\u4e1a\u52a1\u65e5\u5fd7\u91cc\u770b\u4e0d\u5230\u4efb\u4f55\u663e\u5f0f\u7684\u5185\u5b58\u6ea2\u51fa\u5f02\u5e38\u62a5\u9519\u3002\u5728\u5bb9\u5668\u5316 K8s \u73af\u5883\u4e0b&#xff0c;\u5f53 RSS \u8fbe\u5230 Cgroup Limit \u65f6&#xff0c;Linux \u5185\u6838\u4f1a\u4e0d\u8b66\u544a\u76f4\u63a5\u53d1\u9001 SIGKILL \u4fe1\u53f7\u7ec8\u6b62\u8fdb\u7a0b&#xff0c;\u8fd9\u5bf9\u9ad8\u53ef\u7528\u4e1a\u52a1\u800c\u8a00\u662f\u6781\u5927\u7684\u5b89\u5168\u5a01\u80c1\u3002<\/p>\n<p>flowchart TD<br \/>\n    Pod[K8s Pod \u542f\u52a8] &#8211;&gt; Alloc[\u5e76\u53d1\u8bf7\u6c42\u89e6\u53d1 time.After]<br \/>\n    Alloc &#8211;&gt; Leak[\u672a\u91ca\u653e\u7684 Timer \u5bf9\u8c61\u5728 runtime \u94fe\u8868\u5806\u79ef]<br \/>\n    Leak &#8211;&gt; RSS[RSS \u7269\u7406\u5185\u5b58\u4ece 500MB \u98d9\u5230 8GB]<br \/>\n    RSS &#8211;&gt; OOM[\u89e6\u53d1 OOM Killed \u5f3a\u6740\u91cd\u542f]<\/p>\n<h3>2. \u6293 pprof \u5206\u6790&#xff1a;\u53d1\u73b0\u5927\u91cf time.After \u95ed\u5305\u672a\u88ab\u5783\u573e\u56de\u6536<\/h3>\n<p>\u4e3a\u4e86\u67e5\u51fa\u7269\u7406\u5185\u5b58\u6cc4\u6f0f\u7684\u771f\u51f6&#xff0c;\u6211\u767b\u5f55\u5bb9\u5668\u76f4\u63a5\u6293\u53d6 Heap Profiling \u91c7\u6837&#xff1a;<\/p>\n<p>go tool pprof -alloc_space &#034;http:\/\/127.0.0.1:6060\/debug\/pprof\/heap&#034;<\/p>\n<p>\u8fdb\u5165\u4ea4\u4e92\u7ec8\u7aef\u540e\u8f93\u5165 top20 -cum \u89c2\u5bdf&#xff1a;\u53d1\u73b0 time.After \u4e0e time.NewTimer \u5185\u90e8\u7684\u7ed3\u6784\u4f53\u5206\u914d\u5360\u636e\u4e86\u7edd\u5927\u591a\u6570\u7684\u5185\u5b58\u9879\u3002<\/p>\n<p>\u7ffb\u770b\u4e1a\u52a1\u4ee3\u7801\u624d\u53d1\u73b0&#xff0c;\u6709\u4f4d\u540c\u4e8b\u5728 for-select \u5faa\u73af\u5904\u7406\u901a\u9053\u8d85\u65f6\u65f6&#xff0c;\u76f4\u63a5\u5199\u4e0b\u4e86&#xff1a;<\/p>\n<p>\/\/ \u9519\u8bef\u793a\u8303&#xff1a;\u6bcf\u6b21\u5faa\u73af\u90fd\u4f1a\u4ea7\u751f\u4e00\u4e2a\u65b0\u7684 Timer \u5bf9\u8c61&#xff0c;\u76f4\u81f3\u8d85\u65f6\u6216GC\u624d\u80fd\u91ca\u653e<br \/>\nselect {<br \/>\ncase msg :&#061; &lt;-ch:<br \/>\n    process(msg)<br \/>\ncase &lt;-time.After(5 * time.Minute):<br \/>\n    log.Println(&#034;timeout&#034;)<br \/>\n}<\/p>\n<p>time.After \u5728\u8ba1\u65f6\u672a\u5230\u4e4b\u524d&#xff0c;\u5e95\u5c42\u7684 Timer \u7ed3\u6784\u4f53\u4f1a\u88ab Go Runtime \u7684\u5168\u5c40 timerBucket \u5f3a\u5f15\u7528\u4f4f&#xff0c;\u5373\u4f7f\u5f53\u524d\u5faa\u73af\u8fed\u4ee3\u5df2\u7ecf\u7ed3\u675f&#xff0c;Timer \u4e0e\u95ed\u5305\u7ed1\u5b9a\u7684\u5185\u5b58\u4e5f\u6839\u672c\u65e0\u6cd5\u88ab\u5783\u573e\u56de\u6536\u5668\u6536\u5272\u3002\u9ad8\u5e76\u53d1\u51b2\u51fb\u4e0b&#xff0c;\u6210\u5343\u4e0a\u4e07\u4e2a Timer \u8fde\u540c\u95ed\u5305\u53d8\u91cf\u5728\u5185\u5b58\u4e2d\u75af\u72c2\u5806\u79ef\u3002<\/p>\n<p>\u6b64\u5916&#xff0c;\u7531\u4e8e Go \u5783\u573e\u56de\u6536\u5668\u53ea\u8d1f\u8d23\u91ca\u653e\u903b\u8f91\u5806\u7a7a\u95f4&#xff0c;\u5728\u6ca1\u6709\u89e6\u53d1\u5f3a\u5236\u5f52\u8fd8\u7ed9 OS \u7684\u673a\u5236\u65f6&#xff0c;\u5185\u5b58\u9875\u4f1a\u88ab\u64cd\u4f5c\u7cfb\u7edf\u7559\u5728 RSS \u96c6\u5408\u4e2d\u3002\u52a0\u4e0a Go 1.12 \u4e4b\u540e\u9ed8\u8ba4\u4f7f\u7528\u7684 MADV_FREE \u673a\u5236&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u5728\u65e0\u5185\u5b58\u538b\u529b\u65f6\u5e76\u4e0d\u4f1a\u7269\u7406\u56de\u6536\u8fd9\u4e9b\u5df2\u91ca\u653e\u7684\u5185\u5b58\u9875&#xff0c;\u5bfc\u81f4\u5bb9\u5668 RSS \u7269\u7406\u5185\u5b58\u4e00\u8def\u66b4\u6da8\u76f4\u5230\u88ab K8s \u5f3a\u6740\u3002<\/p>\n<h3>3. \u91cd\u6784\u4fee\u590d&#xff1a;\u907f\u514d\u5728\u5faa\u73af\u4f53\u5185\u8bef\u7528 time.After<\/h3>\n<p>\u5b9a\u4f4d\u6839\u56e0\u540e&#xff0c;\u6211\u5c06\u5faa\u73af\u4f53\u5185\u7684 time.After \u62bd\u79bb&#xff0c;\u6539\u4e3a\u590d\u7528 time.NewTimer \u5e76\u663e\u5f0f\u5728\u5206\u652f\u4e2d\u91cd\u7f6e&#xff08;Reset&#xff09;\u4e0e\u505c\u6b62&#xff08;Stop&#xff09;\u3002\u901a\u8fc7\u5355\u4f8b\u590d\u7528 Timer \u7ed3\u6784\u4f53&#xff0c;\u4ece\u6839\u672c\u4e0a\u6d88\u9664\u4e86\u9ad8\u5e76\u53d1\u51b2\u51fb\u4e0b\u7684\u7269\u7406\u5185\u5b58\u6cc4\u6f0f\u6839\u6e90\u3002<\/p>\n<p>\u91cd\u6784\u540e\u7684\u9ad8\u53ef\u7528\u901a\u9053\u5904\u7406\u4ee3\u7801\u5982\u4e0b&#xff1a;<\/p>\n<p>package main<\/p>\n<p>import (<br \/>\n&#034;context&#034;<br \/>\n&#034;fmt&#034;<br \/>\n&#034;time&#034;<br \/>\n)<\/p>\n<p>\/\/ ProcessStream \u5b89\u5168\u5730\u5904\u7406\u6d41\u5f0f\u6570\u636e&#xff0c;\u4e25\u9632 Timer \u6cc4\u6f0f<br \/>\nfunc ProcessStream(ctx context.Context, dataChan &lt;-chan string) {<br \/>\n\/\/ \u590d\u7528\u540c\u4e00\u4e2a Timer&#xff0c;\u907f\u514d\u5728 for \u5faa\u73af\u4e2d\u53cd\u590d\u521b\u5efa time.After \u5bfc\u81f4\u5185\u5b58\u7206\u4ed3<br \/>\ntimer :&#061; time.NewTimer(5 * time.Minute)<br \/>\ndefer timer.Stop()<\/p>\n<p>for {<br \/>\n\/\/ \u6bcf\u6b21\u5faa\u73af\u524d\u9700\u91cd\u7f6e Timer<br \/>\nif !timer.Stop() {<br \/>\nselect {<br \/>\ncase &lt;-timer.C:<br \/>\ndefault:<br \/>\n}<br \/>\n}<br \/>\ntimer.Reset(5 * time.Minute)<\/p>\n<p>select {<br \/>\ncase &lt;-ctx.Done():<br \/>\nfmt.Println(&#034;[INFO] \u4e0a\u4e0b\u6587\u7ed3\u675f&#xff0c;\u4f18\u96c5\u9000\u51fa&#034;)<br \/>\nreturn<br \/>\ncase msg, ok :&#061; &lt;-dataChan:<br \/>\nif !ok {<br \/>\nfmt.Println(&#034;[INFO] \u6570\u636e\u901a\u9053\u5173\u95ed&#034;)<br \/>\nreturn<br \/>\n}<br \/>\nfmt.Printf(&#034;[DATA] \u6536\u5230\u6570\u636e: %s<br \/>\n&#034;, msg)<br \/>\ncase &lt;-timer.C:<br \/>\nfmt.Println(&#034;[WARN] 5 \u5206\u949f\u65e0\u6570\u636e&#xff0c;\u89e6\u53d1\u4fdd\u6d3b\u8d85\u65f6&#034;)<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>func main() {<br \/>\nch :&#061; make(chan string, 10)<br \/>\nctx, cancel :&#061; context.WithCancel(context.Background())<br \/>\ndefer cancel()<\/p>\n<p>go ProcessStream(ctx, ch)<br \/>\nch &lt;- &#034;item_1&#034;<br \/>\ntime.Sleep(100 * time.Millisecond)<br \/>\n}<\/p>\n<h3>4. \u538b\u6d4b\u56de\u5f52&#xff1a;4 \u5c0f\u65f6\u5927\u6d41\u91cf\u51b2\u5237&#xff0c;\u5185\u5b58\u62c9\u51fa\u4e00\u6761\u76f4\u7ebf<\/h3>\n<p>\u4ee3\u7801\u4fee\u6539\u63d0\u4ea4\u540e&#xff0c;\u6211\u4eec\u5728\u6d4b\u8bd5\u73af\u5883\u6784\u5efa\u955c\u50cf\u5e76\u542f\u52a8 100 \u7ebf\u7a0b\u5e76\u53d1\u538b\u6d4b&#xff1a;<\/p>\n<p>go test -bench&#061;. -benchmem -memprofile&#061;mem.out<\/p>\n<p>\u7ecf\u8fc7\u6574\u6574 4 \u5c0f\u65f6\u7684\u6301\u7eed\u9ad8\u5f3a\u5ea6\u538b\u529b\u51b2\u5237&#xff0c;\u5bb9\u5668 RSS \u7269\u7406\u5185\u5b58\u7a33\u7a33\u56fa\u5b9a\u5728 680MB \u9644\u8fd1&#xff0c;\u518d\u6ca1\u6709\u51fa\u73b0\u4efb\u4f55\u722c\u5347\u8d8b\u52bf\u3002<\/p>\n<p>\u91d1\u4e1d\u96c0\u53d1\u5e03\u8986\u76d6\u7070\u5ea6\u8282\u70b9\u540e&#xff0c;\u76d1\u63a7\u5927\u76d8\u4e0a\u7684 container_memory_working_set_bytes \u62c9\u51fa\u4e86\u4e00\u6761\u7b14\u76f4\u7684\u5e73\u7ebf&#xff0c;OOM Killed \u62a5\u9519\u5f7b\u5e95\u5f52\u96f6\u3002<\/p>\n<p>\u5728 Go \u73af\u5883\u53d8\u91cf\u914d\u7f6e\u65b9\u9762&#xff0c;\u6211\u4eec\u5728 Dockerfile \u4e2d\u8ffd\u52a0\u4e86&#xff1a;<\/p>\n<p>ENV GODEBUG&#061;madvdontneed&#061;1<\/p>\n<p>\u663e\u5f0f\u544a\u77e5 Go Runtime \u5728 GC \u540e\u7acb\u523b\u4f7f\u7528 MADV_DONTNEED \u91ca\u653e\u7269\u7406\u5185\u5b58\u7ed9 Linux \u5185\u6838&#xff0c;\u6781\u5927\u5730\u6539\u5584\u4e86 K8s \u73af\u5883\u4e0b\u7684\u7269\u7406\u5185\u5b58\u56de\u6536\u6548\u7387&#xff0c;\u6d88\u9664\u4e86\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u5185\u5b58\u7ba1\u7406\u4e4b\u95f4\u7684\u6ede\u540e\u77db\u76fe\u3002<\/p>\n<p>\u6b64\u5916&#xff0c;\u6211\u4eec\u8fd8\u5728 Prometheus \u76d1\u63a7\u4e2d\u914d\u7f6e\u4e86\u9488\u5bf9\u5185\u5b58\u6cc4\u9732\u8d8b\u52bf\u7684\u5bfc\u6570\u9884\u8b66\u6307\u6807&#xff1a;<\/p>\n<p>predict_linear(container_memory_working_set_bytes[1h], 86400) &gt; 8*1024*1024*1024<\/p>\n<p>\u5229\u7528\u7ebf\u6027\u56de\u5f52\u7b97\u6cd5\u63d0\u524d 24 \u5c0f\u65f6\u9884\u6d4b\u6f5c\u5728\u7684\u5185\u5b58\u6cc4\u9732\u98ce\u9669&#xff0c;\u5c06\u751f\u4ea7\u9690\u60a3\u627c\u6740\u5728\u840c\u82bd\u9636\u6bb5\u3002<\/p>\n<h3>5. \u7ecf\u9a8c\u5c0f\u7ed3&#xff1a;Go \u5185\u5b58\u6cc4\u6f0f\u5e38\u89c1\u7684 5 \u4e2a\u6697\u5751<\/h3>\n<li>\u5207\u52ff\u5728 for \u5faa\u73af\u4e2d\u76f4\u63a5\u4f7f\u7528 time.After&#xff1a;\u957f\u5faa\u73af\u4e2d\u7528 time.After \u5c31\u662f\u5728\u5236\u9020\u5185\u5b58\u5b9a\u65f6\u70b8\u5f39&#xff0c;\u52a1\u5fc5\u4f7f\u7528 time.NewTimer \u914d\u5408 Reset\/Stop\u3002<\/li>\n<li>Goroutine \u6cc4\u6f0f\u662f RSS \u66b4\u6da8\u7684\u4e3b\u56e0&#xff1a;\u5411\u672a\u7f13\u51b2\u4e14\u65e0\u63a5\u6536\u8005\u7684 Channel \u5199\u5165\u6570\u636e\u4f1a\u4ee4\u534f\u7a0b\u6c38\u4e45\u6302\u8d77&#xff0c;\u5173\u8054\u7684 Stack \u5185\u5b58\u6c38\u8fdc\u65e0\u6cd5\u88ab GC \u91ca\u653e\u3002<\/li>\n<li>\u533a\u5206 HeapAlloc \u4e0e RSS&#xff1a;Go \u7684 GC \u867d\u7136\u6536\u5272\u4e86\u5806\u5185\u5b58&#xff0c;\u4f46\u7cfb\u7edf\u5c42\u7684 madvise \u91ca\u653e\u7ed9 OS \u53ef\u80fd\u6709\u5ef6\u8fdf&#xff0c;\u770b\u6307\u6807\u8981\u7ed3\u5408 pprof \u4e0e\u5bb9\u5668\u6307\u6807\u4e00\u8d77\u770b\u3002<\/li>\n<li>\u6ce8\u610f Go \u73af\u5883\u53d8\u91cf\u8bbe\u7f6e&#xff1a;\u5728 K8s \u955c\u50cf\u4e2d\u5efa\u8bae\u5f00\u542f GODEBUG&#061;madvdontneed&#061;1&#xff0c;\u786e\u4fdd\u7269\u7406\u5185\u5b58\u53ca\u65f6\u9000\u8fd8\u7ed9\u5bbf\u4e3b\u673a\u3002<\/li>\n<li>\u8b66\u60d5\u5207\u7247\u5e95\u5c42\u6570\u7ec4\u5f3a\u5f15\u7528&#xff1a;\u957f\u751f\u547d\u5468\u671f\u7684\u5207\u7247\u622a\u53d6\u77ed\u5207\u7247\u65f6&#xff08;\u5982 b &#061; a[:2]&#xff09;&#xff0c;\u4f1a\u5bfc\u81f4\u6574\u4e2a\u5927\u6570\u7ec4\u5728\u5185\u5b58\u4e2d\u65e0\u6cd5\u91ca\u653e&#xff0c;\u5e94\u5f53\u4f7f\u7528 copy \u8fdb\u884c\u6df1\u62f7\u8d1d\u9694\u79bb\u3002<\/li>\n<h3>6. \u6df1\u5165\u539f\u7406&#xff1a;Go \u5185\u5b58\u5206\u914d\u5668 mcache\/mcentral \u4e0e OS \u9875\u5f52\u8fd8\u673a\u5236<\/h3>\n<p>\u8981\u7406\u89e3\u4e3a\u4ec0\u4e48 RSS \u7269\u7406\u5185\u5b58\u65e0\u6cd5\u53ca\u65f6\u91ca\u653e&#xff0c;\u5fc5\u987b\u5256\u6790 Go Runtime \u5185\u5b58\u5206\u914d\u5668\u7684\u4e09\u5c42\u67b6\u6784&#xff08;mcache \u2794 mcentral \u2794 mheap&#xff09;\u3002<\/p>\n<p>\u5f53\u7ebf\u7a0b\u7533\u8bf7\u5c0f\u5bf9\u8c61\u5185\u5b58\u65f6&#xff0c;\u4f18\u5148\u4ece Goroutine \u6240\u5728\u7684 P \u7ed1\u5b9a\u7684 mcache \u4e2d\u76f4\u63a5\u5207\u5206&#xff0c;\u8fd9\u4e00\u6b65\u662f\u5b8c\u5168\u65e0\u9501\u7684&#xff1b;\u5f53 mcache \u7a7a\u95f4\u8017\u5c3d&#xff0c;\u4f1a\u5411\u5168\u5c40\u7684 mcentral \u7533\u8bf7\u8865\u5145 mspan \u9875\u3002\u4f46\u5728\u9ad8\u5e76\u53d1\u521b\u5efa time.After \u95ed\u5305\u7684\u573a\u666f\u4e0b&#xff0c;\u5927\u91cf\u6781\u5c0f\u7ed3\u6784\u4f53\u6563\u843d\u5728\u4e0d\u540c\u7684 mspan \u5185\u5b58\u9875\u4e2d\u3002<\/p>\n<p>\u54ea\u6015 GC \u6807\u8bb0\u6e05\u9664\u7b97\u6cd5\u91ca\u653e\u4e86 95% \u7684\u5bf9\u8c61&#xff0c;\u4f46\u53ea\u8981\u8be5 mspan \u5185\u90e8\u8fd8\u6b8b\u7559 1 \u4e2a\u672a\u8d85\u65f6\u7684 Timer \u7ed3\u6784\u4f53&#xff0c;\u6574\u9875 8KB \u7269\u7406\u5185\u5b58\u5c31\u65e0\u6cd5\u5f52\u8fd8\u7ed9\u7cfb\u7edf\u3002\u8fd9\u79cd\u4e25\u91cd\u7684\u201c\u5185\u5b58\u788e\u7247\u5316&#xff08;Memory Fragmentation&#xff09;\u201d\u662f\u5bfc\u81f4\u7cfb\u7edf RSS \u6307\u6807\u865a\u9ad8\u98d9\u5347\u7684\u5e95\u5c42\u7269\u7406\u903b\u8f91\u3002\u5728\u5de5\u7a0b\u91cd\u6784\u4e2d&#xff0c;\u901a\u8fc7\u663e\u5f0f\u590d\u7528 time.NewTimer&#xff0c;\u4e0d\u4ec5\u6d88\u9664\u4e86\u5806\u5206\u914d\u5f00\u9500&#xff0c;\u8fd8\u5927\u5e45\u51cf\u8f7b\u4e86 Garbage Collector \u6807\u8bb0\u626b\u63cf\u7684 CPU \u541e\u5410\u8d1f\u62c5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218&#xff1a;RSS\u4e00\u8def\u98d9\u52308G&#xff0c;\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751<br \/>\n1. \u5185\u5b58\u62a5\u8b66&#xff1a;\u5bb9\u5668 RSS \u76f4\u5954 8GB \u9650\u989d&#xff0c;K8s \u9891\u7e41\u89e6\u53d1 OOM Killed<br \/>\n\u4e0a\u5468\u4e09\u6e05\u6668&#xff0c;\u544a\u8b66\u5e73\u53f0\u7a81\u7136\u53d1\u6765\u9ad8\u5371\u901a\u77e5&#xff1a;\u68c0\u7d22\u670d\u52a1\u7684 K8s Pod \u5185\u5b58\u5360\u7528&#xff08;RSS&#xff09;\u5448 45 \u5ea6\u89d2\u6301\u7eed\u6500\u5347&#xff0c;\u4ece\u521d\u59cb\u7684 500MB \u4e00\u8def\u98d9\u5230\u4e86 8GB \u5bb9\u5668\u4e0a\u9650\u3002<br \/>\n\u968f\u540e K8s \u89e6\u53d1\u4e86 OOM<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[50],"topic":[],"class_list":["post-92668","post","type-post","status-publish","format-standard","hentry","category-server","tag-50"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218\uff1aRSS\u4e00\u8def\u98d9\u52308G\uff0c\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/92668.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218\uff1aRSS\u4e00\u8def\u98d9\u52308G\uff0c\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218&#xff1a;RSS\u4e00\u8def\u98d9\u52308G&#xff0c;\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751 1. \u5185\u5b58\u62a5\u8b66&#xff1a;\u5bb9\u5668 RSS \u76f4\u5954 8GB \u9650\u989d&#xff0c;K8s \u9891\u7e41\u89e6\u53d1 OOM Killed \u4e0a\u5468\u4e09\u6e05\u6668&#xff0c;\u544a\u8b66\u5e73\u53f0\u7a81\u7136\u53d1\u6765\u9ad8\u5371\u901a\u77e5&#xff1a;\u68c0\u7d22\u670d\u52a1\u7684 K8s Pod \u5185\u5b58\u5360\u7528&#xff08;RSS&#xff09;\u5448 45 \u5ea6\u89d2\u6301\u7eed\u6500\u5347&#xff0c;\u4ece\u521d\u59cb\u7684 500MB \u4e00\u8def\u98d9\u5230\u4e86 8GB \u5bb9\u5668\u4e0a\u9650\u3002 \u968f\u540e K8s \u89e6\u53d1\u4e86 OOM\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/92668.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-10T13:48:48+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92668.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/92668.html\",\"name\":\"Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218\uff1aRSS\u4e00\u8def\u98d9\u52308G\uff0c\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-10T13:48:48+00:00\",\"dateModified\":\"2026-08-10T13:48:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/92668.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/92668.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92668.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218\uff1aRSS\u4e00\u8def\u98d9\u52308G\uff0c\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218\uff1aRSS\u4e00\u8def\u98d9\u52308G\uff0c\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/92668.html","og_locale":"zh_CN","og_type":"article","og_title":"Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218\uff1aRSS\u4e00\u8def\u98d9\u52308G\uff0c\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218&#xff1a;RSS\u4e00\u8def\u98d9\u52308G&#xff0c;\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751 1. \u5185\u5b58\u62a5\u8b66&#xff1a;\u5bb9\u5668 RSS \u76f4\u5954 8GB \u9650\u989d&#xff0c;K8s \u9891\u7e41\u89e6\u53d1 OOM Killed \u4e0a\u5468\u4e09\u6e05\u6668&#xff0c;\u544a\u8b66\u5e73\u53f0\u7a81\u7136\u53d1\u6765\u9ad8\u5371\u901a\u77e5&#xff1a;\u68c0\u7d22\u670d\u52a1\u7684 K8s Pod \u5185\u5b58\u5360\u7528&#xff08;RSS&#xff09;\u5448 45 \u5ea6\u89d2\u6301\u7eed\u6500\u5347&#xff0c;\u4ece\u521d\u59cb\u7684 500MB \u4e00\u8def\u98d9\u5230\u4e86 8GB \u5bb9\u5668\u4e0a\u9650\u3002 \u968f\u540e K8s \u89e6\u53d1\u4e86 OOM","og_url":"https:\/\/www.wsisp.com\/helps\/92668.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-10T13:48:48+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/92668.html","url":"https:\/\/www.wsisp.com\/helps\/92668.html","name":"Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218\uff1aRSS\u4e00\u8def\u98d9\u52308G\uff0c\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-10T13:48:48+00:00","dateModified":"2026-08-10T13:48:48+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/92668.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/92668.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/92668.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Go\u5185\u5b58\u6cc4\u9732\u6392\u67e5\u5b9e\u6218\uff1aRSS\u4e00\u8def\u98d9\u52308G\uff0c\u5c45\u7136\u662f defer \u8e29\u4e86\u95ed\u5305\u5751"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/92668","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=92668"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/92668\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=92668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=92668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=92668"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=92668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}