# Performance issue with multiple themes.
Hi everyone.
Some time ago, when we were running our load tests, we found an issue in the platform around the response times when using comprehensive theming.
PROBLEM
Currently, edx-platform has a method to validate if a directory is a valid theme, that method searches within the folders that are set in COMPREHENSIVE_THEME_DIRS, but it does so recursively. Therefore, the more themes you have, the method will be called even more times which considerably increases the response time.
Adding 4 themes to the comprehensive themes directory will as much as triple the response time. Adding one single theme will have a noticeable effect.
TESTS
NOTE:
These tests were executed using K6 with a stage of:
"stages": [{ "target": 28, "duration": "2m" },{ "target": 28, "duration": "6m" },{ "target": 0, "duration": "2m" }]
Increase users from 0 to 28 in 2 minutes, keep the same number of users for 6 minutes more, and finally, decrease the number of users to 0 in 2 minutes.
To get the number of executions we use cProfiler.
All tests were executed in the same Kubernetes cluster.
Image without comprehensive theming
- K6 load test
running (10m09.6s), 00/28 VUs, 602 complete and 0 interrupted iterations
http_req_duration..............: avg=553.57ms min=107.08ms med=492.97ms max=3.98s p(90)=1.02s p(95)=1.24s
- cProfiler*
is_theme_dir number of calls: 0
Image with tutor-indigo
- K6 load test
running (10m15.3s), 00/28 VUs, 523 complete and 0 interrupted iterations
http_req_duration..............: avg=1.24s min=132.26ms med=1.23s max=2.95s p(90)=2s p(95)=2.17s
- cProfiler*
is_theme_dir number of calls: 556
ncalls | tottime | percall | cumtime | percall | filename:lineno(function) |
---|---|---|---|---|---|
556 | 0.0009611 | 1.729e-06 | 0.005788 | 1.041e-05 | helpers_dirs.py:70(is_theme_dir) |
Image with multiple themes
NOTE:
The community themes that we used: cubitetech, digifab, indigo, mitxpro
- K6 load test
running (10m11.9s), 00/28 VUs, 377 complete and 2 interrupted iterations
http_req_duration..............: avg=3.17s min=133.3ms med=3.56s max=7.38s p(90)=4.54s p(95)=4.8s
- cProfiler*
is_theme_dir number of calls: 1896
ncalls | tottime | percall | cumtime | percall | filename:lineno(function) |
---|---|---|---|---|---|
1896 | 0.005246 | 2.767e-06 | 0.03027 | 1.596e-05 | helpers_dirs.py:70(is_theme_dir) |
CONCLUSION
These test results show how the response time drops considerably if you were to download several themes even if they are not in use.
SOLUTION
We are working on finding a solution to this, but we would like to know your opinions about it.
Is this something you have encountered before or even have a workaround for? is the ability to download more than one theme important to some of you?
cProfiler Reports:
indigo.prof (306.0 KB)
themes.prof (314.2 KB)
tutor.prof (301.4 KB)