mirror of https://github.com/yandex/odyssey.git
odissey: add cache and cache_chunk configuration options
This commit is contained in:
parent
4ec923ce8b
commit
9f505cb2c7
|
@ -37,6 +37,8 @@ nodelay yes
|
|||
keepalive 7200
|
||||
readahead 8192
|
||||
client_max 100
|
||||
cache 100
|
||||
cache_chunk 16384
|
||||
workers 1
|
||||
|
||||
listen {
|
||||
|
@ -91,7 +93,7 @@ database default {
|
|||
pool "transaction"
|
||||
pool_size 0
|
||||
pool_timeout 0
|
||||
pool_ttl 30
|
||||
pool_ttl 50
|
||||
pool_cancel yes
|
||||
pool_rollback yes
|
||||
|
||||
|
|
|
@ -21,7 +21,9 @@ readahead 4096
|
|||
nodelay yes
|
||||
keepalive 7200
|
||||
client_max 100
|
||||
workers 4
|
||||
cache 100
|
||||
cache_chunk 16384
|
||||
workers 1
|
||||
|
||||
listen {
|
||||
host "*"
|
||||
|
@ -72,7 +74,7 @@ database default
|
|||
pool "transaction"
|
||||
pool_size 100
|
||||
pool_timeout 4000
|
||||
pool_ttl 5
|
||||
pool_ttl 60
|
||||
pool_cancel yes
|
||||
pool_rollback yes
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@ enum
|
|||
OD_LKEEPALIVE,
|
||||
OD_LREADAHEAD,
|
||||
OD_LWORKERS,
|
||||
OD_LCACHE,
|
||||
OD_LCACHE_CHUNK,
|
||||
OD_LCLIENT_MAX,
|
||||
OD_LCLIENT_FWD_ERROR,
|
||||
OD_LTLS,
|
||||
|
@ -131,6 +133,8 @@ static od_keyword_t od_config_keywords[] =
|
|||
od_keyword("keepalive", OD_LKEEPALIVE),
|
||||
od_keyword("readahead", OD_LREADAHEAD),
|
||||
od_keyword("workers", OD_LWORKERS),
|
||||
od_keyword("cache", OD_LCACHE),
|
||||
od_keyword("cache_chunk", OD_LCACHE_CHUNK),
|
||||
od_keyword("client_max", OD_LCLIENT_MAX),
|
||||
od_keyword("client_fwd_error", OD_LCLIENT_FWD_ERROR),
|
||||
od_keyword("tls", OD_LTLS),
|
||||
|
@ -916,6 +920,16 @@ od_config_parse(od_config_t *config)
|
|||
if (! od_config_next_number(config, &scheme->workers))
|
||||
return -1;
|
||||
continue;
|
||||
/* cache */
|
||||
case OD_LCACHE:
|
||||
if (! od_config_next_number(config, &scheme->cache))
|
||||
return -1;
|
||||
continue;
|
||||
/* cache_chunk */
|
||||
case OD_LCACHE_CHUNK:
|
||||
if (! od_config_next_number(config, &scheme->cache_chunk))
|
||||
return -1;
|
||||
continue;
|
||||
/* listen */
|
||||
case OD_LLISTEN:
|
||||
rc = od_config_parse_listen(config);
|
||||
|
|
|
@ -458,7 +458,7 @@ static inline int
|
|||
od_frontend_stream_hit_limit(od_client_t *client)
|
||||
{
|
||||
od_instance_t *instance = client->system->instance;
|
||||
return shapito_stream_used(client->stream) >= instance->scheme.cache_limit_size_ra;
|
||||
return shapito_stream_used(client->stream) >= instance->scheme.cache_chunk_ra;
|
||||
}
|
||||
|
||||
static od_frontend_rc_t
|
||||
|
|
|
@ -133,10 +133,8 @@ int od_instance_main(od_instance_t *instance, int argc, char **argv)
|
|||
od_logger_set_stdout(&instance->logger, instance->scheme.log_to_stdout);
|
||||
|
||||
/* set cache limits */
|
||||
shapito_cache_set_limit(&instance->stream_cache, instance->scheme.cache_limit);
|
||||
|
||||
shapito_cache_set_limit_size(&instance->stream_cache,
|
||||
instance->scheme.cache_limit_size);
|
||||
shapito_cache_set_limit(&instance->stream_cache, instance->scheme.cache);
|
||||
shapito_cache_set_limit_size(&instance->stream_cache, instance->scheme.cache_chunk);
|
||||
|
||||
/* run as daemon */
|
||||
if (instance->scheme.daemonize) {
|
||||
|
|
|
@ -46,9 +46,9 @@ void od_scheme_init(od_scheme_t *scheme)
|
|||
scheme->workers = 1;
|
||||
scheme->client_max_set = 0;
|
||||
scheme->client_max = 0;
|
||||
scheme->cache_limit = 100;
|
||||
scheme->cache_limit_size = 10 * 1024;
|
||||
scheme->cache_limit_size_ra = 8 * 1024;
|
||||
scheme->cache = 100;
|
||||
scheme->cache_chunk = 16 * 1024;
|
||||
scheme->cache_chunk_ra = 14 * 1024;
|
||||
od_list_init(&scheme->storages);
|
||||
od_list_init(&scheme->routes);
|
||||
od_list_init(&scheme->listen);
|
||||
|
@ -578,6 +578,12 @@ int od_scheme_validate(od_scheme_t *scheme, od_logger_t *logger)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* set pipeline cache chunk watermark to 90% */
|
||||
if (scheme->cache_chunk > 0)
|
||||
scheme->cache_chunk_ra = scheme->cache_chunk - (scheme->cache_chunk / 10);
|
||||
else
|
||||
scheme->cache_chunk_ra = 0;
|
||||
|
||||
/* log format */
|
||||
if (scheme->log_format == NULL) {
|
||||
od_error(logger, "config", NULL, NULL, "log is not defined");
|
||||
|
@ -858,6 +864,10 @@ void od_scheme_print(od_scheme_t *scheme, od_logger_t *logger, int routes_only)
|
|||
if (scheme->client_max_set)
|
||||
od_log(logger, "config", NULL, NULL,
|
||||
"client_max %d", scheme->client_max);
|
||||
od_log(logger, "config", NULL, NULL,
|
||||
"cache %d", scheme->cache);
|
||||
od_log(logger, "config", NULL, NULL,
|
||||
"cache_chunk %d", scheme->cache_chunk);
|
||||
od_log(logger, "config", NULL, NULL,
|
||||
"workers %d", scheme->workers);
|
||||
od_log(logger, "config", NULL, NULL, "");
|
||||
|
|
|
@ -140,9 +140,9 @@ struct od_scheme
|
|||
int workers;
|
||||
int client_max_set;
|
||||
int client_max;
|
||||
int cache_limit;
|
||||
int cache_limit_size;
|
||||
int cache_limit_size_ra;
|
||||
int cache;
|
||||
int cache_chunk;
|
||||
int cache_chunk_ra;
|
||||
/* temprorary storages */
|
||||
od_list_t storages;
|
||||
/* routes */
|
||||
|
|
Loading…
Reference in New Issue