Work servers only need 4 celery.

This commit is contained in:
Samuel Clay 2024-02-18 08:08:25 -05:00
parent 39f4d73a13
commit f17d12a10c
4 changed files with 33 additions and 13 deletions

View file

@ -7,22 +7,32 @@ groups:
haproxy: inventory_hostname.startswith('hwww')
app: inventory_hostname.startswith('happ')
happ: inventory_hostname.startswith('happ')
web: inventory_hostname.startswith('happ')
app: inventory_hostname.startswith('happ')
hweb: inventory_hostname.startswith('happ')
django: inventory_hostname.startswith('happ-web')
hdjango: inventory_hostname.startswith('happ-web')
refresh: inventory_hostname.startswith('happ-refresh')
hrefresh: inventory_hostname.startswith('happ-refresh')
count: inventory_hostname.startswith('happ-count')
hcount: inventory_hostname.startswith('happ-count')
push: inventory_hostname.startswith('happ-push')
hpush: inventory_hostname.startswith('happ-push')
blogs: inventory_hostname.startswith('blog')
hnode: inventory_hostname.startswith('hnode')
node: inventory_hostname.startswith('hnode')
hnode: inventory_hostname.startswith('hnode')
node_socket: inventory_hostname.startswith('hnode-socket')
hnode_socket: inventory_hostname.startswith('hnode-socket')
node_images: inventory_hostname.startswith('hnode-images')
hnode_images: inventory_hostname.startswith('hnode-images')
node_text: inventory_hostname.startswith('hnode-text')
hnode_text: inventory_hostname.startswith('hnode-text')
node_page: inventory_hostname.startswith('hnode-page')
hnode_page: inventory_hostname.startswith('hnode-page')
node_favicons: inventory_hostname.startswith('hnode-favicons')
hnode_favicons: inventory_hostname.startswith('hnode-favicons')
# debugs: inventory_hostname.startswith('hdebug')

View file

@ -127,6 +127,9 @@
- name: Reload gunicorn
command: "kill -HUP {{ psaux.stdout }}"
when: not pulled.changed
rescue:
- name: Restart Docker Container
command: "docker restart newsblur_web"
tags:
- static

View file

@ -92,14 +92,14 @@ backend nginx
option httpchk GET /_nginxchk
http-check expect rstatus 200|503
default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
{% for host in groups.web %}
{% for host in groups.hweb %}
server nginx-{{host}} {{host}}.node.nyc1.consul:80
{% endfor %}
backend app_django
option httpchk GET /_haproxychk
default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
{% for host in groups.django %}
{% for host in groups.hdjango %}
server {{host}} {{host}}.node.nyc1.consul:8000
{% endfor %}
@ -107,7 +107,7 @@ backend app_count
balance roundrobin
option httpchk GET /_haproxychk
default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
{% for host in groups.count %}
{% for host in groups.hcount %}
server {{host}} {{host}}.node.nyc1.consul:8000
{% endfor %}
# server-template app-counts 1 _app-counts._tcp.service.nyc1.consul:8000 check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
@ -116,7 +116,7 @@ backend app_refresh
balance roundrobin
option httpchk GET /_haproxychk
default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
{% for host in groups.refresh %}
{% for host in groups.hrefresh %}
server {{host}} {{host}}.node.nyc1.consul:8000
{% endfor %}
# server-template app-refresh 1 _app-refresh._tcp.service.nyc1.consul:8000 check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
@ -125,7 +125,7 @@ backend app_push
balance roundrobin
option httpchk GET /_haproxychk
default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
{% for host in groups.push %}
{% for host in groups.hpush %}
server {{host}} {{host}}.node.nyc1.consul:8000
{% endfor %}
# server-template app-push 1 _app-push._tcp.service.nyc1.consul:8000 check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
@ -134,13 +134,13 @@ backend node_images
option httpchk HEAD /sc,seLJDaKBog3LLEMDe8cjBefMhnVSibO4RA5boZhWcVZ0=/https://samuelclay.com/static/images/2019%20-%20Cuba.jpg
http-check expect rstatus 200|301
default-server check inter 10000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
{% for host in groups.node_images %}
{% for host in groups.hnode_images %}
server {{host}} {{host}}.node.nyc1.consul:8088
{% endfor %}
backend node_socket
balance roundrobin
default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
{% for host in groups.node_socket %}
{% for host in groups.hnode_socket %}
server {{host}} {{host}}.node.nyc1.consul:8008
{% endfor %}
@ -149,7 +149,7 @@ backend node_favicons
option httpchk GET /rss_feeds/icon/1
balance roundrobin
default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
{% for host in groups.node_favicons %}
{% for host in groups.hnode_favicons %}
server {{host}} {{host}}.node.nyc1.consul:8008
{% endfor %}
@ -158,7 +158,7 @@ backend node_text
option httpchk GET /rss_feeds/original_text_fetcher?test=1
balance roundrobin
default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
{% for host in groups.node_text %}
{% for host in groups.hnode_text %}
server {{host}} {{host}}.node.nyc1.consul:8008
{% endfor %}
@ -166,7 +166,10 @@ backend node_page
http-check expect rstatus 200|503
option httpchk GET /original_page/1?test=1
balance roundrobin
server-template node-page 1 _node-page._tcp.service.nyc1.consul:8008 check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
{% for host in groups.hnode_page %}
server {{host}} {{host}}.node.nyc1.consul:8008
{% endfor %}
backend staging
balance roundrobin

View file

@ -450,7 +450,11 @@ CELERY_IMPORTS = ("apps.rss_feeds.tasks",
"apps.feed_import.tasks",
"apps.search.tasks",
"apps.statistics.tasks",)
CELERY_WORKER_CONCURRENCY = 16
if "task-work" in SERVER_NAME:
CELERY_WORKER_CONCURRENCY = 4
else:
CELERY_WORKER_CONCURRENCY = 16
CELERY_TASK_IGNORE_RESULT = True
CELERY_TASK_ACKS_LATE = True # Retry if task fails
CELERY_WORKER_MAX_TASKS_PER_CHILD = 10