Add memcached

Seahub caches items (avatars, profiles, etc) on the file system in /tmp/seahub_cache/ by default. You can use memcached instead to improve the performance.

First, make sure libmemcached library and development headers are installed on your system.

On Ubuntu 16.04 (apt-get install python-dev) and CentOS 7 (yum install python-devel) you can install it using the systems package manager.

  1. sudo apt-get install libmemcached-dev

Install Python memcache library.

  1. sudo pip install pylibmc
  2. sudo pip install django-pylibmc

Add the following configuration to seahub_settings.py.

  1. CACHES = {
  2. 'default': {
  3. 'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
  4. 'LOCATION': '127.0.0.1:11211',
  5. },
  6. 'locmem': {
  7. 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  8. },
  9. }
  10. COMPRESS_CACHE_BACKEND = 'locmem'

If you use a memcached cluster, your configuration depends on your Seafile server version. You can find how to setup memcached cluster here.

Seafile server before 6.2.11

Please replace the CACHES variable with the following. This configuration uses consistent hashing to distribute the keys in memcached. More information can be found on pylibmc documentation and django-pylibmc documentation. Supposed your memcached server addresses are 192.168.1.13[4-6].

  1. CACHES = {
  2. 'default': {
  3. 'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
  4. 'LOCATION': ['192.168.1.134:11211', '192.168.1.135:11211', '192.168.1.136:11211',],
  5. 'OPTIONS': {
  6. 'ketama': True,
  7. 'remove_failed': 1,
  8. 'retry_timeout': 3600,
  9. 'dead_timeout': 3600
  10. }
  11. },
  12. 'locmem': {
  13. 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  14. },
  15. }
  16. COMPRESS_CACHE_BACKEND = 'locmem'

Seafile Server 6.2.11 or newer

The configuration is the same as single node memcached server. Just replace the IP address with the floating IP.