On Monday, 7 January 2013 at 18:39, Christoph Sturm wrote:
Hello webbit team,I'm new to webbit, and I want it to build a http server that uses a redis cache.I think https://github.com/spullara/redis-protocol is what I need, but I have no idea how to use netty protocols with webbit.
Well it's a redis protocol for netty so it should not need a new thread.
There is a netty 3.5.2.Final based client in github.com/spullara/redis-protocol now. You'll need to domvn clean install -pl netty-client -amTo build it. It gives you asynchronous completion events and from there you can chain together work between Redis and Webbit. There is an example WebbitServer in the repository as well.
BTW, the client currently doesn't implement:"MULTI", "EXEC", "DISCARD", // Transactions"PSUBSCRIBE", "SUBSCRIBE", "UNSUBSCRIBE", "PUNSUBSCRIBE", // subscriptions
Hi Sam, I just checked out your webbit-redis example, it looks really cool!
Would it be possible to share resources(like the underlying thread pools) between redis.netty.client.RedisClient and redis.client.RedisClient? What I mean is adding a constructor to both RedisClients that'd take an executor - that way one could use both clients for different purposes in a single webbit project while using a single thread pool.
On Sunday, January 13, 2013 12:35:04 PM UTC-8, peter hausel wrote:Hi Sam, I just checked out your webbit-redis example, it looks really cool!Thanks.Would it be possible to share resources(like the underlying thread pools) between redis.netty.client.RedisClient and redis.client.RedisClient? What I mean is adding a constructor to both RedisClients that'd take an executor - that way one could use both clients for different purposes in a single webbit project while using a single thread pool.The executor in the blocking client is used specifically for ensuring correct ordering when using the Pipeline. It must be a single thread executor which will limit your scalability if you are going to share them with another system — it really isn't for pooling. In fact, I should probably set it up so that it isn't even created if you don't use asynchronous features in the blocking client.
Another option would be to move to using my own queue and consuming a thread from a provided executor more in the style of netty though then I would need to implement the ListeningFutures as well.
BTW, why would you use both of them in the same application?
There is a netty 3.5.2.Final based client in github.com/spullara/redis-protocol now. You'll need to domvn clean install -pl netty-client -amTo build it. It gives you asynchronous completion events and from there you can chain together work between Redis and Webbit. There is an example WebbitServer in the repository as well.
Ok, pub/sub support is now in master. I have lightly tested it :) It is basically identical to the support in the blocking client so porting to try it out should be straight-forward. Would love your feedback.
On Sun, Jan 13, 2013 at 2:45 AM, Sam Pullara <spul...@gmail.com> wrote:
There is a netty 3.5.2.Final based client in github.com/spullara/redis-protocol now. You'll need to domvn clean install -pl netty-client -amTo build it. It gives you asynchronous completion events and from there you can chain together work between Redis and Webbit. There is an example WebbitServer in the repository as well.Your example WebbitServer seems to block the Webbit thread while talking to Redis. You should avoid doing this [1].I have sent a pull request that corrects this [2].Aslak
final RedisClient redis = RedisClient.connect("localhost", 6379).get();
but that's happening outside of the event loop.
Sam, please correct me if I am wrong.
Thanks,
Peter
On Sunday, January 13, 2013 6:40:34 PM UTC-5, Aslak Hellesøy wrote:Hi Aslak,On Sun, Jan 13, 2013 at 2:45 AM, Sam Pullara <spul...@gmail.com> wrote:
There is a netty 3.5.2.Final based client in github.com/spullara/redis-protocol now. You'll need to domvn clean install -pl netty-client -amTo build it. It gives you asynchronous completion events and from there you can chain together work between Redis and Webbit. There is an example WebbitServer in the repository as well.Your example WebbitServer seems to block the Webbit thread while talking to Redis. You should avoid doing this [1].I have sent a pull request that corrects this [2].AslakI believe the current example is actually non-blocking already, since RedisClient returns a Promise https://github.com/spullara/redis-protocol/blob/master/netty-client/src/main/java/redis/netty/client/RedisClient.java#L144
I've reduced the synchronization down to just what is necessary to ensure proper ordering of responses. I think the chances of real contention are pretty unlikely as it just spans two enqueues, one to my local matching reply queue and the write to the channel in netty. As it is you can get hundreds of thousands requests+responses per second with a single connection.Peter: you should pull master again. I'll try and do a release if I have time.