mysql - Django querysets in a distributed application -


i have 4 ec2 servers running django 1.3.2 application uwsgi. share mysql server on amazon rds. i'm experiencing behavior if new objects created through admin , try:

get_object_or_404(class, pk=new_object.pk) 

sometimes find object, other times return 404.

what going on?

this how i'm using get_object_or_404:

# module level variables if settings.debug:     articles = news.objects.filter(status='live') else:     articles = news.objects.all()   dev view(request, slug):     article = get_object_or_404(articles, slug=slug)     .... 

if restart uwsgi processes, problem goes away.

questions , things i've tried:

  1. are module level variables problem? i've tried debug since querysets lazy doesn't seem problem.
  2. is cache issue? i've restarted memcache , cleared nginx's cache issue remains.
  3. is rds issue? haven't found answer this.
  4. is queryset cache issue? haven't found answer this, , don't know how.

everything works expected on single server, have multiple servers, start experience behavior.

module level variables problem - querysets "lazy" long not used (iteration, evalution, whatever), start retrieving records populate cache (hint: django open-source, can readthecode(tm) when doc not enough).

you might have troubles transaction isolation level if use innodb tables (cf django's doc on last point).


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

uitableview - Create and use custom prototype table cells in xamarin ios using storyboard -