C#C
C#3y ago
Messiah

❔ Dealing with parallel http requests in an API

I have an API that receives many requests before they've concluded executing in the api. This causes unwanted behaviour such as writing twice to the database with the same PK.

What options do I have to fix this? I'm honestly looking for the easiest to implement solution, at this point I don't care about good practices or performance, except for only the ASP.NET controller having to be async (so I can't drop all requests while I process one).

I've thought about putting requests in queues or channels, also thought about implementing some kind of lock that doesn't drop incoming requests (if that's a thing).

Ideas?
Was this page helpful?