mirror of
https://gitee.com/wangbin579/cetus.git
synced 2024-11-29 18:37:36 +08:00
Optimize connection create processing
This commit is contained in:
parent
3d8c649573
commit
d1c7db612b
@ -64,7 +64,7 @@ typedef struct chassis chassis;
|
||||
#define MAX_QUERY_TIME 65536
|
||||
#define MAX_WAIT_TIME 1024
|
||||
#define MAX_TRY_NUM 6
|
||||
#define MAX_CREATE_CONN_NUM 64
|
||||
#define MAX_CREATE_CONN_NUM 256
|
||||
#define MAX_DIST_TRAN_PREFIX 64
|
||||
#define DEFAULT_LIVE_TIME 7200
|
||||
|
||||
@ -187,6 +187,7 @@ struct chassis {
|
||||
int max_header_size;
|
||||
int compressed_merged_output_size;
|
||||
int asynchronous_type;
|
||||
int connections_created_per_time;
|
||||
|
||||
/* Conn-pool initialize settings */
|
||||
int max_idle_connections;
|
||||
|
@ -704,6 +704,13 @@ init_parameters(struct chassis_frontend_t *frontend, chassis *srv)
|
||||
srv->mid_idle_connections = frontend->default_pool_size;
|
||||
g_message("set default pool size:%d", srv->mid_idle_connections);
|
||||
|
||||
int connections_created_per_time = srv->mid_idle_connections / srv->worker_processes;
|
||||
if (connections_created_per_time > MAX_CREATE_CONN_NUM) {
|
||||
srv->connections_created_per_time = MAX_CREATE_CONN_NUM;
|
||||
} else {
|
||||
srv->connections_created_per_time = connections_created_per_time;
|
||||
}
|
||||
|
||||
if (frontend->max_pool_size >= srv->mid_idle_connections) {
|
||||
srv->max_idle_connections = frontend->max_pool_size;
|
||||
} else {
|
||||
|
@ -5760,8 +5760,12 @@ network_connection_pool_create_conns(chassis *srv)
|
||||
|
||||
allowd_conn_num = allowd_conn_num - total;
|
||||
|
||||
if (allowd_conn_num > MAX_CREATE_CONN_NUM) {
|
||||
allowd_conn_num = MAX_CREATE_CONN_NUM;
|
||||
if (allowd_conn_num > srv->connections_created_per_time) {
|
||||
allowd_conn_num = srv->connections_created_per_time;
|
||||
}
|
||||
|
||||
if (allowd_conn_num > 0) {
|
||||
srv->is_need_to_create_conns = 1;
|
||||
}
|
||||
|
||||
for (j = 0; j < allowd_conn_num; j++) {
|
||||
@ -5901,8 +5905,8 @@ check_and_create_conns_func(int fd, short what, void *arg)
|
||||
|
||||
if (!chas->maintain_close_mode) {
|
||||
if (chas->is_need_to_create_conns) {
|
||||
network_connection_pool_create_conns(chas);
|
||||
chas->is_need_to_create_conns = 0;
|
||||
network_connection_pool_create_conns(chas);
|
||||
} else {
|
||||
if (chas->complement_conn_flag) {
|
||||
network_connection_pool_create_conns(chas);
|
||||
@ -5940,7 +5944,7 @@ check_and_create_conns_func(int fd, short what, void *arg)
|
||||
}
|
||||
#endif
|
||||
g_debug("%s: check_and_create_conns_func", G_STRLOC);
|
||||
struct timeval check_interval = {30, 0};
|
||||
struct timeval check_interval = {10, 0};
|
||||
chassis_event_add_with_timeout(chas, &chas->auto_create_conns_event, &check_interval);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user