summaryrefslogtreecommitdiff
path: root/zuul/web/__init__.py
diff options
context:
space:
mode:
authorTobias Henkel <tobias.henkel@bmw.de>2022-01-28 11:57:19 +0100
committerTobias Henkel <tobias.henkel@bmw.de>2022-01-31 09:09:14 +0100
commitc2d959fdba0f8032f83535e55256c21a1e3a2367 (patch)
treeac8453a767947d350969197a11e87793ce522d71 /zuul/web/__init__.py
parentf648f21304cd2bdee276e0391b600297b22b7d0f (diff)
downloadzuul-c2d959fdba0f8032f83535e55256c21a1e3a2367.tar.gz
Cache serialized tenant status
We see a very high cpu load on zuul web. Profiling shows that most of that time is spent during json serialization. The biggest json blobs we have is the per tenant status json. This is currently cached as data structure so we can filter it by change as well. In order to reduce json serialization effort also cache a pre-serialized version of this and use it for the tenant status. Change-Id: Idbbcda6bf0835fadf970e4fb43adc300770da8e7
Diffstat (limited to 'zuul/web/__init__.py')
-rwxr-xr-xzuul/web/__init__.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/zuul/web/__init__.py b/zuul/web/__init__.py
index 6d31165fd..489e2a450 100755
--- a/zuul/web/__init__.py
+++ b/zuul/web/__init__.py
@@ -943,6 +943,7 @@ class ZuulWebAPI(object):
last_modified_header = last_modified.strftime('%a, %d %b %Y %X GMT')
resp.headers["Last-modified"] = last_modified_header
resp.headers['Access-Control-Allow-Origin'] = '*'
+ resp.headers['Content-Type'] = 'application/json; charset=utf-8'
return payload
def formatStatus(self, tenant):
@@ -982,7 +983,7 @@ class ZuulWebAPI(object):
status['management_events'] = len(
management_event_queues[pipeline.name])
pipelines.append(status)
- return data
+ return data, json.dumps(data).encode('utf-8')
def _getTenantOrRaise(self, tenant_name):
tenant = self.zuulweb.abide.tenants.get(tenant_name)
@@ -1001,15 +1002,14 @@ class ZuulWebAPI(object):
@cherrypy.expose
@cherrypy.tools.save_params()
- @cherrypy.tools.json_out(content_type='application/json; charset=utf-8')
def status(self, tenant):
- return self._getStatus(tenant)
+ return self._getStatus(tenant)[1]
@cherrypy.expose
@cherrypy.tools.save_params()
@cherrypy.tools.json_out(content_type='application/json; charset=utf-8')
def status_change(self, tenant, change):
- payload = self._getStatus(tenant)
+ payload = self._getStatus(tenant)[0]
result_filter = ChangeFilter(change)
return result_filter.filterPayload(payload)