What I'm Doing
Understand isolation level
28 April 2019
Isolation is the I
in ACID, one of the 4 famous properties in database transaction.
Isolation level play a critial role in concurrent scenarios. Higher isolation level offers better gurantee of data consistency, however worse performance in concurrency.
... Read More
Golang compiler optimization when covert bool to int
25 August 2017
In golang, you can’t directly compare bool value and int value, and you can’t print bool value as digit 1 or 0 using fmt.Printf(). the best way is to convert bool variable to int.
How to do that? A most common way is to write a conversion function like this one.
... Read More
[code analysis] Nginx zero downtime upgrade
23 January 2017
Nginx can gracefully upgrade without shutdown the existing server. Detail upgrade process can be found at the nginx document
In short,
- Build a new nginx binary, move it to
/usr/local/nginx/sbin/nginx
- Send a USR2 signal to existing nginx process, the this process will execute new binary, the new binary will accept requests with the old one simultaneously.
- If nothing wrong, send WINCH(optional) and QUIT signal to stop old process.
Brief Note of Docker
27 August 2015
Installation
On linux, follow the installation guide
On OSX, install boot2docker(deprecated) or Docker Toolbox which is recommended on docker official document.
... Read More
Route All Network Traffic Through VPN
11 August 2015
By default, openvpn traffic only local network traffic through vpn. We can config openvpn client to route all ipv4 traffic through vpn, such as the advanced option in tunnelblick
. However, some other vpn clients like zerotier, whose client is not sound enough, thus we have to route these traffic manually.
Rename Directory Which Contains Submodules
28 July 2015
When rename a directory which contains submodule using command git mv old new
, and then check status with git status
, an error will occur like
fatal: Could not chdir to ‘../../../../../lib/hiredis’: No such file or directory fatal: ‘git status –porcelain’ failed in submodule lib/hiredis
because git won’t rename the path of submodule in the configuration files automatically. Thus we must edit these configs manually.
... Read More
Various OpenVPN Clients Configuration
20 July 2015
preparation
*.crt
Client certificate
*.key
Client private key
*.takey
OpenVPN TLS auth key
ca.crt
CA root certificate
Server ip & port
Encryption Cipher Method, AES-256-CBC
etc.
Hash Algorithm, default SHA1
Roman Numberal and Cpp Implementation
15 July 2015
One of the leecode problem quotes Roman Numberal. Out of curiosity, I query some document about Roman Numberal, wikipedia and Roman Numerals Chart
... Read MorePreparation
The installation is based on a debian jessie (server) with two network interface. eth0(192.168.100.2) connects to internet, eth1(10.10.10.2) for intranet configured for with fai server.
dhcp server
Firstly, configure fai server with a static ip, edit /etc/network/interfaces
Nginx+Uwsgi Integration
9 July 2015
To improve the performance of python website under nginx, it’s better to use tcp connection rather than proxy_pass with http protocol.
nginx conf
edit /etc/nginx/site-enabled/default
or add a new file in site-enabled folder
server{
listen 80;
server_name abc.com
location /api {
uwsgi_pass 127.0.0.1:3015;
include uwsgi_params;
access_log /var/log/api.log;
}
}
... Read More