celluloid / floss

UNMAINTAINED: See celluloid/celluloid#779 - A Ruby implementation of the Raft consensus algorithm.
MIT License
77 stars 14 forks source link

Redis Persistent Log #18

Closed josephglanville closed 11 years ago

josephglanville commented 11 years ago

This implements an initial pass at a persistent log in Redis.

It also adds another example script which uses this new log backend and an initial set of specs to describe the Floss::Log class.

aflatter commented 11 years ago

Won't merge this for now. I'm talking to Joseph about the usefulness of a Redis backend.

tarcieri commented 11 years ago

@aflatter would like to know your thoughts on a Redis backend too

aflatter commented 11 years ago

@tarcieri Some quick thoughts: I personally would prefer a single implementation for persisting logs. I'm not sure how useful it is to store them in a database requiring a separate daemon. Just logging to files means less setup cost and not having yet another layer of adapters means less maintenance.

tarcieri commented 11 years ago

@aflatter seems good, thanks for the explanation (not a fan of Redis for this use case either ;)

josephglanville commented 11 years ago

Agreed, as I explained to @aflatter via email I intended to use Redis as an example implementation because I wasn't up to speed on how Celluloid works with blocking IO. I have since implemented a Kyotocabinet backend (could just as easily use LevelDB, MDB or BDB..) that is both faster and simpler.

tarcieri commented 11 years ago

FYI, in the Redis-specific case, there's Celluloid::Redis which uses Celluloid::IO (and is therefore nonblocking):

https://github.com/celluloid/celluloid-redis

That's not to say Redis is a good idea here, though ;)

josephglanville commented 11 years ago

Hehe yeah, this was implemented using Celluloid::Redis because at the time I thought I would need libraries written with the Celluloid::IO framework to prevent blocking of the other actors while the log_replicator is writing entries to disk. Atleast what I have observed is this IO seems to be happening in a separate thread... is this a safe assumption or have I miss-understood what Celluloid does for me here and I still need a way of doing non-blocking IO on the log file?

tarcieri commented 11 years ago

@josephglanville blocking I/O is okay, but if Celluloid::IO is used then actors can continue to receive messages while they're in the middle of I/O operations. For Redis this is mostly useful with PUB/SUB sockets since they can block indefinitely (see also: BRPOP(LPUSH))