Re: [gevent] Why there is only one connection to redis used in a Gevent WSGIServer?

112 views
Skip to first unread message

Zera Holladay

unread,
Mar 30, 2013, 9:26:44 AM3/30/13
to gev...@googlegroups.com
Just a theory: try changing yield to return.

-zh


On Fri, Mar 29, 2013 at 8:12 PM, Xuqing Jia <amazi...@gmail.com> wrote:
I'm using gevent to build a server which do some redis stuff and return the result to client. But the performance is bad. After some research I found that there is only one connection to redis. It looks like there is only one greenlet spawned. Here is my program:

<script src="https://gist.github.com/amazingjxq/5274574.js"></script>

Is there something wrong with my program? Why there is only one connection to redis?

--
You received this message because you are subscribed to the Google Groups "gevent: coroutine-based Python network library" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gevent+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Matthias Urlichs

unread,
Mar 30, 2013, 7:21:26 AM3/30/13
to gev...@googlegroups.com
Hi,

Xuqing Jia:
> Here is my program:
>
> <script src="https://gist.github.com/amazingjxq/5274574.js"></script>
>
That's a JavaScript snippet (which doesn't make much sense to me;
document.write() is almost never what you want to use, these days).

Not Python, much less gevent.

--
-- Matthias Urlichs

Denis Bilenko

unread,
Mar 31, 2013, 4:56:07 AM3/31/13
to gev...@googlegroups.com
I think the link he meant to paste is https://gist.github.com/amazingjxq/5274574


Leif K-Brooks

unread,
Mar 31, 2013, 5:34:39 AM3/31/13
to gev...@googlegroups.com
It seems to be making multiple connections to redis for me. I tested it with:


And got this output:

in_use_conn: 9 created_connections: 10
in_use_conn: 8 created_connections: 10
in_use_conn: 7 created_connections: 10
in_use_conn: 6 created_connections: 10
in_use_conn: 5 created_connections: 10
in_use_conn: 4 created_connections: 10
in_use_conn: 3 created_connections: 10
in_use_conn: 2 created_connections: 10
in_use_conn: 1 created_connections: 10
in_use_conn: 0 created_connections: 10

Is it possible your testing did not actually create multiple concurrent requests?

Btw, you don't need to create an explicit redis.ConnectionPool. The redis.Redis class will create one for you automatically if you allow it to. So you can do `r = redis.Redis()` in the global scope, and use that same r object everywhere.

On Fri, Mar 29, 2013 at 5:12 PM, Xuqing Jia <amazi...@gmail.com> wrote:
I'm using gevent to build a server which do some redis stuff and return the result to client. But the performance is bad. After some research I found that there is only one connection to redis. It looks like there is only one greenlet spawned. Here is my program:
Is there something wrong with my program? Why there is only one connection to redis?

--
Reply all
Reply to author
Forward
0 new messages