BitMap

所谓的Bit-map就是用一个bit位来标记某个元素对应的Value, 而Key即是该元素。由于采用了Bit为单位来存储数据,因此在存储空间方面,可以大大节省。

我们可以用一个unsigned int类型的数组或者向量来表示位图,假设我们定义vector a,则 第i位可表示为a[i/32]的i%32位(其中,32*N+r = i,r为i%32,也就是i/32的余数)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Bitmap
{
private:
vector<size_t> v;
public:
Bitmap(size_t num) : v((num>>5)+1, 0) {}
//set 1
void set(size_t num)
{
v[num>>5] |= (1<<(num & 31)); // num & 31 equals num % 32
}
//set 0
void clean(size_t num)
{
v[num>>5] &= ~(1<<(num & 31));
}
//if exist or not
bool isExist(size_t num)
{
bool is = 0;
size_t r = 1 << (num & 31); //r represents remainder
if(r == (v[num>>5] & r))
is = 1;
return is;
}
};

Docker

  • docker是应用 打包、分发和部署的工具

Linux内核提供namespace完成隔离,Cgroup完成资源限制。namespace+Cgroup构成了容器的底层技术(rootfs是容器文件系统层技术)。

  • 多容器通信:docker network创建虚拟网络
  • docker-compose 把项目的多个服务集合到一起,一键运行

优点

  • 部署方便
  • 部署安全
  • 隔离性好
  • 快速回滚
  • 成本低
  • 管理成本低

缺点

  • 隔离性:

基于hypervisor的虚拟技术,在隔离性上比容器技术更好,因为系统硬件资源完全上虚拟化,当一台虚拟机出现系统级别问题,不会影响到同一宿主机的其他虚拟机。(但是容器就不一样了,容器之间共享同一个操作系统内核及其它组件)

  • 性能:

运用不同的技术对应用本身进行了一定程度的封装与隔离,在降低应用和应用之间以及应用和环境之间的耦合性上做了很多努力,但是随之而来的,就会产生更过的网络连接转发和数据交互

  • 存储方案

需要外挂网络磁盘或者映射到宿主机上

微服务

服务注册与发现

**单体服务拆分为微服务后,如果微服务之间存在调用依赖,就需要得到目标服务的服务地址,也就是微服务治理的”服务发现“。**要完成服务发现,就需要将服务信息存储到某个载体,载体本身即是微服务治理的”服务注册中心“,而存储到载体的动作即是”服务注册“。

可观测性

微服务由于较单体应用有了更多的部署载体,需要对众多服务间的调用关系、状态有清晰的掌控。可观测性就包括了

  • 调用拓扑关系
  • 监控(Metrics)
  • 日志(Logging)
  • 调用追踪(Trace)

流量管理

  • 灰度发布
  • A/B实验

鉴权

C/C++函数调用过程分析

反向代理和正向代理

  • 反向代理的对象是服务器,目的是隐藏服务器端,实现负载均衡、流量路由等功能。客户端并不知道自己连接的对象是代理,常见的应用是 NGINX。
  • 正向代理的对象是客户端,目的是隐藏客户端,客户端知道自己连接的是一个代理,并通过该代理来访问后台服务,常见的应用是 VPN。
特征 正向代理 (Forward Proxy) 反向代理 (Reverse Proxy)
代理对象 客户端 (Client) 服务端 (Server)
隐藏了谁 隐藏了客户端 (服务器不知道谁在访问) 隐藏了服务端 (用户不知道谁在提供服务)
配置端 客户端需要配置 (需要在浏览器/系统填代理IP) 服务端配置 (用户无感知,直接输网址即可)
典型代表 VPN, Shadowsocks, 公司网关 Nginx, HAProxy, Cloudflare
一句话 我(客户端)找个中介去访问世界。 世界(客户端)通过中介来访问我(服务端)。

英文

项目难点

During my tenure, I was in charge of many projects, among which the most challenging for me was the first project. Because I ran into memory leaks and concurrency issues. For the first question, by using performance analysis tools and consulting related materials, I learned that the underlying memory allocation strategy caused the memory leak problem, so I adjusted the strategy and solved the problem smoothly. The second question, I implemented CAS by combining redis and lua scripts, and cooperated with the retry mechanism to ensure that the data written in is in line with expectations.

为什么加入

I’d like to join because both citrix and i share the same values, also, i think this position merges my interests with my skill set, so i can contribute to Citrix

未来展望

i look forward to continuing to develop my skills and carees. Citrix excite me and i hope that in five years I’ll still be here continuig to hone my skills

为什么离职

For the long-term planning, I hope to return to Nanjing for development and settle down with my girlfriend

如何应对工作中的压力

i work well under pressure. when i’m under pressure, rather than panic. the first thing i do is prioritize the most important things that need to be done first. then i tackle each task one by one

优点

i have strong work ethic and it makes me do better