Skip to content

Commit

Permalink
Merge pull request #33 from skalenetwork/hotfix/improve-nginx
Browse files Browse the repository at this point in the history
Limit number of connections to an upstream
  • Loading branch information
dmytrotkk authored Dec 28, 2022
2 parents a7d0c8c + 8fc5978 commit e55c92e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions proxy/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def generate_endpoints(endpoint: str, abi_filepath: str) -> list:
schains_internal_contract, schains_contract, nodes_contract, schain_hash)
for schain_hash in schain_hashes
]
endpoints = list(filter(lambda item: item is not None, endpoints)) # TODO: hotfix!
return endpoints


Expand Down
2 changes: 2 additions & 0 deletions proxy/nginx.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def is_container_running(container) -> bool:
def generate_nginx_configs(schains_endpoints: list) -> None:
logger.info('Generating nginx configs...')
for schain_endpoints in schains_endpoints:
if not schain_endpoints:
continue
logger.info(f'Processing template for {schain_endpoints["chain_info"]["schain_name"]}...')
process_nginx_config_template(schain_endpoints['chain_info'], SERVER_NAME)

Expand Down
6 changes: 3 additions & 3 deletions templates/upstream.conf.j2
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
upstream {{ schain_name }} {
ip_hash;
{% for endpoint in http_endpoints %}
server {{ endpoint }} max_fails=1 fail_timeout=10s;
server {{ endpoint }} max_fails=1 max_conns=500 fail_timeout=10s;
{% endfor %}
}
upstream ws-{{ schain_name }} {
ip_hash;
{% for endpoint in ws_endpoints %}
server {{ endpoint }} max_fails=1 fail_timeout=10s;
server {{ endpoint }} max_fails=1 max_conns=500 fail_timeout=10s;
{% endfor %}
}
upstream storage-{{ schain_name }} {
ip_hash;
{% for endpoint in fs_endpoints %}
server {{ endpoint }} max_fails=1 fail_timeout=10s;
server {{ endpoint }} max_fails=1 max_conns=500 fail_timeout=10s;
{% endfor %}
}

0 comments on commit e55c92e

Please sign in to comment.