Throttling across nodes

97 views
Skip to first unread message

David Kuhn

unread,
Feb 6, 2014, 6:01:00 AM2/6/14
to django-res...@googlegroups.com
Has anyone tried using throttling across multiple Django server instances? 

I have multiple Django web servers running DRF behind a load balancer that auto-scale. It wasn't clear to me from the docs how I'd go about setting a global throttling policy (e.g.  if a user is only permitted 1 request at a time, how can this be enforced across the cluster?).

I suspect that I may have to implement a custom throttle which backs onto some sort of store that supports atomic counters (e.g. redis). If someone knows of any resources, examples or modules that already do this it would be a massive help.


Ganesh Swami

unread,
Feb 6, 2014, 1:47:33 PM2/6/14
to django-res...@googlegroups.com
Hi David,

Yes, you're right. You'll have to have shared state in an external store.

This is the classic snippet that I've customized over the years:
https://djangosnippets.org/snippets/2017/

You can use either memcached or redis as both provide atomic counters
with time expiry.

cheers,
Ganesh
> --
> You received this message because you are subscribed to the Google Groups
> "Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-rest-fram...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Ganesh Swami
c: 778-865-6075

Dave Kuhn

unread,
Feb 6, 2014, 8:44:44 PM2/6/14
to django-res...@googlegroups.com
Thanks Ganesh, looks nice and simple. I'll have a crack. If something useful comes out of it I'll submit a pull request.
Reply all
Reply to author
Forward
0 new messages