twitter / fatcache

Memcache on SSD
Apache License 2.0
1.3k stars 178 forks source link

Feature Request: Support for Dalli/Rails #11

Closed benubois closed 10 years ago

benubois commented 11 years ago

It would be great if this could work with Rails and I think for that to happen this would have to work with the Dalli gem. Currently when trying to perform any memcached operations an exception occurs:

require 'dalli'
dc = Dalli::Client.new('localhost:11211')
dc.set('abc', 123)

method server_for_key in ring.rb at line 45 method perform in client.rb at line 347 method set in client.rb at line 199

log from fatcache:

[Fri Sep  6 05:56:01 2013] fc_server.c:87 accepted c 7 on s 6
[Fri Sep  6 05:56:01 2013] fc_memcache.c:785 parsed bad req 12 res 1 type 0 state 0
00000000  80 0b 00 00 00 00 00 00  00 00 00 00 00 00 00 00   |................|
00000010  00 00 00 00 00 00 00 00                            |........|
[Fri Sep  6 05:56:01 2013] fc_core.c:81 recv on c 7 failed: Invalid argument
[Fri Sep  6 05:56:01 2013] fc_core.c:113 close c 7 on event 0005 eof 0 done 0 rb 24 sb 0: Invalid argument
[Fri Sep  6 05:56:01 2013] fc_client.c:64 close c 7 discarding pending req 12 len 24 type 0
manjuraj commented 10 years ago

@benubois could you paste the log file by running fatcache with log level 9 (-v 9)

benubois commented 10 years ago

Certainly, here it is:

[Sun Sep 22 22:13:41 2013] fc_core.c:145 event 0001 on 6
[Sun Sep 22 22:13:41 2013] fc_util.c:573 malloc(120) at 0xa8f970 @ fc_connection.c:180
[Sun Sep 22 22:13:41 2013] fc_connection.c:239 get conn 0xa8f970 c 7
[Sun Sep 22 22:13:41 2013] fc_server.c:87 accepted c 7 on s 6
[Sun Sep 22 22:13:41 2013] fc_server.c:45 accept on s 6 not ready - eagain
[Sun Sep 22 22:13:41 2013] fc_core.c:145 event 0005 on 7
[Sun Sep 22 22:13:41 2013] fc_util.c:573 malloc(224) at 0xa8f9f0 @ fc_message.c:57
[Sun Sep 22 22:13:41 2013] fc_message.c:124 get msg 0xa8f9f0 id 1 request 1 owner sd 7
[Sun Sep 22 22:13:41 2013] fc_util.c:573 malloc(8192) at 0xa8fae0 @ fc_mbuf.c:46
[Sun Sep 22 22:13:41 2013] fc_mbuf.c:99 get mbuf 0xa91ab0
[Sun Sep 22 22:13:41 2013] fc_mbuf.c:199 insert mbuf 0xa91ab0 len 0
[Sun Sep 22 22:13:41 2013] fc_connection.c:63 recv on sd 7 24 of 8144
[Sun Sep 22 22:13:41 2013] fc_memcache.c:785 parsed bad req 1 res 1 type 0 state 0
00000000  80 0b 00 00 00 00 00 00  00 00 00 00 00 00 00 00   |................|
00000010  00 00 00 00 00 00 00 00                            |........|
[Sun Sep 22 22:13:41 2013] fc_core.c:81 recv on c 7 failed: Invalid argument
[Sun Sep 22 22:13:41 2013] fc_core.c:113 close c 7 on event 0005 eof 0 done 0 rb 24 sb 0: Invalid argument
[Sun Sep 22 22:13:41 2013] fc_client.c:64 close c 7 discarding pending req 1 len 24 type 0
[Sun Sep 22 22:13:41 2013] fc_message.c:141 put msg 0xa8f9f0 id 1
[Sun Sep 22 22:13:41 2013] fc_mbuf.c:208 remove mbuf 0xa91ab0 len 24
[Sun Sep 22 22:13:41 2013] fc_mbuf.c:121 put mbuf 0xa91ab0 len 24
[Sun Sep 22 22:13:41 2013] fc_connection.c:162 put conn 0xa8f970
manjuraj commented 10 years ago

looks like the Dalli is trying to use binary protocol (https://github.com/mperham/dalli). fatcache only supports memcache ascii protocol.

manjuraj commented 10 years ago

closing this for now. feel free to reopen if you have questions

benubois commented 10 years ago

@manjuraj,

Makes sense, but I keep coming back to this project as memcached on SSD is such a great idea.

I think it would be a great feature and would make fatcache immediately useful to anyone using Rails.

Any thoughts on what it would take to support the binary protocol?

manjuraj commented 10 years ago

There is an implementation of binary memcache in the twemproxy project (https://github.com/twitter/twemproxy/commit/f2ffca7e9bdf43efe6c60143c37ef2d628bb8fc6). See twemproxy, branch - binary_memcache.

I believe it would be trivial to port this over to fatcache