Closed
Bug 440867
Opened 18 years ago
Closed 18 years ago
Elements should be cached using memcache where appropriate
Categories
(addons.mozilla.org Graveyard :: Administration, defect)
addons.mozilla.org Graveyard
Administration
Tracking
(Not tracked)
RESOLVED
FIXED
3.4.5
People
(Reporter: cpollett, Assigned: cpollett)
Details
Attachments
(2 files)
|
8.38 KB,
patch
|
wenzel
:
review+
|
Details | Diff | Splinter Review |
|
4.51 KB,
text/plain
|
Details |
Some page elements barely change with time such as the categories listing and the search element. These elements appear on nearly every page and for each page that hasn't been cached as whole, these elements will need to be recalculated. It is proposed that for such elements caching be used. Cake supports caching of elements, but it would probably be better to use memcache. We could either follow their API or have a global place where we can select which elements should be cached. I propose caching elements for 20 minutes.
| Assignee | ||
Updated•18 years ago
|
Summary: Elements should be cached used memcache when appropriate → Elements should be cached using memcache when appropriate
| Assignee | ||
Updated•18 years ago
|
Summary: Elements should be cached using memcache when appropriate → Elements should be cached using memcache where appropriate
| Assignee | ||
Comment 1•18 years ago
|
||
Basically, this patch overrides views renderElement in addons.php to support memcaching of elements. The key is calculated from the name of the element and the parameter that have been passed to it. A field for the class $cacheableElts
is used to control which elements caching will be attempted for. Right now this list includes search, categories, and addon_listitem. To make search work, the search_controller had to publish several new variables for advanced search parameters, otherwise, the search element wouldn't remember which advance search parameters are set. For caching to offer a speed improvement, calculating the hash (MD5) has to be faster than computing the element. This seems to be the case for the three elements I am suggesting caching. To test this I did apache bench tests on the main page on my home server with a line like:
ab -k -n 1000 -c 5 my_test_site/amo_front_page
Without caching elements this took 452 seconds, with caching 372. I also tested search pages, to do this I wrote a script benchmark.php which I will attach in a moment. It basically uses curl to request the search results page search on a terms according to the distribution of most common search based on urchin data. Then I could run a line like:
ab -k -n 1000 -c 5 my_test_site/benchmark.php
to test how caching would works for a typical amo search. The results I got were
1108 seconds versus 1078 seconds. There was a fair bit of overhead caused by using curl so I think this is probably a bigger speed up then it seems. In any case, it my testing it seems for the most common activities on amo, element caching should speed things up.
| Assignee | ||
Comment 2•18 years ago
|
||
| Assignee | ||
Comment 3•18 years ago
|
||
An explanation as to why there was less of a speed improvement on the search page versus on the main page occurred to me. On search pages we only have the search element; whereas, on the main page we have both search and categories. In my testing there was only a minor speed improvement from addon_listitem caching on the search pages (on the order of a 4-5 second). So over 1000 hits doing search caching seems to save you about 25ish seconds. On the main page, the remainder of the speed improvement is coming from category caching. As many other common pages (for instance, category browsing) have both elements, the main page is probably more representative of the typical speed-up.
Comment 4•18 years ago
|
||
Frederic, do you have time to review this?
Comment 5•18 years ago
|
||
Ah, crap, I forgot to look at this. Will do, tonight.
Updated•18 years ago
|
Attachment #327043 -
Attachment mime type: application/octet-stream → text/plain
Comment 6•18 years ago
|
||
Thanks.
Comment 7•18 years ago
|
||
Comment on attachment 327041 [details] [diff] [review]
patch to cache some common elements
Yup, that works for me.
Note though that this doesn't seem to take away load too much, in general: Generating views is usually not very expensive, with the exception of your advanced search, and the categories list (for which this patch is probably quite helpful).
For other things, the majority of work happens in the controller, and the view only "digests" the "bite-size" pieces together. Memcaching elements will not take away this part of the work.
Attachment #327041 -
Flags: review?(fwenzel) → review+
| Assignee | ||
Comment 8•18 years ago
|
||
Checked in r16644
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Comment 9•18 years ago
|
||
Chris, could you please help verifying this bug?
Comment 10•18 years ago
|
||
Since this is a purely-under-the-hood thing, I think the only way this is verifiable is by writing a test to check if rendering an element twice won't trigger any database calls the second time around.
Updated•18 years ago
|
Component: Add-ons → Administration
QA Contact: add-ons → administration
Updated•10 years ago
|
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•