Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unique sequence number generator in AWS without RDS?

Does any AWS service or solution offer sequence functionality similar to SQL Sequences as found in Postgres or Oracle (or any other RDBMS), without having to maintain an entire Postgres instance?

I do have access to RDS if needed, but I'm wondering if it's overkill just for one sequence and whether theres a simpler/cheaper solution.

Ideally the sequence would be 8 digit numbers, and not needed at a particularly high volume (just a few thousand per day).

Edit: Possible duplicate of Distributed sequence number generation?

Edit 2: To clarify, the goal is to have uniqueness, with simple numbers. Number order is not important, as long as they are unique.

like image 704
James Daily Avatar asked Dec 23 '22 04:12

James Daily


1 Answers

If you are okay with simply having unique IDs (without being sequential), AWS Key Management Service (KMS) has a GenerateRandom function. The chance of duplication is very small.

Or, you could go with a traditional GUID/UUID.

However, if you want the IDs to be sequential, then you will need somewhere to store the value:

  • Amazon DynamoDB is a convenient datastore that offers a much lower cost than an Amazon RDS instance. There is even an Atomic counter that can increment and return the count.
  • If your volume isn't very high, you could consider storing the value in the AWS Systems Manager Parameter Store, which has simple Put/Get capabilities and zero cost.
like image 62
John Rotenstein Avatar answered Jan 05 '23 00:01

John Rotenstein