server: delay startup upon overload

This commit is contained in:
Thomas Schoebel-Theuer 2023-12-05 15:23:11 +01:00
parent a0dec08f8e
commit ef0b97efd4
3 changed files with 23 additions and 0 deletions

View File

@ -94,6 +94,7 @@ int dent_limit = DENT_LIMIT;
int dent_retry = DENT_RETRY;
atomic_t running_dent = ATOMIC_INIT(0);
int server_start_delay_ms = 1000;
static
int cb_thread(void *data)
@ -1087,6 +1088,20 @@ void check_bricks(void)
up_write(&server_mutex);
}
static
void _limit_handler_rate(struct server_cookie *cookie)
{
int below =
nr_affected_resources * max_client_channels * 2;
int rate =
atomic_read(&server_handler_count) - below;
if (rate <= 0)
return;
rate *= server_start_delay_ms;
brick_msleep(rate);
}
static int port_thread(void *data)
{
struct mars_global *server_global = alloc_mars_global();
@ -1154,6 +1169,9 @@ static int port_thread(void *data)
MARS_DBG("got new connection #%d\n", handler_socket.s_debug_nr);
if (cookie->port_nr > MARS_TRAFFIC_META)
_limit_handler_rate(cookie);
this_handler_limit = handler_limit;
if (cookie->port_nr <= MARS_TRAFFIC_META)
this_handler_limit *= 2;

View File

@ -692,6 +692,7 @@ struct ctl_table mars_table[] = {
INT_ENTRY("client_receiver_count", client_receiver_count, 0400),
INT_ENTRY("server_callback_count", server_callback_count, 0400),
INT_ENTRY("server_handler_count", server_handler_count, 0400),
INT_ENTRY("server_start_delay_ms", server_start_delay_ms, 0400),
INT_ENTRY("mars_emergency_mode", mars_emergency_mode, 0600),
INT_ENTRY("mars_reset_emergency", mars_reset_emergency, 0600),
INT_ENTRY("mars_keep_msg_s", mars_keep_msg, 0600),

View File

@ -51,6 +51,10 @@ extern int usable_strategy_version;
extern int usable_marsadm_version_major;
extern int usable_marsadm_version_minor;
extern int nr_affected_resources;
extern int max_client_channels;
extern int server_start_delay_ms;
extern int mars_min_update;
extern loff_t global_total_space;