Yes. But this is the case with every multi-master database around,
except for ones that require the writes to replicate out to more than
one node before returning. Some have even designed things like "vector
clocks" to pick a winner during reconnects with writes to both the
"masters".
> Or, does redis cluster intend to syncronously replicate all writes to
> the slaves, so that the write on the master is not considered to have
> 'committed' unless the slave (all or one?) have acknowledged that the
> command was successfully logged by the slave?
There was talk of offering this, I haven't read the cluster doc yet,
so I can't say whether this will be offered.
> The use case that generated this question is whether edis would be
> appropriate to use as an auto-increment ticket server, to generate
> primary keys, a la the twitter snowflake system. Of course, to make
> this work, the ticket server could never 'go backwards' in the
> sequence generator, even in the case of node failures.
High-speed distributed auto-incrementing ids are the wrong thing to
use. There is all of that nasty synchronization stuff that needs to
happen that slows you down. Also, Twitter peaked at somewhere around
10k tweets/second a couple months ago. That's not all that fast.
If you have the space, use UUIDs (128 bits packed). They are designed
to generate unique keys. Some variants are better at proving that
guarantee, but all are pretty good, and none require synchronization
If you have 64 bits, and can deal with one/second (or so) sync times,
you can do the following:
[32 bits for the seconds since Jan 1, 1970][10 bit id][22 bits of a counter]
Each process that is generating ids gets an id that is placed in the
10 bit id field. Every time it generates an 64 bit id, it increments
the counter. Before it generates a 64 bit id in any second (by
incrementing the counter and concatenating the data), it refreshes
it's lock on it's id. That process can generate some 4 million unique
64 bit ids each second. There are some tricks for lock timeouts, etc.,
but aside from a convenient lock and allocation of the 10 bit id, you
don't need Redis for this.
Regards,
- Josiah
Regards,
- Josiah
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
>
>
There's an interesting story with the Virgin space ships, where Burt Rutan designed the launch vehicle and payload vehicle to have the same cockpit, so pilots would only need to train for one system, and so they could standardize on parts etc.
A good goal for offline is to make things as consistent on the client and the server as possible. For example, you would want to write the same language, so you can define the same model definitions, you would want the database interface to be the same, so you could have a simple replication link replicating client database to server database. An offline web app is a distributed system: multiple nodes, most of which are mobile and can be occasionally disconnected, master/master from the get go. Move towards symmetrical nodes as much as possible (e.g. Dynamo), and away from multiple tier asymmetrical systems. UUIDs are a step in the right direction.
While I agree with your sentiment (just use UUIDs for reliability,
consistency, etc.) the practical matter is that most DBMS available in
the marketplace (really all) do a poor job of handling non-integer
primary key ids, and arguably a fairly poor job at non-numeric indexes
generally (Oracle had some awful bugs around this the last time I used
it). The exception being some noSQL dbs that use UUIDs internally
(like MongoDB, Riak, maybe CouchDB, etc.) ... seemingly for their
ability to generate arbitrary ids based on limited/zero-sharing of
information between nodes.
I've had pretty good luck with PostgreSQL and MySQL for string indexes
(just use hex and deal with the larger space, it's just easier), but
I've not personally tried them for primary keys.
Regards,
- Josiah