Enable caching of blobs in V2 registry protocol, to avoid DB connections after the cache has been loaded

This should help for bursty pull traffic, as it will avoid DB connections on a huge % of requests
This commit is contained in:
Joseph Schorr 2017-12-14 13:38:24 -05:00
parent db6007cb37
commit b2485934ed
5 changed files with 112 additions and 13 deletions

12
app.py
View file

@ -23,6 +23,7 @@ from data import model
from data.archivedlogs import LogArchive
from data.billing import Billing
from data.buildlogs import BuildLogs
from data.cache import InMemoryDataModelCache
from data.model.user import LoginWrappedDBUser
from data.queue import WorkQueue, BuildMetricQueueReporter
from data.userevent import UserEventsBuilderModule
@ -160,16 +161,7 @@ def _request_end(resp):
if request.user_agent is not None:
extra["user-agent"] = request.user_agent.string
user = get_authenticated_user()
if user:
extra['user'] = {'email': user.email,
'uuid': user.uuid,
'org': user.organization,
'robot': user.robot}
logger.info("request-end", extra=extra)
logger.debug('Ending request: %s', request.path)
return resp
@ -188,6 +180,8 @@ Principal(app, use_sessions=False)
tf = app.config['DB_TRANSACTION_FACTORY']
# TODO(jschorr): make this configurable
model_cache = InMemoryDataModelCache()
avatar = Avatar(app)
login_manager = LoginManager(app)