dragonflydb / dragonfly

A modern replacement for Redis and Memcached
https://www.dragonflydb.io/
Other
25.99k stars 955 forks source link

Are there support memcached binary protocols? #303

Open dph5199278 opened 2 years ago

dph5199278 commented 2 years ago

Describe the bug When I use text protocols, everything is ok. But when I use binary mode, the program will report an error.

To Reproduce

  1. Use xmemcached binary protocols to connect dragonfly
  2. Use set methot
  3. See error

Expected behavior work to ok.

Screenshots image

Environment (please complete the following information):

Reproducible Code Snippet

XMemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses("127.0.0.1:11211"));
// use binary protocols
builder.setCommandFactory(new BinaryCommandFactory());
// set method
builder.build().set(key, 0, value);
romange commented 2 years ago

indeed, we have not implement memcached binary support yet.

dph5199278 commented 2 years ago

indeed, we have not implement memcached binary support yet.

Are there any plan to support binary protocols? thanks

romange commented 2 years ago

Yes, we have plans. Pls dm me at discord or send me an email - I would like to understand your use case better before prioritizing this task.

dph5199278 commented 2 years ago

Yes, we have plans. Pls dm me at discord or send me an email - I would like to understand your use case better before prioritizing this task.

memcached-test.zip

This is my complete use case. Thanks.

romange commented 2 years ago

I am not talking about a reproducible test, I am talking about your system in general. Why do you use memcache in 2022 when writing a new code and cetera.

dph5199278 commented 2 years ago

I am not talking about a reproducible test, I am talking about your system in general. Why do you use memcache in 2022 when writing a new code and cetera.

: ) In my case

  1. I am not use memcached for my new code
  2. There are many old systems that use memcached, I want to compare Memcached with Dragonfly to see whether the cost can be reduced for migration.
  3. redis is different from its interfaces, and the migration cost is high

Thanks.

romange commented 2 years ago

Ok, so it's actually an interesting use-case for us and this is why I wanted to chat with you. You prefer talking here? Discord is faster...

dph5199278 commented 2 years ago

Ok, so it's actually an interesting use-case for us and this is why I wanted to chat with you. You prefer talking here? Discord is faster...

Yes, I never used Discord, so this is better : )

romange commented 2 years ago

ok,

  1. what's the size of your memcached cluster? are you throughput constrained? memory bounded? what would be the decisive factor for you to switch to DF i.e. what's the cost difference that would cause the flip?

  2. Can you check with text-based protocol and decide whether it's more cost efficient for you without binary protocol support? And then if yes, we can prioritize the feature?

my email is roman -at- dragonflydb.io - feel free to reach out there (I hope you used email before 😉 )

dph5199278 commented 2 years ago

what's the size of your memcached cluster? are you throughput constrained? memory bounded? what would be the decisive factor for you to switch to DF i.e. what's the cost difference that would cause the flip?

  1. Dragonfly supports the interface between Redis and Memcached, and the data is interoperable
  2. The dictionary data of the old system takes a lot of time to access for the first time after the memcached is restarted
  3. The old system uses Memcached for session synchronization, which has a large amount of data and uses the binary protocol for higher performance

Can you check with text-based protocol and decide whether it's more cost efficient for you without binary protocol support? And then if yes, we can prioritize the feature?

Prioritize other features, because the old system has been running for a long time. For performance, stability is the priority, so we can wait for your binary protocol support.

: ) Thanks! I send same email too.

alphabet5 commented 7 months ago

(I think) we're looking for support of binary protocols too.

This is an example get request,

Memcache Protocol, Get Key Request
    Magic: Request (128)
    Opcode: Get Key (12)
    Key Length: 35
    Extras length: 0
    Data type: Raw bytes (0)
    Reserved: 0
    [Value length: 0]
    Total body length: 35
    Opaque: 65536
    CAS: 0
    Key: my-modified-key-name

Memcached responds with a normal result / key not found response, but dragonfly there is only a tcp ack, and then nothing else is sent - causing the client to log error 31 (timeout), and send the fin/rst after the configured timeout (5s in our case).

It would be helpful for the server to respond with something more helpful, maybe 28 = MEMCACHED_NOT_SUPPORTED ?

romange commented 7 months ago

how can I send a binary request easily?