西维蜀黍

【Linux】命令 - ls

参数

  • -R:是否递归,即如果列出的目录中仍有子目录或者文件,将所有目录下面的文件都显示出来。
  • -l:显示文件的形态、权限、拥有者、文件大小、最后修改时间、文件的完整名称(文件名+扩展名)。显示格式是每一行显示一个文件或者目录。
  • -a: List all files, including hidden files
  • -r: list subdirectories recursively
  ...


【Design Pattern】Microservices - Service Mesh(服务网格)Pattern

Background

Why Service Mesh

People write very sophisticated applications and services using higher level protocols like HTTP without even thinking about how TCP controls the packets on their network. This situation is what we need for microservices, where engineers working on services can focus on their business logic and avoid wasting time in writing their own services infrastructure code or managing libraries and frameworks across the whole fleet.

Service-to-service communication is what makes microservices possible. The logic governing communication can be coded into each service without a service mesh layer—but as communication gets more complex, a service mesh becomes more valuable. For cloud-native apps built in a microservices architecture, a service mesh is a way to comprise a large number of discrete services into a functional application.

  ...


【Golang】性能调优 - Golang 程序内存使用分析

Memory Profiling

默认情况下,统计的是当前内存使用数(字节数或对象数量),即使用 --inuse_objects

除此之外,我们还可以使用--alloc-space 来查看和分析当前截止每当前时刻已分配内存的总和(字节数或对象数量),比如每次为一个struct 分配一块新内存空间,都会计数在内(即使在分配之后,马上被GC回收了。而前者来说,就会考虑)。

Name Meaning
inuse_space amount of memory allocated and not released yet
inuse_objects amount of objects allocated and not released yet
alloc_space total amount of memory allocated (regardless of released)
alloc_objects total amount of objects allocated (regardless of released)
  ...


【Golang】性能调优 - PProf

PProf

pprof is a tool for visualization and analysis of profiling data.

pprof reads a collection of profiling samples in profile.proto format and generates reports to visualize and help analyze the data. It can generate both text and graphical reports (through the use of the dot visualization package).

profile.proto is a protocol buffer that describes a set of callstacks and symbolization information. A common usage is to represent a set of sampled callstacks from statistical profiling. The format is described on the proto/profile.proto file. For details on protocol buffers, see https://developers.google.com/protocol-buffers

Profiles can be read from a local file, or over http. Multiple profiles of the same type can be aggregated or compared.

If the profile samples contain machine addresses, pprof can symbolize them through the use of the native binutils tools (addr2line and nm).

想要进行性能优化,首先瞩目在 Go 自身提供的工具链来作为分析依据,本文将带你学习、使用 Go 后花园,涉及如下:

  • runtime/pprof:适用于对一次性运行程序(即你的应用是运行一段时间后就结束了)的运行数据进行分析
  • net/http/pprof:适用于对长时间运行程序(即你的应用是一直不断在运行的),监控程序会启动一个 HTTP Server 以暴露一个提供运行时采样数据的HTTP接口
  ...


【Linux】命令 - date

date是Linux系统里自带的一个系统命令,用来显示当前的系统时间,不过默认显示的结果里包括很多信息,特别是做为文件名输出时,不是很方便 好在date命令里包含格式化输出的选项。

$ date "+%Y-%m-%d"
2020-08-09
$ date "+%Y-%m-%d %H:%M:%S"
2020-08-09 17:51:17
  ...