python - How to response different responses to the same multiple requests based on whether it has been responded? -


let's python server has 3 different responses available. , 1 user send 3 http requests @ same time.

how can make sure 1 requests 1 unique response out of 3 different responses?

i'm using python , mysql.

the problem though store responded status in mysql, it's bit late time next request came in.

for starters, if mysql isn't handling performance requirements (and rightly shouldn't, doesn't sound sane use-case), consider using in-memory caching, or more flexibility, redis: it's built stuff this, , respond much, quicker. added bonus, has simpler implementation sql.

second, consider hashing user , request details , storing hash response able identify it. upon receiving request, store entry 'pending' status, , handle 'pending' requests - never ones missing entirely.


Comments