perf: configurations for perf improvement (#15142)

Closes #15041

Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
He Weiwei 2021-06-15 18:39:15 +08:00 committed by GitHub
parent 4997eea4c6
commit 72f1afe2cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 21 deletions

View File

@ -38,10 +38,10 @@ database:
# The password for the root user of Harbor DB. Change this before any production use. # The password for the root user of Harbor DB. Change this before any production use.
password: root123 password: root123
# The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained. # The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained.
max_idle_conns: 50 max_idle_conns: 100
# The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections. # The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections.
# Note: the default number of connections is 1024 for postgres of harbor. # Note: the default number of connections is 1024 for postgres of harbor.
max_open_conns: 1000 max_open_conns: 900
# The default data volume # The default data volume
data_volume: /data data_volume: /data

View File

@ -6,6 +6,15 @@ revision = '2.3.0'
down_revisions = ['2.2.0'] down_revisions = ['2.2.0']
def migrate(input_cfg, output_cfg): def migrate(input_cfg, output_cfg):
def db_conn_need_update(db_conf):
if not db_conf:
return False
max_idle_conns = db_conf.get('max_idle_conns', 0)
max_open_conns = db_conf.get('max_open_conns', 0)
return max_idle_conns == 50 and max_open_conns == 1000
current_dir = os.path.dirname(__file__) current_dir = os.path.dirname(__file__)
tpl = Environment( tpl = Environment(
loader=FileSystemLoader(current_dir), loader=FileSystemLoader(current_dir),
@ -16,5 +25,9 @@ def migrate(input_cfg, output_cfg):
config_dict = read_conf(input_cfg) config_dict = read_conf(input_cfg)
if db_conn_need_update(config_dict.get('database')):
config_dict['database']['max_idle_conns'] = 100
config_dict['database']['max_open_conns'] = 900
with open(output_cfg, 'w') as f: with open(output_cfg, 'w') as f:
f.write(tpl.render(**config_dict)) f.write(tpl.render(**config_dict))

View File

@ -73,16 +73,16 @@ database:
# The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained. # The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained.
max_idle_conns: {{ database.max_idle_conns }} max_idle_conns: {{ database.max_idle_conns }}
# The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections. # The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections.
# Note: the default number of connections is 100 for postgres. # Note: the default number of connections is 1024 for postgres of harbor.
max_open_conns: {{ database.max_open_conns }} max_open_conns: {{ database.max_open_conns }}
{% else %} {% else %}
# The password for the root user of Harbor DB. Change this before any production use. # The password for the root user of Harbor DB. Change this before any production use.
password: root123 password: root123
# The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained. # The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained.
max_idle_conns: 50 max_idle_conns: 100
# The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections. # The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections.
# Note: the default number of connections is 100 for postgres. # Note: the default number of connections is 1024 for postgres of harbor.
max_open_conns: 100 max_open_conns: 900
{% endif %} {% endif %}
{% if data_volume is defined %} {% if data_volume is defined %}

View File

@ -2,7 +2,7 @@ worker_processes auto;
pid /tmp/nginx.pid; pid /tmp/nginx.pid;
events { events {
worker_connections 1024; worker_connections 3096;
use epoll; use epoll;
multi_accept on; multi_accept on;
} }

View File

@ -2,7 +2,7 @@ worker_processes auto;
pid /tmp/nginx.pid; pid /tmp/nginx.pid;
events { events {
worker_connections 1024; worker_connections 3096;
use epoll; use epoll;
multi_accept on; multi_accept on;
} }

View File

@ -29,6 +29,10 @@ redis:
dialtimeout: 10s dialtimeout: 10s
password: {{redis_password}} password: {{redis_password}}
db: {{redis_db_index_reg}} db: {{redis_db_index_reg}}
pool:
maxidle: 100
maxactive: 500
idletimeout: 60s
http: http:
{% if internal_tls.enabled %} {% if internal_tls.enabled %}
addr: :5443 addr: :5443