Skip to content

Instantly share code, notes, and snippets.

View vqiu's full-sized avatar
🌴
On vacation

shuhui.qiu vqiu

🌴
On vacation
View GitHub Profile
@vqiu
vqiu / tuning-postgres-zfs.md
Created September 5, 2022 12:47 — forked from saurabhnanda/tuning-postgres-zfs.md
Tuning Postgres + ZFS

Tuning ZFS + Postgres to outperform EXT4 + Postgres

Please refer to ZFS 2-3x slower than EXT4 to see how ZFS defaults + Postgres defaults severely underperform EXT4 defaults + Postgres defaults (and also to know more about the system on which these benchmarks were performed). This page documents how to tune ZFS + Postgres to give better performance for the tpcb-like benchmark.

BIG FAT WARNING

Please do not copy these settings blindly because I am myself not clear on why/how these settings had the impact they did. For example, I cannot explain why full_page_writes=off independently did not give that much boost, nor did an optimized PG configuration. However, putting both of them together gave a 2-4x boost compared to baseline numbers.

Benchmark results

@vqiu
vqiu / rdate.md
Created January 12, 2018 10:15
使用 rdate 替代ntp 功能

总有那么些蛋疼的机房,为了所谓的这安全,将NTP 服务器一刀切了。这时候时间同步就是一个问题,不过我们还可以使用 rdate 来解决。

yum -y install rdate
rdate -s time.nist.gov

cat > /etc/cron.daily/rdate << "EOF"
#!/bin/sh
rdate -s time.nist.gov
@vqiu
vqiu / tc_qos
Last active December 3, 2020 07:51 — forked from swshan/tc
openwrt tc
#!/usr/bin/env bash
# IDEV 内网接口,ODEV外网接口)
IDEV="eth0"
ODEV="eth1"
# 定义总的上下带宽
UP="8mbit"
DOWN="100mbit"
@vqiu
vqiu / nginx.tmpl
Created June 24, 2018 18:14 — forked from tzumby/nginx.tmpl
{{ $cfg := .Cfg }}
{{ $IsIPV6Enabled := .IsIPV6Enabled }}
{{ $healthzURI := .HealthzURI }}
{{ $backends := .Backends }}
{{ $proxyHeaders := .ProxySetHeaders }}
daemon off;
worker_processes {{ $cfg.WorkerProcesses }};
pid /run/nginx.pid;
{{ if ne .MaxOpenFiles 0 }}
worker_processes 2;
error_log /var/log/nginx/error.log info;
events {
worker_connections 1024;
}
http {
init_by_lua '
function split(inputstr, sep)
@vqiu
vqiu / nginx.conf
Created October 23, 2019 07:43 — forked from senderista/nginx.conf
Token bucket with upstream stats
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
lua_shared_dict token_bucket 10M;
lua_shared_dict stats 5M;
init_by_lua '
local redis_c = require "resty.redis"
local ok, new_tab = pcall(require, "table.new")
if not ok or type(new_tab) ~= "function" then
new_tab = function (narr, nrec) return {} end
end
local _M = new_tab(0, 155)
@vqiu
vqiu / named.conf
Created January 11, 2019 03:56 — forked from cpswan/named.conf
Unbound/BIND config for DNS over TLS to 1.1.1.1
options {
directory "/tmp";
listen-on-v6 { none; };
forwarders {
127.0.0.1 port 2053;
};
auth-nxdomain no; # conform to RFC1035
@vqiu
vqiu / proxy.pac
Last active November 10, 2018 19:24 — forked from alphatr/proxy.pac
PAC
function FindProxyForURL(url, host) {
var proxy = "SOCKS5 127.0.0.1:1080; SOCKS 127.0.0.1:1080; DIRECT";
var black = "PROXY 127.0.0.1:65535";
var direct = "DIRECT";
var PROXY_LIST = [
"instagram.com",
"google.com",
"facebook.com",
@vqiu
vqiu / Knocky.lua
Created October 28, 2018 13:04 — forked from agix/Knocky.lua
Nginx + redis + lua + authy script to allow access by IP with one touch
-- apt-get install nginx-extras # to get nginx with lua support
-- apt-get install luarocks
-- apt-get install lua-nginx-redis
-- luarocks install lua-requests
-- In your nginx config file add two lua dict outside server definition
--
-- lua_shared_dict ip_whitelist 1m;
-- lua_shared_dict ip_asklist 1m;
-- server {
--