Commit 6657e009 authored by Alessandro CERIONI's avatar Alessandro CERIONI
Browse files

Preventing concurrent instances from refreshing the cache at the same time

parent f26019ef
......@@ -3,11 +3,22 @@ from flask import request, send_file
import os.path
from apscheduler.schedulers.background import BackgroundScheduler
import atexit
import random
from main import refresh_cache
scheduler = BackgroundScheduler()
scheduler.add_job(refresh_cache, 'cron', hour='6', minute='0')
# It was observed that GeoNetwork does not handle multiple concurrent requests.
# As a matter of facts, in case multiple instances of this service refresh the cache
# concurrently, they all receive a 502 Proxy Error response. In order to avoid that,
# we let the the various instances of this service refresh the cache at different times,
# with at least 5 minutes between each request. The following configuration allows for
# 10 concurrent requests.
random_minute = str(5*random.randint(0, 9))
print(random_minute)#
scheduler.add_job(refresh_cache, 'cron', hour='6', minute=random_minute)
#scheduler.add_job(refresh_cache, 'interval', seconds=60)
scheduler.start()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment