redis replication問題の一解

5773 ワード

 # I/O error trying to sync with MASTER: connection lost
[12826] 01 Apr 16:54:38.555 * Connecting to MASTER 10.x.x.x:6379
[12826] 01 Apr 16:54:38.555 * MASTER  SLAVE sync started
[12826] 01 Apr 16:54:38.621 * Non blocking connect for SYNC fired the event.
[12826] 01 Apr 16:54:38.692 * Master replied to PING, replication can continue...
[12826] 01 Apr 16:54:45.229 * MASTER  SLAVE sync: receiving 390598473 bytes from master

client-output-buffer-limit slave 256mb 64mb 60

hard limitは、redisがこの値に達するとすぐにclient接続を閉じます.soft limitは時間に依存する.例えば、ソフトウェアlimitが32 MB 10 sに設定されている場合、clientのoutput bufferが32 MBを超え、10秒間続くと、この接続が切断されることを意味します.デフォルト値はhardが256 M、softが32 M 60秒の通常クライアントのデフォルトlimitが0であり、いつでもlimitがない.通常のclientはブロックを使用して送信コマンドと受信の完全な戻りを実現するため、次のコマンドを送信する前に、通常のclientの場合に接続を閉じるのは適切ではない.しかし、pub/subクライアントには特に注意してください.この方法では、一度に処理され、出力されるデータが特に大きくなります.コンフィギュレーションセットを使用して設定できますが、コンフィギュレーションセットを使用する場合はMB、GBのような単位はサポートされていません.
Output buffers limits Redis needs to handle a variable-length output buffer for every client, since a command can produce a big amount of data that needs to be transferred to the client.
However it is possible that a client sends more commands producing more output to serve at a faster rate at which Redis can send the existing output to the client. This is especially true with Pub/Sub clients in case a client is not able to process new messages fast enough.
Both the conditions will cause the client output buffer to grow and consume more and more memory. For this reason by default Redis sets limits to the output buffer size for different kind of clients. When the limit is reached the client connection is closed and the event logged in the Redis log file.
There are two kind of limits Redis uses: •The hard limit is a fixed limit that when reached will make Redis closing the client connection as soon as possible. •The soft limit instead is a limit that depends on the time, for instance a soft limit of 32 megabytes per 10 seconds means that if the client has an output buffer bigger than 32 megabytes for, continuously, 10 seconds, the connection gets closed.
Different kind of clients have different default limits: •Normal clients have a default limit of 0, that means, no limit at all, because most normal clients use blocking implementations sending a single command and waiting for the reply to be completely read before sending the next command, so it is always not desirable to close the connection in case of a normal client. •Pub/Sub clients have a default hard limit of 32 megabytes and a soft limit of 8 megabytes per 60 seconds. •Slaves have a default hard limit of 256 megabytes and a soft limit of 64 megabyte per 60 second.
It is possible to change the limit at runtime using the CONFIG SET command or in a permanent way using the Redis configuration file redis.conf. See the example redis.conf in the Redis distribution for more information about how to set the limit.