Skip to content

Instantly share code, notes, and snippets.

@qiaoliu78
Last active November 20, 2020 05:08
Show Gist options
  • Save qiaoliu78/75e7710a02c3346d22ddda04cea83b97 to your computer and use it in GitHub Desktop.
Save qiaoliu78/75e7710a02c3346d22ddda04cea83b97 to your computer and use it in GitHub Desktop.
nginx.conf
user nobody;
daemon on;
worker_processes 112;
#worker_cpu_affinity auto;
error_log error.log;
events {
worker_connections 65535;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
access_log off;
aio threads;
aio_write on;
read_ahead 0;
tcp_nopush on;
tcp_nodelay off;
sendfile on;
# directio 512k;
# directio_alignment 512;
# Cache Configurations
proxy_cache_path /mnt/cache0 levels=2 keys_zone=nginx-cache0:400m max_size=1400g inactive=4d use_temp_path=off;
proxy_cache_path /mnt/cache1 levels=2 keys_zone=nginx-cache1:400m max_size=1400g inactive=4d use_temp_path=off;
proxy_cache_path /mnt/cache2 levels=2 keys_zone=nginx-cache2:400m max_size=1400g inactive=4d use_temp_path=off;
proxy_cache_path /mnt/cache3 levels=2 keys_zone=nginx-cache3:400m max_size=1400g inactive=4d use_temp_path=off;
# Map drives
split_clients $request_uri $ng_cache {
25% "nginx-cache0";
25% "nginx-cache1";
25% "nginx-cache2";
25% "nginx-cache3";
}
upstream backends {
server localhost:18080;
keepalive 4;
}
server {
listen 8080 reuseport;
listen [::]:8080 reuseport;
listen 8443 ssl reuseport;
listen [::]:8443 ssl reuseport;
server_name _;
keepalive_timeout 600s;
ssl_verify_client off;
ssl_session_tickets off;
access_log off;
lingering_close off;
lingering_time 1;
ssl_certificate /home/cdn/certs/server.cert.pem;
ssl_certificate_key /home/cdn/certs/server.key.pem;
ssl_session_timeout 300s;
ssl_protocols TLSv1.2;
# ssl_ciphers AES128-SHA:AES256-SHA;
ssl_ciphers ECDH+AESGCM:ECDH+CHACHA20:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS:!AESCCM;
ssl_prefer_server_ciphers on;
ssl_buffer_size 64k;
location / {
expires 30d;
add_header Pragma public;
add_header Cache-Control "public";
proxy_cache $ng_cache;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://backends;
}
}
}
-- example script that adds a query string
local threadcounter = 1
local threads = {}
function setup(thread)
thread:set("id", threadcounter)
table.insert(threads, thread)
threadcounter = threadcounter + 1
end
function init(args)
-- math.randomseed(os.time()*id)
math.randomseed(0xdeadfeed * id)
end
function delay()
-- return 1000
return 0
end
function fdelay()
local r = math.random(0, 50)
-- print ("fdelay = " .. r)
return r
end
request = function()
-- local param_value = math.random(800000)
local param_value = math.random(100000)
-- added by nk to support multipleclients
local hostname = os.getenv("HOSTNAME")
path = "/_32kobject?version=" .. hostname .. param_value .. "&thread=" .. id
-- path = "/_1mobject?version=" .. hostname .. param_value .. "&thread=" .. id
-- print ("time: " .. os.time() .. " -- thread" .. id .. ":" .. path)
return wrk.format("GET", path)
end
#!/bin/bash
ulimit -n 65535
http_proxy= https_proxy= ./wrk \
-t 112 \
-c 10000 \
-d 600s \
-s scripts/query.lua \
-L \
--timeout 10s \
${1:-http://192.168.1.200:8080}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment