binary protocol notes from the facebook hackathon
dustin at spy.net
Wed Jul 11 07:45:18 UTC 2007
On Jul 10, 2007, at 9:23, Brad Fitzpatrick wrote:
> REQUEST STRUCTURE:
> * Magic byte / version
> * Cmd byte
> * Key len byte (if no key, 0)
> * Reserved byte (should be 0)
> * 4 byte opaque id. (will be copied back in response; means
> nothing to server)
> * 4 byte body length (network order; not including 12 byte header)
> [ cmd-specific fixed-width fields ]
> * key, if key length above is non-zero.
> [ cmd-specific variable-width field ]
I found a problem when implementing this. Given the above
structure, we always know the length of a key, but we can't know the
location of a key unless we know how to process the given command.
I don't know that this is a huge problem, but it thwarted some of my
generic lower-level packet handling code in my test server.
Perhaps we could resurrect the reserved byte and use it as a fixed-
field word (or byte) count? I remember this coming up in the
discussion, but I think we decided it was redundant as the command
should know what its headers are.
More information about the memcached