Improving Performance and Handling Multi-User Systems
In this meeting, the State Changer expressed concerns about the performance of their ticket-selling system. They mentioned that it took around ten seconds for a match to occur, but they were able to reduce it to five seconds. However, they were looking for a more efficient approach, considering the potential increase in ticket sales. They also tested the system with two different users searching for tickets simultaneously and encountered some issues, such as both users experiencing duplicated waiting times or the second user obtaining the same tickets as the first user.
The State Changer raised the question of how to handle such scenarios and asked for general thoughts on the matter. Another State Changer explained that in multi-user systems, race conditions can occur when two requests are processed in parallel. They suggested implementing locking mechanisms to ensure the right allocation of tickets and mentioned the challenges of using traditional database systems due to network delays. The State Changer proposed using Redis, an in-memory cache, to improve performance and reduce the probability of collisions. By adding a recheck at the end and validating ticket availability before purchase, the State Changer could enhance the atomicity of the system.
The recommendation to explore Redis and understand its capabilities was given, as it can significantly improve performance. The State Changer expressed gratitude for the advice and mentioned their intention to investigate Redis further. The meeting concluded with the State Changer expressing satisfaction with the provided insights and requesting to review the meeting recording later. Additionally, another participant mentioned encountering errors and the need to address missing fields in the system, which will require additional work.