Giter Site home page Giter Site logo

Comments (7)

adamghill avatar adamghill commented on August 22, 2024

I'm curious what you have set up for CACHES in your settings file? Unicorn uses the cache to store component data and I wonder if you have the default local memory storage and that is causing a problem. I use a shared redis as my cache so I've never run into a problem with multiple servers.

from django-unicorn.

citizenfish avatar citizenfish commented on August 22, 2024

We don't have any specific setting for CACHES, just using defaults. We were running django using gnuicorn as follows:-

gunicorn --bind 0.0.0.0:80 \
--workers=4 \
--timeout 120 \
--log-level info locaria.wsgi:application \
--access-logfile '-'

We found that reducing the number of workers to 1 fixed the problem but it would be good to understand how we can code round this as running mount every transaction is going to be very inefficient for us.

from django-unicorn.

adamghill avatar adamghill commented on August 22, 2024

Gunicorn workers each have their own memory so the default local memory cache is not shared across workers.

If you only have one server, but multiple workers you could use filesystem caching. If you have multiple servers you will need one of these:

I tend to use redis so in all of my projects I have something like this:

# settings.py

CACHES = {
    "default": {
        "BACKEND": "django.core.cache.backends.redis.RedisCache",
        "LOCATION": "redis://some-redis-server-host:6379",
    }
}

I'm going to look into some potential workarounds to prevent mount from being called, but not having a shared cache will negatively impact other functionality, especially related to child/parent components (see #593 for another example). Unicorn will also be less performant without a shared cache.

Sorry this is not clearly stated in the documentation as a requirement for a production deployment -- I'm going to update the docs to make this more explicit.

from django-unicorn.

adamghill avatar adamghill commented on August 22, 2024

@citizenfish Were you able to use a shared cache to see if this problem went away? Let me know if you still have problems otherwise, I'll close this issue in a few days. Thanks!

from django-unicorn.

citizenfish avatar citizenfish commented on August 22, 2024

Yes it did work. Apologies I should have updated the issue. Thanks

from django-unicorn.

adamghill avatar adamghill commented on August 22, 2024

That's great news! I updated https://www.django-unicorn.com/docs/installation/ to mention setting up cache for production deployments. Closing this issue, but let me know if other changes would be helpful.

from django-unicorn.

Yethiel avatar Yethiel commented on August 22, 2024

That's great news! I updated https://www.django-unicorn.com/docs/installation/ to mention setting up cache for production deployments. Closing this issue, but let me know if other changes would be helpful.

The docs don't seem to mention it yet.
I ran into the same issue: Locally everything works fine but on production everything was very buggy and unpredictable.

I'm glad it's only a cache issue, unicorn has been great so far! I enabled file based caching and now it works beautifully.

from django-unicorn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.