On Wed, Oct 15, 2008 at 9:25 PM, bo <[EMAIL PROTECTED]> wrote: > > It seems that what you may want is something like > > http://softwaremaniacs.org/soft/mysql_replicated/
The crux of that solution is the middleware: def process_request(self, request): state = request.method in ['GET', 'HEAD'] and 'slave' or 'master' connection.use_state(state) Which is same as what I am talking about. This will break the moment a GET request tries to do any DB update. They have tried to solve the session issue by providing their own session backend. From the cursory look I did not find what is the fix for User.get_and_delete_messages issue, other than "hoping that it would be fixed by check_state_override" (GET request just after POST will go to master, which only works if all messages are gauranteed to be originated in web POST requests). Either this becomes a django standard, every code that might update database on GET doing something like: connection.use_master() try: ... # something that updates db finally: connection.revert() or we pray/discard this approach of scaling altogether. I modified it to force a master call for everything that was not a > "SELECT" in the final query, and once you force it to the master (or > it auto forces to the master) it will stay there for the duration of > the request to deal with the asynchronous nature of a master-slave > pair. > As I understand, this is too whacky in my opinion, what if after 100 SELECT queries in a view, one does a INSERT/UPDATE based on data obtained so far, SELECTs would have gone to slave, which may be lagging by an uncertain amount of time, and the write to master, this will lead to very hard to reproduce and debug race conditions. -- Amit Upadhyay Vakow! www.vakow.com +91-9820-295-512 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---