Using a ticket server to generate primary identifiers?

I am building a distributed application on top of Java and Cassandra. To generate unique consecutive 32-bit and 64-bit identifiers, an approach is used, for example, using Flickr servers to generate primary identifiers, is it good? I am especially thrilled with this, as it can help me reduce the size of identifiers to 32 bits or 64 bits as needed, which could otherwise go up to 128 bits with a UUID. I do not want these identifiers to be completely consistent, but at least increase!

Using a single database server can, however, introduce a single point of failure that has been fixed by Cassandra. However, this may be good for the initial stage of our application. Later we can introduce two servers to alleviate these problems.

Does that sound like a good strategy? In short, we mix MYSQL and Cassandra in one application. I know that if for some reason mySQL is not going anywhere, we cannot go forward only with Cassandra.

We looked at other solutions, such as a snowflake, but they did not meet our requirements.

EDIT: I seek advice on whether using MySQL to generate unique primary identifiers for entering data / entities stored in a Cassandra database is a good approach. What are the disadvantages, if any, of an approach such as Flickr Ticket servers?

+3
source share
2 answers

I'm not a big fan of trying to make sense of surrogate keys (which you are trying to do if you want them to grow over time). As you can see, this makes it difficult to create keys. Assuming you want the keys to grow over time just so that you can sort the data, why not include the timestamp when the object was created and save it in your data store? This greatly simplifies key genealogy and allows you to do almost anything you can do with keys that grow over time, with an added bonus to the fact that it will be clear who will support your code, how to sort objects.

+3
source

, " ", " SPOF ".

ID, ID, .

, , . ( ). , , , , 111, 120, 113, 122, 115, 124...

" ", , (, 10000 ) () , ( ), . , , , .


Ah, " " number ( , , " ", " data" ), ( number). , , ID- ( number).

+1

Source: https://habr.com/ru/post/1795266/


All Articles