Closed Bug 1191581 Opened 10 years ago Closed 9 years ago

Use Django Cache Machine to cache frequent queries (e.g. refdata lookups)

Categories

(Tree Management :: Treeherder, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: emorley, Assigned: wlach)

References

Details

Attachments

(2 files)

We currently manually handle caching for Datasources: https://github.com/mozilla/treeherder/blob/3b3f3fabd6edadd3d813b5896314195073d8f8ed/treeherder/model/models.py#L166-L175 However this is slightly broken at the moment (bug 1187304). In addition, I wonder if we want to start using caching for more models (eg some of the reference data). There are packages out there that could do this for us in a more automatic manner. eg: http://tech.yipit.com/2011/12/07/django-queryset-cachinge280a6or-how-we-slayed-the-beast-known-as-mysql-joins/ http://jbalogh.me/2010/02/09/cache-machine/ https://cache-machine.readthedocs.org/en/latest/ https://pythonhosted.org/johnny-cache/ https://github.com/dziegler/django-cachebot Cache Machine looks promising - the only thing is that it apparently doesn't currently support QuerySet.values or QuerySet.values_list: https://cache-machine.readthedocs.org/en/latest/#cache-manager ...however we could rework some of the uses of these - or else even add support for them to Cache Manager ourselves. Mauro - what are your thoughts? :-)
Flags: needinfo?(mdoglio)
Blocks: 1187304
There's a comparison grid on https://www.djangopackages.com/grids/g/caching/. I would go with django-cache-machine because it seems to do what we need and other mozilla web properties (e.g. zamboni) use it.
Flags: needinfo?(mdoglio)
Depends on: 1280660
No longer depends on: 1280660
I've been experimenting with Django cache machine with excellent results.
Assignee: nobody → wlachance
Summary: Consider using a library to assist with Django model caching (eg Cache Machine) → Use Django Cache Machine to cache frequent queries (e.g. refdata lookups)
On further investigation I'm not seeing much benefit from using memcache to cache refdata lookups, at least. I think MySQL's built-in cache is already pretty good with this type of information, and thus there's not a huge benefit to taking it out of the loop. Attached is a screenshot of the top database transactions on stage (where I was testing this work). The retrieval patterns are pretty much the same before & after.
Going to close this as wontfix for now, we can always reopen if we have a workload which benefits from db caching in the future.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: