西维蜀黍

【Database】索引 - 哈希索引(Hash Indexes)

Hash Tables

Refer to https://swsmile.info/post/data-structure-hash-table/

  ...


【Kubernetes】cAdvisor

sdsd

  ...


【Kubernetes】学习

docker 在 Kubernetes 中的角色

Docker 技术依然执行它原本的任务。当 kubernetes 把 pod 调度到节点上,节点上的 kubelet 会指示 docker 启动特定的容器。接着,kubelet 会通过 docker 持续地收集容器的信息,然后提交到主节点上。Docker 如往常一样拉取容器镜像、启动或停止容器。不同点仅仅在于这是由自动化系统控制而非管理员在每个节点上手动操作的。

如果你曾经用过Docker容器技术部署容器,那么可以将Docker看成Kubernetes内部使用的低级别组件。Kubernetes不仅仅支持Docker,还支持Rocket,这是另一种容器技术。

docker仅能在单机上部署容器,而kubernetes可以统一管理各类容器,形成集群。Kubernetes作为Docker生态圈中重要一员,是Google多年大规模容器管理技术的开源版本。Kubernetes支持GCE、vShpere、CoreOS、Azure等平台,也可以直接运行在物理机上。

Kubernetes非常适合做微服务的架构。

其主要功能如下:

  1. 用户不需要关心需要多少台机器,只需要关心软件(服务)运行所需的环境。以服务为中心,你需要关心的是api,如何把大服务拆分成小服务,如何使用api去整合它们。

  2. 以集群的方式运行管理容器。

  3. 解决Docker跨机器容器之间的通讯问题。

  4. Kubernetes的Pods自我修复机制使得容器集群总是运行在用户指定的状态。

  ...


【Prometheus】Recording Rules

Recording Rules

Prometheus supports two types of rules which may be configured and then evaluated at regular intervals: recording rules and alerting rules. To include rules in Prometheus, create a file containing the necessary rule statements and have Prometheus load the file via the rule_files field in the Prometheus configuration. Rule files use YAML.

Recording rules allow you to precompute frequently needed or computationally expensive expressions and save their result as a new set of time series. Querying the precomputed result will then often be much faster than executing the original expression every time it is needed. This is especially useful for dashboards, which need to query the same expression repeatedly every time they refresh.

  ...


【Redis】How to Design Keys

Redis keys are binary safe, this means that you can use any binary sequence as a key, from a string like “foo” to the content of a JPEG file. The empty string is also a valid key.

A few other rules about keys:

  • Very long keys are not a good idea. For instance a key of 1024 bytes is a bad idea not only memory-wise, but also because the lookup of the key in the dataset may require several costly key-comparisons. Even when the task at hand is to match the existence of a large value, hashing it (for example with SHA1) is a better idea, especially from the perspective of memory and bandwidth.
  • Very short keys are often not a good idea. There is little point in writing “u1000flw” as a key if you can instead write “user:1000:followers”. The latter is more readable and the added space is minor compared to the space used by the key object itself and the value object. While short keys will obviously consume a bit less memory, your job is to find the right balance.
  • Try to stick with a schema. For instance “object-type:id” is a good idea, as in “user:1000”. Dots or dashes are often used for multi-word fields, as in comment:1234:reply.to or comment:1234:reply-to.
  • The maximum allowed key size is 512 MB.
  ...


【Redis】Pub/Sub

Publish/Subscribe Pattern

Refer to https://swsmile.info/post/publish-subscribe-pattern/

  ...


【Redis】不同数据类型(Data Types)的存储

  ...


【Redis】数据类型(Data Types)

Strings

Strings are the most basic kind of Redis value. Redis Strings are binary safe, this means that a Redis string can contain any kind of data, for instance a JPEG image or a serialized Ruby object.

A String value can be at max 512 Megabytes in length.

You can do a number of interesting things using strings in Redis, for instance you can:

  ...


【Redis】过期删除和内存淘汰

Redis 过期删除与内存淘汰

Redis 使用的过期删除策略

Redis 是可以对 key 设置过期时间的,因此需要有相应的机制将已过期的键值对删除,而做这个工作的就是过期键值删除策略。

每当我们对一个 key 设置了过期时间时,Redis 会把该 key 带上过期时间存储到一个过期字典(expires dict)中,也就是说「过期字典」保存了数据库中所有 key 的过期时间。

当我们查询一个 key 时,Redis 首先检查该 key 是否存在于过期字典中:

  • 如果不在,则正常读取键值;
  • 如果存在,则会获取该 key 的过期时间,然后与当前系统时间进行比对,如果比系统时间大,那就没有过期,否则判定该 key 已过期。

Redis 使用的过期删除策略是「惰性删除+定期删除」这两种策略配和使用。

  ...


【macOS】开机自动连接SMB

Approach 1 - Configure your Mac to automatically mount an SMB share at Login

  ...