西维蜀黍

【Linux】配置本地DNS

Linux

Under Linux / UNIX / BSD operating system, you need to edit the /etc/resolv.conf file and add the line:

nameserver {IP-OF-THE-DNS-1}
nameserver {IP-OF-THEISP-DNS-SERVER-2}

Login as the root, enter:

# vi /etc/resolv.conf

OR

$ sudo vi /etc/resolv.conf

Modify or enter nameserver as follows:

nameserver 208.67.222.222
nameserver 208.67.220.220
  ...


【Golang】性能调优 - trace

Tracing

trace 工具可以看到GC被执行的次数和每次执行的时长

Tracing is a way to instrument code to analyze latency throughout the lifecycle of a chain of calls. Go provides golang.org/x/net/trace package as a minimal tracing backend per Go node and provides a minimal instrumentation library with a simple dashboard. Go also provides an execution tracer to trace the runtime events within an interval.

Tracing enables us to:

  • Instrument and analyze application latency in a Go process.
  • Measure the cost of specific calls in a long chain of calls.
  • Figure out the utilization and performance improvements. Bottlenecks are not always obvious without tracing data.
  ...


【Golang】性能调优 - 分析阻塞操作

排查因调用同步原语(synchronization primitives)导致阻塞操作

使用前需要先调用 runtime.SetMutexProfileFraction

在程序中,除了锁的争用会导致阻塞之外,很多逻辑都会导致阻塞。

  ...


【Golang】性能调优 - 分析互斥锁使用

查看因持有互斥锁(mutexes)导致阻塞的情况(堆栈)

使用前需要先调用 runtime.SetBlockProfileRate

$ go tool pprof http://localhost:6060/debug/pprof/mutex
Fetching profile over HTTP from http://localhost:6060/debug/pprof/mutex
Saved profile in /Users/weishi/pprof/pprof.contentions.delay.002.pb.gz
Type: delay
Time: Aug 15, 2020 at 1:54pm (+08)
No samples were found with the default sample value type.
Try "sample_index" command to analyze different sample values.
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 0, 0% of 0 total
      flat  flat%   sum%        cum   cum%
  ...


【Golang】性能调优 - 分析 goroutine 使用

排查 goroutine 泄露

由于 Golang 自带内存回收,所以一般不会发生内存泄露。但凡事都有例外,在 golang 中, goroutine 本身是可能泄露的,或者叫 goroutine 失控,进而导致内存泄露。

  ...