How to response different responses to the same multiple requests based on whether it has been responded?
<p>Let's say my <code>python</code> server has three different responses available. And one user send three HTTP requests at the same time. </p>

<p>How can I make sure that one requests get one unique response out of my three different responses?</p>

<p>I'm using python and mysql. </p>

<p>The problem is that even though I store already responded status in mysql, it's a bit too late by the time the next request came in.</p>

<p>For starters, if MySQL isn't handling your performance requirements (and it rightly shouldn't, that doesn't sound like a very sane use-case), 
consider using something like in-memory caching, or for more flexibility, Redis:
It's built for stuff like this, and will likely respond much, much quicker.
As an added bonus, it has an even simpler implementation than SQL.</p>

<p>Second, consider hashing some user and request details and storing that hash with the response to be able to identify it.
Upon receiving a request, store an entry with a 'pending' status, and only handle 'pending' requests - never ones that are missing entirely.</p>

python distributed-computing