0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00
wagtail/docs/advanced_topics/performance.rst

100 lines
3.6 KiB
ReStructuredText
Raw Normal View History

2014-02-18 18:45:31 +01:00
Performance
===========
Wagtail is designed for speed, both in the editor interface and on the front-end, but if you want even better performance or you need to handle very high volumes of traffic, here are some tips on eking out the most from your installation.
2014-02-18 18:45:31 +01:00
2014-07-15 15:16:22 +02:00
2014-02-18 18:45:31 +01:00
Editor interface
~~~~~~~~~~~~~~~~
We have tried to minimise external dependencies for a working installation of Wagtail, in order to make it as simple as possible to get going. However, a number of default settings can be configured for better performance:
2014-07-15 15:16:22 +02:00
2014-02-18 18:45:31 +01:00
Cache
-----
We recommend `Redis <http://redis.io/>`_ as a fast, persistent cache. Install Redis through your package manager (on Debian or Ubuntu: ``sudo apt-get install redis-server``), add ``django-redis`` to your ``requirements.txt``, and enable it as a cache backend:
.. code-block:: python
2014-02-18 18:45:31 +01:00
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': '127.0.0.1:6379',
'OPTIONS': {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
}
}
}
2014-02-18 18:45:31 +01:00
2014-02-18 18:45:31 +01:00
Search
------
Wagtail has strong support for `Elasticsearch <http://www.elasticsearch.org/>`_ - both in the editor interface and for users of your site - but can fall back to a database search if Elasticsearch isn't present. Elasticsearch is faster and more powerful than the Django ORM for text search, so we recommend installing it or using a hosted service like `Searchly <http://www.searchly.com/>`_.
Once the Elasticsearch server is installed and running. Install the ``elasticsearch`` Python module with:
.. code-block:: console
$ pip install elasticsearch
2015-05-28 11:12:48 +02:00
then add the following to your settings:
2015-05-28 11:12:48 +02:00
.. code-block:: python
2015-05-28 11:12:48 +02:00
WAGTAILSEARCH_BACKENDS = {
'default': {
'BACKEND': 'wagtail.wagtailsearch.backends.elasticsearch',
2015-05-28 11:12:48 +02:00
'INDEX': '{{ project_name }}',
},
}
Once Elasticsearch is configured, you can index any existing content you may have:
.. code-block:: console
2015-05-28 11:12:48 +02:00
$ ./manage.py update_index
2015-05-28 11:12:48 +02:00
2014-07-15 15:16:22 +02:00
2014-02-18 18:45:31 +01:00
Database
--------
Wagtail is tested on SQLite, and should work on other Django-supported database backends, but we recommend PostgreSQL for production use.
2014-07-15 15:16:22 +02:00
Templates
---------
The overhead from reading and compiling templates can add up. In some cases a significant performance improvement can be gained by using `Django's cached template loader <https://docs.djangoproject.com/en/1.10/ref/templates/api/#django.template.loaders.cached.Loader>`_:
.. code-block:: python
TEMPLATES = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'OPTIONS': {
'loaders': [
('django.template.loaders.cached.Loader', [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]),
],
},
}]
There is a caveat associated with this loader though. Changes to a template file will not be picked up once it is cached. This means that this loader should *not* be enabled during development.
2014-02-18 18:45:31 +01:00
Public users
~~~~~~~~~~~~
.. _caching_proxy:
2014-02-18 18:45:31 +01:00
Caching proxy
-------------
To support high volumes of traffic with excellent response times, we recommend a caching proxy. Both `Varnish <http://www.varnish-cache.org/>`_ and `Squid <http://www.squid-cache.org/>`_ have been tested in production. Hosted proxies like `Cloudflare <https://www.cloudflare.com/>`_ should also work well.
2014-07-15 15:16:22 +02:00
Wagtail supports automatic cache invalidation for Varnish/Squid. See :ref:`frontend_cache_purging` for more information.