Improving Performance and Handling Race Conditions in Multi-User Systems with Xano and Redis
The State Changers in this meeting discussed the challenge of handling multiple users requesting for the same resources simultaneously, specifically within a ticketing system. They delved deep into the issues of latency, performance improvement, and race conditions involving "Xano".
One participant was concerned about how to improve system performance when there are thousands of seats to sell and multiple users making requests almost at the same time. A specific problem arises when two users request the same tickets simultaneously, and both get the tickets, resulting in unsuccessful transactions or duplicated records.
The discussion centered on how multi-user systems work and how to manage locking systems to prevent two users from acquiring the same ticket. With conventional techniques, race conditions can still occur, especially when two requests are running completely in parallel.
The most recommended solution was to introduce the concept of locking earlier in the process such that there's less code between scrutinizing the request and when you lock the ticket. This approach significantly reduces the probability of collision but does not eliminate it entirely.
A secondary solution was rechecking whether the ticket is available, just before the user receives it. This double-check method should further decrease the probability of collision.
The last recommendation was integrating a technology like "Redis", an in-memory cache that significantly increases speed because of no network or disk waiting time. Thus, using Redis can shrink the probability of collisions to a fraction of a second, further reducing errors and improving user experience.
Other topics of discussion involved troubleshooting certain issues related to missing fields in the system, which are set to be addressed in the office hours.