測(cè)試環(huán)境 騰訊云CVM centos7.5 4核 8G X 4臺(tái)
1臺(tái)機(jī)器搭建webman,無(wú)邏輯業(yè)務(wù) 直接輸出1KB字符
3臺(tái)機(jī)器使用k6做壓力測(cè)試客戶端, 3臺(tái)機(jī)器同時(shí)發(fā)送命令,每臺(tái)機(jī)器模擬10000人 運(yùn)行100秒
使用內(nèi)網(wǎng)ip http方式測(cè)試
直接訪問(wèn)webman 每臺(tái)機(jī)器,每秒能處理3w左右個(gè)請(qǐng)求,全部請(qǐng)求成功
使用nginx+webman 每臺(tái)機(jī)器,每秒能處理7k左右個(gè)請(qǐng)求,還會(huì)有失敗的請(qǐng)求
性能下降了5倍左右.
webman
nginx+webman
打算把現(xiàn)有的純api業(yè)務(wù)換成webman來(lái)做,有沒(méi)有其他高效方案配合webman一起使用
nginx配置有問(wèn)題吧,貼下配置
server
{
listen 80 default_server;
server_name proxy.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/proxy.com;
#SSL-START SSL related configuration, do NOT delete or modify the next line of commented-out 404 rules
#error_page 404/404.html;
#SSL-END
#ERROR-PAGE-START Error page configuration, allowed to be commented, deleted or modified
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START PHP reference configuration, allowed to be commented, deleted or modified
#Clear cache
location ~ /purge(/.*) {
proxy_cache_purge cache_one $host$1$is_args$args;
#access_log /www/wwwlogs/proxy.com_purge_cache.log;
}
location ^~ /
{
proxy_pass http://127.0.0.1:8787;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
#Persistent connection related configuration
add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
set $static_file6WUdp7fS 0;
if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
{
set $static_file6WUdp7fS 1;
expires 12h;
}
if ( $static_file6WUdp7fS = 0 )
{
add_header Cache-Control no-cache;
}
}
# Forbidden files or directories
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
# Directory verification related settings for one-click application for SSL certificate
location ~ \.well-known{
allow all;
}
#access_log /www/wwwlogs/proxy.com.log;
#error_log /www/wwwlogs/proxy.com.error.log;
}
按照手冊(cè)配置試下,
upstream webman {
server 127.0.0.1:8787;
keepalive 10240;
}
server {
server_name 站點(diǎn)域名;
listen 80;
access_log off;
root /your/webman/public;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Connection "";
if (!-f $request_filename){
proxy_pass http://webman;
}
}
}
最主要的是 keepalive 10240;
這個(gè)配置,也可以順便把nginx日志關(guān)閉