I have built a REST endpoint, which writes data(Accounts) to Salesforce. Currently, for a single record, there could be multiple (20-30 times) upserts within 1-to-5 seconds. Behind the scenes, it's a complicated scenario. Also, I can not make it asynchronous using staging object.
Why Upsert: As I may have to query the record before deciding on insert/update(which would slowdown the service, as the records are in millions)
Now the error I face is
DUPLICATE_VALUE, duplicate value found: UNIQUE_ID__c duplicates value on record with id: 0010Q00000ABDA
What could be possible solution to this?