Skip to content

Instantly share code, notes, and snippets.

View kingluo's full-sized avatar

jinhua luo kingluo

View GitHub Profile
@kingluo
kingluo / grpc-status.md
Last active November 10, 2023 01:53
Everything about APISIX GRPC functionalities
@kingluo
kingluo / a.md
Last active August 18, 2023 11:32
How to trace nginx blocking issue via systemtap?

Test

# run openresty
/usr/local/openresty/nginx/sbin/nginx -p $PWD -c nginx.conf -g "daemon off;"

# run systemtap script
./samples/blocking-bt.sxx -D STP_NO_OVERLOAD --arg time=60 --skip-badvars -x 144081

# trigger the workload
@kingluo
kingluo / processes.erl
Last active July 7, 2023 08:19
erlang noshell
$ erlc processes.erl
$ erl -noshell -s processes test -s init stop
the max processes is 262144
the proecess time is 2.0:3.57
$ erl -noshell -s processes test2 100000 -s init stop
the max processes is 262144
{"init terminating in do_boot",{system_limit,[{erlang,spawn,[erlang,apply,[#Fun<processes.2.26012808>,[]]],[]},{erlang,spawn,1,[]},{processes,for,3,[{file,"processes.erl"},{line,24}]},{processes,for,3,[{file,"processes.erl"},{line,24}]},{processes,max,1,[{file,"processes.erl"},{line,10}]},{init,start_it,1,[]},{init,start_em,1,[]}]}}
# program freeze here...
# Ctrl+C not work
@kingluo
kingluo / doc.md
Last active April 9, 2023 15:12
APISIX limit-req plugin test

rate limit policy

  • [,rate]: pass
  • (rate, burst]: sleep
  • (burst,): reject

Test

Configure a fake upstream as APISIX itself, and calculate the actual success rate via serverless plugin.

@kingluo
kingluo / go.mod
Last active March 9, 2023 18:01
go-ldap GSSAPI
module github.com/kingluo/foobar
go 1.19
require (
github.com/go-ldap/ldap/v3 v3.4.5-0.20230226130424-b64a808c288f
gopkg.in/jcmturner/gokrb5.v7 v7.5.0
)
require (
@kingluo
kingluo / implement-grpc-client-in-rust-for-openresty.md
Last active November 27, 2022 06:26
Implement grpc client in rust language for openresty/nginx

gems

Back in 2019, when I work as individual postgresql/nginx consultant. Many clients ask me if they could do hybrid programming in nginx.

They said, nginx/openresty is powerful and high performance, but the most significant drawback is it lacks of ecosystem of mainstream programming languages, especially when they have to interact with popular frameworks, e.g. kafka, consul, k8s, etc. The C/Lua ecosystem is slim, even if they bite the bullet and write down C/Lua modules, they face the awkward fact that most frameworks do not provide C/Lua API.

@kingluo
kingluo / leak.go
Last active October 14, 2022 06:20
package main
import (
"fmt"
"log"
"math/rand"
"net/http"
"strings"
"time"
)
package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"math/rand"
"net/http"
"strings"
ipset_name="myset"
hosts=("httpbin.org")
interval=3 #secs
while true; do
new_iplist=()
for host in ${hosts[@]}; do
for ip in $(dig +noall +answer +multiline $host | awk '{print $NF}' | sort); do
new_iplist+=($ip)
done