Comments (7)
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.
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.
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.
@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.
Yes it did work. Apologies I should have updated the issue. Thanks
from django-unicorn.
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.
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)
- Unicorn setup during the Django tutorial breaks the tutorial rocket HOT 3
- HTML select "IndexError: tuple index out of range" when using custom setter with "$event.target.value" HOT 1
- Bug: unicorn:poll throwing error HOT 2
- Incorrect Variable Passed Turned into String? HOT 3
- Morphdom Exception: component.js:257 TypeError: Cannot read properties of undefined (reading 'nodeType') HOT 3
- UnicornView._attribute_names() fails in some components because of unresolved type hints HOT 5
- Float in nested tuple[dict] gets converted to string HOT 2
- Using a component inside a loop will duplicate the database query (or rendering the entire page) for each element HOT 3
- Using requests library inside of a UnicornView HOT 1
- Lists of Dataclass or Pydantic objects don't seem to serialize/deserialize properly.. HOT 1
- Cannot redirect from mount()
- feature request: make `self.request` available within `javascript_exclude` class properties HOT 10
- handling non-standard django app configs HOT 2
- parent components (i) do not refresh children html and (ii) break when used as direct views HOT 15
- updating child components via a parent method HOT 1
- Combining ```unicorn:view``` and ```unicorn:poll``` features gives error ```The 'control' component appears to have multiple root elements.``` HOT 1
- ValueError after second post HOT 3
- possible race condition: `unicorn:model` looses data when saved too quickly. HOT 1
- self.parent reference not updating
- Force rendering parent doesn't run context processors
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-unicorn.