(1) Setting the primary key self-increment why not to take
In this case, the database itself is a single point and cannot be detached because the ID is duplicated.
(2) Rely on the database self-increment mechanism to reach the global ID unique
Use the following statement:
REPLACE into Tickets64 VALUES (' a ');
SELECT last_insert_id ();
This guarantees that the global ID is unique, but the Tickets64 table is still a single point.
(3) Rely on the database self-increment mechanism to reach the global ID unique and eliminate the single point
On the basis of 2, deploy two (multiple) DB instances,
Set the self-increment step to 2 (more than the number of instances), i.e. Auto-increment-increment = 2
Set Auto-increment-offset to .....
The first database server has an auto-increment ID of 1 3 5 7 9
Second set is 2 4 6 8 10
(4) solve the problem of excessive pressure on the read library for each request global ID
For example, the first time a business service is started, a unique ID of 3559 is requested.
If the method is 2, 3, then the ID is 3559, so every time the database is requested, the database pressure is larger
can use 3559 * 65536 (for example, and not necessarily 65536) + memory self-increment variable to be used as ID
Retrieve a self-increment ID from the database when the memory self-increment variable reaches 65535
This way, even if there are multiple business servers, the ID is not duplicated:
First set 3559 * 65536 + 1,2,3.....65535
Second Set 3560 * 65536 + 1,2,3.....65535
Then the first to 65535, for a database self-increment ID, this time may be 3561 * 65536 + ....
Resolve database self-increment ID issues