I have use case in which I have to generate 10 million discount codes for a campaign. There can be multiple campaigns. Hence the final discount figures can be close to 200-300 million discount codes.
A simple solution would be to generate these many discount codes and store it in DB(postgres). But that would lead to slowdowns and unnecessary burden on the system.
Alternate solution in my mind is to:
- Store a range_of_discount, campaign in the DB.
- Run python code to generate x-million discount codes in range mentioned in step 1.
- Upload output of above in merchant like GPAY/CRED etc.
- When a user comes in and applies the code, and if it is in range, then it is a valid discount code.
This way, I wont have to store millions of record.
Or is there any easier way to achieve this?
Limitation would be that the codes cannot be sequential.