stephenmcd / cartridge

Ecommerce for Mezzanine
http://cartridge.jupo.org
BSD 2-Clause "Simplified" License
708 stars 299 forks source link

memcached - ServerError: error 10 from memcached_set: SERVER ERROR #115

Closed stargazer33 closed 11 years ago

stargazer33 commented 11 years ago

When I want to view a product with a lot of product variants (about 1000) and caching with memcached is enabled I get this error:

[04/Jun/2013 14:59:31] ERROR [django.request:212] Internal Server Error: /shop/product/зигзаг-полотенцесушитель/
Traceback (most recent call last):
  File "/home/inox-t/.virtualenvs/prj_inox/lib/python2.6/site-packages/django/core/handlers/base.py", line 187, in get_response
    response = middleware_method(request, response)
  File "/home/inox-t/.virtualenvs/prj_inox/lib/python2.6/site-packages/mezzanine/core/middleware.py", line 134, in process_response
    response.add_post_render_callback(_cache_set)
  File "/home/inox-t/.virtualenvs/prj_inox/lib/python2.6/site-packages/django/template/response.py", line 92, in add_post_render_callback
    callback(self)
  File "/home/inox-t/.virtualenvs/prj_inox/lib/python2.6/site-packages/mezzanine/core/middleware.py", line 132, in 
    _cache_set = lambda r: cache_set(cache_key, r.content, timeout)
  File "/home/inox-t/.virtualenvs/prj_inox/lib/python2.6/site-packages/mezzanine/utils/cache.py", line 37, in cache_set
    return cache.set(_hashed_key(key), packed, real_timeout)
  File "/home/inox-t/.virtualenvs/prj_inox/lib/python2.6/site-packages/django/core/cache/backends/memcached.py", line 71, in set
    self._cache.set(key, value, self._get_memcache_timeout(timeout))
ServerError: error 10 from memcached_set: SERVER ERROR

here my cache settings:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': '127.0.0.1:11211',
        "BINARY" : True,
        'OPTIONS': {  # Maps to pylibmc "behaviors"
            'tcp_nodelay': True,
            'ketama': True,           
        }
   }
}

PYLIBMC_MIN_COMPRESS_LEN=2048

I googled a bit about this error... it seems it is related to 1M limit of memcached value. I tried with PYLIBMC_MIN_COMPRESS_LEN set and without it, same results

stargazer33 commented 11 years ago

OK, it seems, modifying the memcached argument -I helps. I set it to the value

-I 2M

At the moment it works, no error

stargazer33 commented 11 years ago

Just checked the generated HTML size. It's about 1.5M. This explains why increasing memcached parameter helps.

Actually I just want these dropdown lists. At the the moment I use 7 dropdown lists for the product. It seems using these dropdown lists/options creates problems in cartridge (huge number of variations)

stephenmcd commented 11 years ago

I've no idea what approach will be best for you, but you may need to consider taking a step back and reconsidering a different approach to what you're doing. 1.5M of HTML isn't going to allow for a well functioning site.

chrisspen commented 10 years ago

@stargazer33, How do you set the -I memcached argument in CACHES? Does it go in OPTIONS? I'm having trouble finding any documentation for that in the python wrapper docs.