Each machine node runs such an server instance, which operates kunlun storage nodes(SN) and/or computing nodes(CN) that run on the computer server, in response to requests initiated by computing nodes and/or cluster_mgr module to start/stop/create/drop/backup/restore a CN/SN.
Apache License 2.0
3
stars
1
forks
source link
Traffic limitation in transfering data between different node_mgrs #7
2022-03-11 14:55:55: snow@zettadb.com created the issue
Data transfer between different node_mgrs is the fundementally function.To achive the gole of using physical resource precisly,we implemented the Traffic limitaion mechanism.\
== How To\
BRPC( HTTP ProgressiveAttachment )is used as the chassis of the network framework, the mechanism we implementd is base on it.\
=== Server side
We created a File service which residens in the BRPC server which means the file-service listen the same unique Port. \
The file data which is required by client is sent by chunked stream after the HTTP header is recived by the client. That means the client side need revcive data stream continually until End-Of-Data is detected.
==== principle of the traffic control
The standard of estimating the network traffic is widly accepted in Second Level, so we control the number of sent bytes in second interval.\
pseudocode is described below:\
Traffic control:
{{{#!c++
for (;;) {
ret = read(fd, buff, SEND_BUFFER_SIZE(1024B));
if (ret < 0) {
Error break;
} else if (ret == 0) {
Finish break;
} else {
for (;;) {
if (timer.timeout(n microsecond)) {
// do check
inner_check_counter++;
if (inner_check_counter >= (1000000 / n)) {
// traffic control under seconde level
inner_check_counter = 0;
bytes_send_counter = 0;
}
if (bytes_send_counter >= bytes_per_sec) {
// stop and wait in the rest of the one seconde long
sleep(((1000000 /n) - inner_check_counter) * n);
inner_check_counter = 0;
bytes_send_counter = 0;
continue;
}
}
Write(buff, ret) < 0) ;
bytes_send_counter += ret;
finish break;
}
}
}
}}}
=== Client side
We implementd a new tool residens in the util folders called download_file,which tell server the speed to send data.\
the parameters is listed below:\
{{{#!c++
-out_filename (Downloaded File name) type: string default: ""
-out_prefix (Downloaded File path prefix) type: string default: ""
-output_override (Whether override the output file if destination has the
same name or not) type: bool default: false
-traffic_limit (Download traffic limit, default is 5242880(5 MB))
type: int64 default: 5242880
-url (URL of the request reource) type: string default: ""
}}}
Here is how the traffic control performing.\
node_mgr1 want to the file F1 residens on the node_mgr2. \
node_mgr1 use download_file tool to download file F1 from node_mgr2 and specify the speed by traffic_limit para.\
node_mgr2 send file F1 in the speed of traffic_limit. \
2022-03-11 16:16:51: snow@zettadb.com changed title from Traffic limit in transfering data between different node_mgrs to Traffic limitation in transfering data between different node_mgrs
Issue migrated from trac ticket # 497 www.kunlunbase.com
component: node manager | priority: major
2022-03-11 14:55:55: snow@zettadb.com created the issue