The invention relates to a lightweight technical implementation scheme for generating a distributed unique ID based on a
snowflake algorithm and Redis, in particular to the field of online car-hailing, comprising the steps of initializing
snowflake algorithm parameters as a basis for generating the unique ID, ensuring that the ID generated by calling for multiple times in the same
timestamp has uniqueness, selecting a cloud to deploy a Redis instance, and starting RDB and AOF at the same time. The method comprises the following steps: constructing an ID generator class by utilizing a Spring Boot framework, adding Redis related dependency, defining a starting
timestamp and judging an ID range through row, supporting high-
concurrency requests and avoiding performance bottlenecks, adding a thread group and setting a thread number to simulate a
concurrency user number, adding an HTTP (
Hyper Text Transport Protocol) request, recording performance indexes of Redis by utilizing a redis-cli monitoring command, and checking
response time of Redis and
throughput of a
system. IDs are stored by utilizing a BIGTNT type, slow queries exceeding
execution time are checked through a SLOWLOG command, online car-hailing marketing
business data which are not used any more are cleaned by utilizing redis-cli, a memory is released, efficient
resource use is kept, and memory leakage or overuse is prevented.