On Tue, Nov 6, 2012 at 7:28 PM, Howard <
howa...@gmail.com> wrote:
> On Wednesday, November 7, 2012 12:52:51 AM UTC+8, Josiah Carlson wrote:
>>
>> > 1. Assume I am using snapshoting, the doc said each snapshots will
>> > create a
>> > new DB, so if I have large memory, e.g. 10GB, if I set a very frequent
>> > snapshot interval, the file IO during snapshot will be very high?
>>
>> Yes, it will be high, regardless of snapshot interval. It writes *all*
>> of your data to disk. So if you tell it to do it every minute, you
>> will writing it to disk every minute.
>>
> So assume I set to sync my 10GB data to disk every time, I will need to copy
> 10GB data to a new file and that is risky since the disk might not be able
> to finish with the 1min interval?
Redis will not start a new sync until the last one is done. So if you
tell it to sync every minute, if it can only sync every minute and a
half, it will.
Depending on your data, if you have 10 gigs of memory being used, you
may not have a 10 gigabyte dump. In my experience, I expect on-disk
dumps to be 1/20-1/5 the size of the in-memory data. So for 10 gigs in
memory, I would expect 500 megs to 2 gigabytes on disk. At 2
gigabytes, that's a 33m/second write to disk. Pretty reasonable if you
have your own hardware, perhaps a bit much if you are in the cloud
somewhere.
Also note that when you have a slave, the initial sync performs a
snapshot, sends it to the slave, then streams write commands.
>> (though the last writes may be partial, but you can fix it with the
>> check aof binary that is created when you compile Redis).
>
> Why there is partial write? I assume redis will write to a new file and
> rename is atomic?
If you are writing to an AOF, and you want to backup the AOF, you have
to remember that Redis is writing data to the AOF continuously. To
backup the AOF, you would need to start copying it. But when you read
those last bytes, the copy process may not get all of the bytes that
Redis has written (Redis writes to the file, but syncs every second,
and can sync less often if other high-IO operations are going on). So
you could end up with a partial AOF.
This isn't an issue with an rdb, because it is point-in-time, as long
as you wait for the dump to complete (and not read the temporary
file).
Regards,
- Josiah