| 1 | <?xml version="1.0" encoding="US-ASCII"?> |
|---|
| 2 | <!DOCTYPE rfc SYSTEM "rfc2629.dtd"> |
|---|
| 3 | <?xml-stylesheet type='text/xsl' href='rfc2629.xslt'?> |
|---|
| 4 | <?rfc toc="yes"?> |
|---|
| 5 | <?rfc strict="yes"?> |
|---|
| 6 | <?rfc symrefs="yes"?> |
|---|
| 7 | <?rfc sortrefs="yes" ?> |
|---|
| 8 | <?rfc compact="yes" ?> |
|---|
| 9 | <?rfc subcompact="yes" ?> |
|---|
| 10 | <rfc category="info" docName="draft-stone-memcache-udp-01" ipr="none"> |
|---|
| 11 | |
|---|
| 12 | <front> |
|---|
| 13 | |
|---|
| 14 | <title abbrev="Memcache Over UDP"> Memcache Binary Protocol: Extensions for UDP </title> |
|---|
| 15 | |
|---|
| 16 | <author fullname="Aaron Stone" surname="Aaron Stone" role="editor"> |
|---|
| 17 | <organization>Six Apart, Ltd.</organization> |
|---|
| 18 | <address> |
|---|
| 19 | <postal> |
|---|
| 20 | <street>548 4th Street</street> |
|---|
| 21 | <city>San Francisco</city> |
|---|
| 22 | <region>CA</region> |
|---|
| 23 | <code>94107</code> |
|---|
| 24 | <country>USA</country> |
|---|
| 25 | </postal> |
|---|
| 26 | <email>aaron@serendipity.palo-alto.ca.us</email> |
|---|
| 27 | </address> |
|---|
| 28 | </author> |
|---|
| 29 | |
|---|
| 30 | <date day="14" month="December" year="2007" /> |
|---|
| 31 | |
|---|
| 32 | <area>Applications</area> |
|---|
| 33 | |
|---|
| 34 | <keyword>memcache memcached cache udp</keyword> |
|---|
| 35 | |
|---|
| 36 | <abstract> |
|---|
| 37 | <t> |
|---|
| 38 | This memo explains extensions to the memcache binary protocol for use in a UDP environment. |
|---|
| 39 | </t> |
|---|
| 40 | |
|---|
| 41 | <t> |
|---|
| 42 | Memcache is a high performance key-value cache. It is intentionally a |
|---|
| 43 | dumb cache, optimized for speed only. Applications using memcache do |
|---|
| 44 | not rely on it for data -- a persistent database with guaranteed reliability |
|---|
| 45 | is strongly recommended -- but applications can run much faster when |
|---|
| 46 | cached data is available in memcache. |
|---|
| 47 | </t> |
|---|
| 48 | </abstract> |
|---|
| 49 | </front> |
|---|
| 50 | |
|---|
| 51 | <middle> |
|---|
| 52 | <section anchor="introduction" title="Introduction"> |
|---|
| 53 | <t> |
|---|
| 54 | Memcache is a high performance key-value cache. It is intentionally a |
|---|
| 55 | dumb cache, optimized for speed only. Applications using memcache do |
|---|
| 56 | not rely on it for data -- a persistent database with guaranteed reliability |
|---|
| 57 | is strongly recommended -- but applications can run much faster when |
|---|
| 58 | cached data is available in memcache. |
|---|
| 59 | </t> |
|---|
| 60 | <t> |
|---|
| 61 | Sites may find that, due to their network architecture or application usage patterns, |
|---|
| 62 | the stateless <xref target="UDP"/> protocol better suits their needs. This document |
|---|
| 63 | provides extensions and descriptions of use of the <xref target="MEMCACHE">memcache protocol</xref> |
|---|
| 64 | in a UDP environment. |
|---|
| 65 | </t> |
|---|
| 66 | <t> |
|---|
| 67 | It is a goal of this document to provide sufficient information in each UDP packet |
|---|
| 68 | as to avoid any requirement for statefulness on the part of the server nor significant |
|---|
| 69 | caching of outstanding packets on the part of the client. |
|---|
| 70 | </t> |
|---|
| 71 | <section anchor="conventions" title="Conventions Used In This Document"> |
|---|
| 72 | <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", |
|---|
| 73 | "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this |
|---|
| 74 | document are to be interpreted as described in <xref target="KEYWORDS"/>. |
|---|
| 75 | </t> |
|---|
| 76 | </section> |
|---|
| 77 | </section> |
|---|
| 78 | |
|---|
| 79 | <section anchor="values" title="Defined Values"> |
|---|
| 80 | <section anchor="value-magic" title="Magic Byte"> |
|---|
| 81 | <t> |
|---|
| 82 | The magic bytes remains the same as in <xref target="MEMCACHE"/>. |
|---|
| 83 | </t> |
|---|
| 84 | </section> |
|---|
| 85 | |
|---|
| 86 | <section anchor="value-status" title="Response Status"> |
|---|
| 87 | <t> |
|---|
| 88 | Additional status values: |
|---|
| 89 | <list hangIndent="8" style="hanging"> |
|---|
| 90 | <t hangText="0x0004">Value is larger than a single response packet</t> |
|---|
| 91 | </list> |
|---|
| 92 | </t> |
|---|
| 93 | </section> |
|---|
| 94 | |
|---|
| 95 | <section anchor="value-opcodes" title="Command Opcodes"> |
|---|
| 96 | <t> |
|---|
| 97 | Additional opcode values: |
|---|
| 98 | <list hangIndent="8" style="hanging"> |
|---|
| 99 | <t hangText="0x0C">Get Range</t> |
|---|
| 100 | <t hangText="0x0D">Set Range</t> |
|---|
| 101 | </list> |
|---|
| 102 | </t> |
|---|
| 103 | </section> |
|---|
| 104 | |
|---|
| 105 | <section anchor="value-types" title="Data Types"> |
|---|
| 106 | <t> |
|---|
| 107 | There are no new data types in this extension. |
|---|
| 108 | </t> |
|---|
| 109 | </section> |
|---|
| 110 | </section> |
|---|
| 111 | |
|---|
| 112 | <section anchor="commands" title="Commands"> |
|---|
| 113 | |
|---|
| 114 | <section anchor="command-get" title="Get Response"> |
|---|
| 115 | <t> |
|---|
| 116 | This section extends the behavior of the Get and GetQ commands as described in |
|---|
| 117 | <xref target="MEMCACHE" x:sec="command-get"/>. |
|---|
| 118 | </t> |
|---|
| 119 | |
|---|
| 120 | <t> |
|---|
| 121 | When a Get or GetQ request is made via UDP, and the value of the key for which |
|---|
| 122 | the request was made is larger than can be placed into a single UDP packet (noting |
|---|
| 123 | that the protocol header must also be counted), a Get Range response packet |
|---|
| 124 | MUST be sent instead of the Get response packet. In this instance: |
|---|
| 125 | <list style="numbers"> |
|---|
| 126 | <t>The Status field of the response header MUST be 0x0004.</t> |
|---|
| 127 | <t>The Offset field of the GetR response extras MUST be 0.</t> |
|---|
| 128 | <t>The Length field of the GetR response extras, and the data contained in |
|---|
| 129 | the Value field of the packet, SHOULD be the maximum |
|---|
| 130 | allowed length of a UDP packet, less the space required by the header |
|---|
| 131 | and extras; however it MAY be any amount below this maximum.</t> |
|---|
| 132 | <t>The Total value length field of the response extras MUST be the |
|---|
| 133 | actual length of the complete value.</t> |
|---|
| 134 | </list> |
|---|
| 135 | </t> |
|---|
| 136 | |
|---|
| 137 | <t> |
|---|
| 138 | The client, upon receipt of a Get Range response bearing Status 0x004 |
|---|
| 139 | and a Message ID corresponding to its Get request, shall then know that |
|---|
| 140 | it has received only the first portion of the value. The client MAY choose |
|---|
| 141 | to request the remaining portion of the value by sending one or more Get Range requests. |
|---|
| 142 | </t> |
|---|
| 143 | </section> |
|---|
| 144 | |
|---|
| 145 | <section anchor="command-getr-request" title="Get Range Request"> |
|---|
| 146 | <t> |
|---|
| 147 | The Get Range request is primarily intended for use over a UDP transport |
|---|
| 148 | to request byte ranges of the value for a key. In the event that the Data version |
|---|
| 149 | check fails to match that of the key, an error MUST be returned. |
|---|
| 150 | </t> |
|---|
| 151 | <t> |
|---|
| 152 | <figure> |
|---|
| 153 | <preamble>Extra data for get range request:</preamble> |
|---|
| 154 | <artwork> |
|---|
| 155 | Byte/ 0 | 1 | 2 | 3 | |
|---|
| 156 | / | | | | |
|---|
| 157 | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| |
|---|
| 158 | +---------------+---------------+---------------+---------------+ |
|---|
| 159 | 0| Flags | |
|---|
| 160 | +---------------+---------------+---------------+---------------+ |
|---|
| 161 | 4| Data version check | |
|---|
| 162 | | | |
|---|
| 163 | +---------------+---------------+---------------+---------------+ |
|---|
| 164 | 12| Offset | |
|---|
| 165 | +---------------+---------------+---------------+---------------+ |
|---|
| 166 | 16| Length | |
|---|
| 167 | +---------------+---------------+---------------+---------------+ |
|---|
| 168 | Total 20 bytes |
|---|
| 169 | </artwork></figure> |
|---|
| 170 | </t> |
|---|
| 171 | </section> |
|---|
| 172 | |
|---|
| 173 | <section anchor="command-getr-response" title="Get Range Response"> |
|---|
| 174 | <t> |
|---|
| 175 | The Get Range request is primarily intended for use over a UDP transport |
|---|
| 176 | to indicate the location of the bytes of the value for a key contained in |
|---|
| 177 | a given packet. A client receives enough information in each Get Range |
|---|
| 178 | extras to construct an appropriately sized buffer in its own memory and |
|---|
| 179 | blindly insert the contents of the packet at the given byte offset. |
|---|
| 180 | </t> |
|---|
| 181 | <t> |
|---|
| 182 | <figure> |
|---|
| 183 | <preamble>Extra data for get range response:</preamble> |
|---|
| 184 | <artwork> |
|---|
| 185 | Byte/ 0 | 1 | 2 | 3 | |
|---|
| 186 | / | | | | |
|---|
| 187 | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| |
|---|
| 188 | +---------------+---------------+---------------+---------------+ |
|---|
| 189 | 0| Flags | |
|---|
| 190 | +---------------+---------------+---------------+---------------+ |
|---|
| 191 | 4| Data version check | |
|---|
| 192 | | | |
|---|
| 193 | +---------------+---------------+---------------+---------------+ |
|---|
| 194 | 12| Offset | |
|---|
| 195 | +---------------+---------------+---------------+---------------+ |
|---|
| 196 | 16| Length | |
|---|
| 197 | +---------------+---------------+---------------+---------------+ |
|---|
| 198 | 20| Total value length | |
|---|
| 199 | +---------------+---------------+---------------+---------------+ |
|---|
| 200 | Total 24 bytes |
|---|
| 201 | </artwork></figure> |
|---|
| 202 | </t> |
|---|
| 203 | </section> |
|---|
| 204 | |
|---|
| 205 | </section> |
|---|
| 206 | |
|---|
| 207 | <section anchor="security" title="Security Considerations"> |
|---|
| 208 | <t> |
|---|
| 209 | This document does not introduce any new security considerations |
|---|
| 210 | beyond those discussed in <xref target="MEMCACHE" x:sec="security"/>. |
|---|
| 211 | </t> |
|---|
| 212 | </section> |
|---|
| 213 | |
|---|
| 214 | </middle> |
|---|
| 215 | |
|---|
| 216 | <back> |
|---|
| 217 | <references title="Normative References"> |
|---|
| 218 | <dwdrfc-ref anchor='UDP' src='http://xml.resource.org/public/rfc/bibxml/reference.RFC.0768.xml'/> |
|---|
| 219 | <dwdrfc-ref anchor='KEYWORDS' src='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'/> |
|---|
| 220 | <!-- FIXME: Get a draft reference for the base document. --> |
|---|
| 221 | <dwdrfc-ref anchor='MEMCACHE' src='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'/> |
|---|
| 222 | </references> |
|---|
| 223 | </back> |
|---|
| 224 | |
|---|
| 225 | </rfc> |
|---|
| 226 | |
|---|