Chinaunix首页 | 论坛 | 博客
  • 博客访问: 29954252
  • 博文数量: 2065
  • 博客积分: 10377
  • 博客等级: 上将
  • 技术积分: 21525
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-04 17:50
文章分类

全部博文(2065)

文章存档

2012年(2)

2011年(19)

2010年(1160)

2009年(969)

2008年(153)

分类: 系统运维

2009-10-18 11:19:47

各种状态
General-purpose statistics
受到无参数的"stats"命令后,服务器发送多行内容,如下: Upon receiving the "stats" command without arguments, the server sents
a number of lines which look like this:
STAT \r\n
服务器用以下一行来终止这个清单: The server terminates this list with the line
END\r\n
在每行状态中, 是状态的名字, 使状态的数据。 以下清单,是所有的状态名称,数据类型,和数据代表的含义。 In each line of statistics, is the name of this statistic, and
is the data. The following is the list of all names sent in
response to the "stats" command, together with the type of the value
sent for this name, and the meaning of the value.
在“类型”一列中,"32u"表示32位无符号整型,"64u"表示64位无符号整型,"32u:32u"表示用冒号隔开的两个32位无符号整型。

In the type column below, "32u" means a 32-bit unsigned integer, "64u"
means a 64-bit unsigner integer. '32u:32u' means two 32-but unsigned
integers separated by a colon.

名称/Name 类型/Type 含义/Meaning
pid 32u 服务器进程ID Process id of this server process
uptime 32u 服务器运行时间,单位秒 Number of seconds this server has been running
time 32u 服务器当前的UNIX时间 current UNIX time according to the server
version string 服务器的版本号 Version string of this server
rusage_user 32u:32u 该进程累计的用户时间
(秒:微妙)
Accumulated user time for this process
(seconds:microseconds)
rusage_system 32u:32u 该进程累计的系统时间
(秒:微妙)
Accumulated system time for this process
(seconds:microseconds)
curr_items 32u 服务器当前存储的内容数量 Current number of items stored by the server
total_items 32u 服务器启动以来存储过的内容总数 Total number of items stored by this server
ever since it started
bytes 64u 服务器当前存储内容所占用的字节数 Current number of bytes used by this server
to store items
curr_connections 32u 连接数量 Number of open connections
total_connections 32u 服务器运行以来接受的连接总数 Total number of connections opened since
the server started running
connection_structures 32u 服务器分配的连接结构的数量 Number of connection structures allocated
by the server
cmd_get 32u 取回请求总数 Cumulative number of retrieval requests
cmd_set 32u 存储请求总数 Cumulative number of storage requests
get_hits 32u 请求成功的总次数 Number of keys that have been requested and
found present
get_misses 32u 请求失败的总次数 Number of items that have been requested
and not found
bytes_read 64u 服务器从网络读取到的总字节数 Total number of bytes read by this server
from network
bytes_written 64u 服务器向网络发送的总字节数 Total number of bytes sent by this server to
network
limit_maxbytes 32u 服务器在存储时被允许使用的字节总数 Number of bytes this server is allowed to
use for storage.


其它命令
Other commands

“flush_all” 命令有一个可选的数字参数。它总是执行成功,服务器会发送“OK\r\n”回应。它的效果是使已经存在的项目立即失效(缺省),或在指定的时间后。此后执 行取回命令,将不会有任何内容返回(除非重新存储同样的键名)。flush_all 实际上没有立即释放项目所占用的内存,而是在随后陆续有新的项目被储存时执行。flush_all 效果具体如下:它导致所有更新时间早于flush_all所设定时间的项目,在被执行取回命令时命令被忽略。

"flush_all" is a command with an optional numeric argument. It always succeeds, and the server sends "OK\r\n" in response. Its effect is to invalidate all existing items immediately (by default) or after the expiration specified. After invalidation none of the items will be returned in response to a retrieval command (unless it's stored again under the same key *after* flush_all has invalidated the items). flush_all doesn't actually free all the memory taken up by existing items; that will happen gradually as new items are stored. The most precise definition of what flush_all does is the following: it causes all items whose update time is earlier than the time at which flush_all was set to be executed to be ignored for retrieval purposes.
“version”命令没有参数: "version" is a command with no arguments:
version\r\n
在回应中,服务器发送: In response, the server sends
"VERSION \r\n"
是服务器的版本字串。 where is the version string for the server.
“quit”命令没有参数: "quit" is a command with no arguments:
quit\r\n
接收此命令后,服务器关闭连接。不过,客户端可以在不再需要时,简单地关闭连接就行,并不一定需要发送这个命令。 Upon receiving this command, the server closes the connection. However, the client may also simply close the connection when it no longer needs it, without issuing this command.


UDP 协议
UDP protocol
当来自客户端的连接数远大于TCP连接的上限时,可以使用基于UDP的接口。UDP接口不能保证传输到位,所以只有在不要求成功的操作中使用;比如被用于一个“get”请求时,会因不当的缓存处理而发生错误或回应有遗失。 For very large installations where the number of clients is high enough that the number of TCP connections causes scaling difficulties, there is also a UDP-based interface. The UDP interface does not provide guaranteed delivery, so should only be used for operations that aren't required to succeed; typically it is used for "get" requests where a missing or incomplete response can simply be treated as a cache miss.
每个UDP数据包都包含一个简单的帧头,数据之后的内容与TCP协议的描述类似。在执行所产生的数据流中,请求必须被包含在单独的一个UDP数据包中,但是回应可能跨越多个数据包。(只有“get”和“set”请求例外,跨越了多个数据包) Each UDP datagram contains a simple frame header, followed by data in the same format as the TCP protocol described above. In the current implementation, requests must be contained in a single UDP datagram, but responses may span several datagrams. (The only common requests that would span multiple datagrams are huge multi-key "get" requests and "set" requests, both of which are more suitable to TCP transport for reliability reasons anyway.)
帧头有8字节长,如下(均由16位整数组成,网络字节顺序,高位在前): The frame header is 8 bytes long, as follows (all values are 16-bit integers in network byte order, high byte first):
  • 0-1 请求ID
  • 2-3 序号
  • 4-5 该信息的数据包总数
  • 6-7 保留位,必须为0
  • 0-1 Request ID
  • 2-3 Sequence number
  • 4-5 Total number of datagrams in this message
  • 6-7 Reserved for future use; must be 0
请求ID有客户端提供。一般它会是一个从随机基数开始的递增值,不过客户端想用什么样的请求ID都可以。服务器的回应会包含一个和请求中的同样的ID。客户端使用请求ID来区分每一个回应。任何一个没有请求ID的数据包,可能是之前的请求遭到延迟而造成的,应该被丢弃。 The request ID is supplied by the client. Typically it will be a monotonically increasing value starting from a random seed, but the client is free to use whatever request IDs it likes. The server's response will contain the same ID as the incoming request. The client uses the request ID to differentiate between responses to outstanding requests if there are several pending from the same server; any datagrams with an unknown request ID are probably delayed responses to an earlier request and should be discarded.
序号的返回是从0到n-1,n是该条信息的数据包数量。 The sequence number ranges from 0 to n-1, where n is the total number of datagrams in the message. The client should concatenate the payloads of the datagrams for a given response in sequence number order; the resulting byte stream will contain a complete response in the same format as the TCP protocol (including terminating \r\n sequences).
阅读(1206) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~