Created
December 6, 2009 17:41
-
-
Save araddon/250307 to your computer and use it in GitHub Desktop.
Testing out new redis connection pooling performance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Testing Pooled = 109s:: | |
ab -n 20000 -c 1 http://192.168.1.2:8888/rp | |
Testing Non Pooled = 148s:: | |
ab -n 20000 -c 1 http://192.168.1.2:8888/r | |
""" | |
import tornado.httpserver | |
import tornado.ioloop | |
import tornado.options | |
import tornado.web | |
import redis | |
from tornado.options import define, options | |
define("port", default=8888, help="run on the given port", type=int) | |
class MainHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.write("Hello, world") | |
class RedisHandler(tornado.web.RequestHandler): | |
def get(self): | |
r = redis.Redis(host='192.168.1.7') | |
r.set("hello","Redis") | |
h = r.get("hello") | |
if h == 'Redis': | |
self.write("Hello, %s" % h) | |
else: | |
self.write("Crap!") | |
r.disconnect() | |
class RedisPooledHandler(tornado.web.RequestHandler): | |
def get(self): | |
r = redis.Redis(host='192.168.1.7',pooled=True) | |
r.set("hello","Pooled") | |
h = r.get("hello") | |
if h == 'Pooled': | |
self.write("Hello, %s" % h) | |
else: | |
self.write("Crap!") | |
def main(): | |
tornado.options.parse_command_line() | |
application = tornado.web.Application([ | |
(r"/", MainHandler), | |
(r"/r", RedisHandler), | |
(r"/rp", RedisPooledHandler), | |
], | |
**{"debug":True}) | |
http_server = tornado.httpserver.HTTPServer(application) | |
http_server.listen(options.port) | |
tornado.ioloop.IOLoop.instance().start() | |
if __name__ == "__main__": | |
main() |
Sorry, forgot this was still up there. This was for a branch of redis i made, for performance testing of the thread-local changes to redis python client I submitted, but when implemented it became the default, (thus no pooled parameter).
I will delete it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Traceback (most recent call last):
File "", line 1, in
TypeError: init() got an unexpected keyword argument 'pooled'