django-cachalot/docs/limits.rst
2015-02-16 16:18:32 +01:00

63 lines
2.3 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.. _limits:
Limits
------
Locmem
......
Locmem is a just a dict stored in a single Python process.
Its not shared between processes, so dont use locmem with django-cachalot
in a multi-processes project, if you use RQ or Celery for instance.
Redis
.....
By default, Redis will not evict persistent keys (those without an expiry set)
when the maximum memory has been reached. The keys created by django-cachalot
are persistent, so in an out of memory situation most of the site will go down
due to OOM exceptions.
To avoid this, you can change 'maxmemory-policy' to 'allkeys-lru' in redis.conf.
Be aware that this policy applies to all the databases on that server.
You'll also want to keep an eye on the redis stats and increase 'maxmemory' if
needed. This is just to improve performance, it doesn't impact site availability.
MySQL
.....
This database software already provides by default something like
django-cachalot:
`MySQL query cache <http://dev.mysql.com/doc/refman/5.7/en/query-cache.html>`_.
Django-cachalot will slow down your queries if that query cache is enabled.
If its not enabled, django-cachalot will make queries much faster.
But you should probably better enable the query cache instead.
.. _Raw queries limits:
Raw SQL queries
...............
.. note::
Dont worry if you dont understand what follow. That probably means you
dont use raw queries, and therefore are not directly concerned by
those potential issues.
By default, django-cachalot tries to invalidate its cache after a raw query.
It detects if the raw query contains ``UPDATE``, ``INSERT`` or ``DELETE``,
and then invalidates the tables contained in that query by comparing
with models registered by Django.
This is quite robust, so if a query is not invalidated automatically
by this system, please :ref:`send a bug report <reporting>`.
In the meantime, you can use :ref:`the API <API>` to manually invalidate
the tables where data has changed.
However, this simple system can be too efficient in some cases and lead to
unwanted extra invalidations.
In such cases, you may want to partially disable this behaviour by
:ref:`dynamically overriding settings <Dynamic overriding>` to set
:ref:`CACHALOT_INVALIDATE_RAW` to ``False``.
After that, use :ref:`the API <API>` to manually invalidate the tables
you modified.