mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 10:35:40 +08:00
Grace delay feature added
`proxy -g8000,3,10` First parameter is average read size we want to keep, second parameter is minimal number of packets in the same direction to apply algorythm, last value is delay added after polling and prior to reading data. An example above adds 10 millisecond delay before reading data if average polling size is below 8000 bytes and 3 read operations are made in the same direction. It's specially usefule with splice. `logdump 1 1` is useful to see how grace delays work, choose delay value to avoid filling the read pipe/buffer (typically 64K) but keep the request sizes close to chosen average on large file upload/download.
This commit is contained in:
parent
8a8622b30f
commit
55d1bbe155
@ -285,3 +285,16 @@ requirements.
|
|||||||
system bus are bottlenecks.
|
system bus are bottlenecks.
|
||||||
<p>TCP_NODELAY and splice are not contrary to each over and should be combined on
|
<p>TCP_NODELAY and splice are not contrary to each over and should be combined on
|
||||||
high-speed connections.
|
high-speed connections.
|
||||||
|
|
||||||
|
<h4>Add grace delay to reduce system calls<h4>
|
||||||
|
|
||||||
|
<pre>proxy -g8000,3,10</pre>
|
||||||
|
First parameter is average read size we want to keep, second parameter is
|
||||||
|
minimal number of packets in the same direction to apply algorythm,
|
||||||
|
last value is delay added after polling and prior to reading data.
|
||||||
|
An example above adds 10 millisecond delay before reading data if average
|
||||||
|
polling size is below 8000 bytes and 3 read operations are made in the same
|
||||||
|
direction. It's specially usefule with splice. <pre>logdump 1 1</pre> is useful
|
||||||
|
to see how grace delays work, choose delay value to avoid filling the read
|
||||||
|
pipe/buffer (typically 64K) but keep the request sizes close to chosen average
|
||||||
|
on large file upload/download.
|
||||||
|
@ -110,6 +110,8 @@ disable NTLM authentication (required if passwords are stored in Unix crypt form
|
|||||||
.B -n1
|
.B -n1
|
||||||
enable NTLMv1 authentication.
|
enable NTLMv1 authentication.
|
||||||
.br
|
.br
|
||||||
|
.B -g(GRACE_TRAFF,GRACE_NUM,GRACE_DELAY)
|
||||||
|
delay GRACE_DELAY milliseconds before polling if average polling size below GRACE_TRAFF bytes and GRACE_NUM read operations in single directions are detected within 1 second. Useful to minimize polling
|
||||||
.B -s
|
.B -s
|
||||||
(for admin) secure, allow only secure operations, currently only traffic counters
|
(for admin) secure, allow only secure operations, currently only traffic counters
|
||||||
view without ability to reset.
|
view without ability to reset.
|
||||||
|
@ -103,6 +103,7 @@ struct extparam conf = {
|
|||||||
0,
|
0,
|
||||||
0, -1, 0, 0, 0, 0,
|
0, -1, 0, 0, 0, 0,
|
||||||
0, 500, 0, 0, 0, 0, 0, 2,
|
0, 500, 0, 0, 0, 0, 0, 2,
|
||||||
|
0, 0, 0,
|
||||||
6, 600,
|
6, 600,
|
||||||
1048576,
|
1048576,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
|
@ -131,7 +131,7 @@ char * proxy_stringtable[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LINESIZE 4096
|
#define LINESIZE 32768
|
||||||
#define BUFSIZE (LINESIZE*2)
|
#define BUFSIZE (LINESIZE*2)
|
||||||
#define FTPBUFSIZE 1536
|
#define FTPBUFSIZE 1536
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#define MAXNSERVERS 5
|
#define MAXNSERVERS 5
|
||||||
|
|
||||||
#define UDPBUFSIZE 16384
|
#define UDPBUFSIZE 16384
|
||||||
#define TCPBUFSIZE 8192
|
#define TCPBUFSIZE 65536
|
||||||
#define SRVBUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE))
|
#define SRVBUFSIZE (param->srv->bufsize?param->srv->bufsize:((param->service == S_UDPPM)?UDPBUFSIZE:TCPBUFSIZE))
|
||||||
|
|
||||||
|
|
||||||
|
@ -223,6 +223,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#ifdef WITHSLICE
|
#ifdef WITHSLICE
|
||||||
" -s Use slice() - faster proxing, but no filtering for data\n"
|
" -s Use slice() - faster proxing, but no filtering for data\n"
|
||||||
#endif
|
#endif
|
||||||
|
"-g(GRACE_TRAFF,GRACE_NUM,GRACE_DELAY) - delay GRACE_DELAY milliseconds before polling if average polling size below GRACE_TRAFF bytes and GRACE_NUM read operations in single directions are detected within 1 second to minimize polling\n"
|
||||||
" -fFORMAT logging format (see documentation)\n"
|
" -fFORMAT logging format (see documentation)\n"
|
||||||
" -l log to stderr\n"
|
" -l log to stderr\n"
|
||||||
" -lFILENAME log to FILENAME\n"
|
" -lFILENAME log to FILENAME\n"
|
||||||
@ -428,6 +429,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
case 'a':
|
case 'a':
|
||||||
srv.anonymous = 1 + atoi(argv[i]+2);
|
srv.anonymous = 1 + atoi(argv[i]+2);
|
||||||
break;
|
break;
|
||||||
|
case 'g':
|
||||||
|
sscanf(argv[i]+2, "%d,%d,%d", &srv.gracetraf, &srv.gracenum, &srv.gracedelay);
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
if(isudp || srv.service == S_ADMIN)
|
if(isudp || srv.service == S_ADMIN)
|
||||||
|
@ -60,6 +60,7 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
|
|||||||
int res;
|
int res;
|
||||||
SASIZETYPE sasize;
|
SASIZETYPE sasize;
|
||||||
int needaction = 0;
|
int needaction = 0;
|
||||||
|
int graceclinum=0, gracesrvnum=0, graceclitraf=0, gracesrvtraf=0, gracetime=0;
|
||||||
|
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
uint64_t inclientpipe = 0, inserverpipe = 0;
|
uint64_t inclientpipe = 0, inserverpipe = 0;
|
||||||
@ -158,6 +159,18 @@ sprintf(logbuf, "int FROMCLIENT = %d, TOCLIENTBUF = %d, FROMCLIENTBUF = %d, TOSE
|
|||||||
log(logbuf);
|
log(logbuf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(needaction && param->srv->gracedelay && !sleeptime){
|
||||||
|
if(gracetime != conf.time){
|
||||||
|
gracetime = conf.time;
|
||||||
|
graceclinum=gracesrvnum=graceclitraf=gracesrvtraf=0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if( (graceclinum && graceclitraf && graceclinum>=param->srv->gracenum && (!param->srv->gracetraf || graceclitraf/graceclinum <= param->srv->gracetraf)) ||
|
||||||
|
(gracesrvnum && gracesrvtraf && gracesrvnum>=param->srv->gracenum && (!param->srv->gracetraf || gracesrvtraf/gracesrvnum <= param->srv->gracetraf))) {
|
||||||
|
sleeptime = param->srv->gracedelay;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if(needaction > 2 && !sleeptime){
|
if(needaction > 2 && !sleeptime){
|
||||||
if(needaction > (MAXFAILATTEMPT+1)){RETURN (93);}
|
if(needaction > (MAXFAILATTEMPT+1)){RETURN (93);}
|
||||||
sleeptime = (1<<(needaction-2));
|
sleeptime = (1<<(needaction-2));
|
||||||
@ -354,6 +367,9 @@ log(logbuf);
|
|||||||
#ifdef WITHLOG
|
#ifdef WITHLOG
|
||||||
log("done read from client to pipe");
|
log("done read from client to pipe");
|
||||||
#endif
|
#endif
|
||||||
|
graceclinum++;
|
||||||
|
graceclitraf += res;
|
||||||
|
gracesrvnum = gracesrvtraf = 0;
|
||||||
inclientpipe += res;
|
inclientpipe += res;
|
||||||
if(inclientpipe >= MAXSPLICE) TOCLIENTPIPE = 0;
|
if(inclientpipe >= MAXSPLICE) TOCLIENTPIPE = 0;
|
||||||
needaction = 0;
|
needaction = 0;
|
||||||
@ -388,6 +404,9 @@ log(logbuf);
|
|||||||
#ifdef WITHLOG
|
#ifdef WITHLOG
|
||||||
log("done read from server to pipe\n");
|
log("done read from server to pipe\n");
|
||||||
#endif
|
#endif
|
||||||
|
gracesrvnum++;
|
||||||
|
gracesrvtraf += res;
|
||||||
|
graceclinum = graceclitraf = 0;
|
||||||
param->nreads++;
|
param->nreads++;
|
||||||
param->statssrv64 += res;
|
param->statssrv64 += res;
|
||||||
inserverpipe += res;
|
inserverpipe += res;
|
||||||
@ -426,6 +445,9 @@ log("read from client to buf");
|
|||||||
#ifdef WITHLOG
|
#ifdef WITHLOG
|
||||||
log("done read from client to buf");
|
log("done read from client to buf");
|
||||||
#endif
|
#endif
|
||||||
|
graceclinum++;
|
||||||
|
graceclitraf += res;
|
||||||
|
gracesrvnum = gracesrvtraf = 0;
|
||||||
inclientbuf += res;
|
inclientbuf += res;
|
||||||
param->cliinbuf += res;
|
param->cliinbuf += res;
|
||||||
if(param->clibufsize == param->cliinbuf) TOCLIENTBUF = 0;
|
if(param->clibufsize == param->cliinbuf) TOCLIENTBUF = 0;
|
||||||
@ -451,6 +473,9 @@ log("read from server to buf");
|
|||||||
#ifdef WITHLOG
|
#ifdef WITHLOG
|
||||||
log("done read from server to buf");
|
log("done read from server to buf");
|
||||||
#endif
|
#endif
|
||||||
|
gracesrvnum++;
|
||||||
|
gracesrvtraf += res;
|
||||||
|
graceclinum = graceclitraf = 0;
|
||||||
param->nreads++;
|
param->nreads++;
|
||||||
param->statssrv64 += res;
|
param->statssrv64 += res;
|
||||||
inserverbuf += res;
|
inserverbuf += res;
|
||||||
|
@ -437,6 +437,7 @@ struct srvparam {
|
|||||||
int noforce;
|
int noforce;
|
||||||
int anonymous;
|
int anonymous;
|
||||||
int clisockopts, srvsockopts, lissockopts, cbcsockopts, cbssockopts;
|
int clisockopts, srvsockopts, lissockopts, cbcsockopts, cbssockopts;
|
||||||
|
int gracetraf, gracenum, gracedelay;
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
int usesplice;
|
int usesplice;
|
||||||
#endif
|
#endif
|
||||||
@ -576,6 +577,7 @@ struct extparam {
|
|||||||
demon, maxchild, needreload, timetoexit, version, noforce, bandlimver, parentretries;
|
demon, maxchild, needreload, timetoexit, version, noforce, bandlimver, parentretries;
|
||||||
int authcachetype, authcachetime;
|
int authcachetype, authcachetime;
|
||||||
int filtermaxsize;
|
int filtermaxsize;
|
||||||
|
int gracetraf, gracenum, gracedelay;
|
||||||
unsigned char *logname, **archiver;
|
unsigned char *logname, **archiver;
|
||||||
ROTATION logtype, countertype;
|
ROTATION logtype, countertype;
|
||||||
char * counterfile;
|
char * counterfile;
|
||||||
|
Loading…
Reference in New Issue
Block a user