from redis._compat import xrange from rediscluster import RedisCluster startup_nodes = [{"host": "127.0.0.1", "port": 7002}, {"host": "127.0.0.1", "port": 7004}, {"host": "127.0.0.1", "port": 7006}, {"host": "127.0.0.1", "port": 7001}, {"host": "127.0.0.1", "port": 7003}, {"host": "127.0.0.1", "port": 7005}] r = RedisCluster(startup_nodes=startup_nodes, max_connections=32, decode_responses=True) for i in xrange(1000000): try: print i d = str(i) r.publish("somechannel", d) except Exception as e: print e