What happens when multiple users access same data in an application, when does a web application crash
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
When multiple users access the same data in an application, several issues can arise, affecting the performance, data integrity, and availability of the application. How well a web application handles simultaneous data access largely depends on the application's architecture, underlying technology stack, and specific mechanisms implemented for concurrency control, data consistency, and error handling. Below, we explore these aspects along with scenarios that might cause an application to crash and how to mitigate such risks.
Concurrency and Data Access Issues
In any multi-user environment, data concurrency is a common challenge. Concurrency refers to the scenario where multiple requests are made to the same data or resource at the same time. This can lead to various issues such as:
- Lost Updates: Where the changes made by one user are overwritten unknowingly by another user.
- Dirty Reads: Occurring when one transaction reads data that has been modified by another concurrent transaction which has not yet been committed.
- Non-repeatable Reads: Occurs when a transaction reads the same data twice and gets different results each time because another transaction has modified the data between these two reads.
- Phantom Reads: Similar to non-repeatable reads, but in this case, the latter transaction sees new records added by another transaction.
To address these issues, systems implement various isolation levels and locking mechanisms:
- Locking: Databases often use locks which prevent other transactions from accessing the same data simultaneously. Locks can be of different types such as shared, exclusive, etc.
- Version Control: Some databases implement version control (also known as optimistic concurrency control), where each transaction works on its version of data. Conflicts are resolved by checking if the data was updated during the transaction.
- Timestamp Ordering: This technique assigns a timestamp to each transaction to decide the serial order in which transactions should take precedence.
Why Web Applications Crash
A web application may crash due to numerous reasons, often not merely due to data access issues. Here are some common causes:
- Resource Exhaustion: When the application runs out of necessary resources like memory, CPU, or network bandwidth, especially under heavy load.
- Deadlocks: When multiple processes block each other by holding a lock on the other resource needed by the opposite process.
- Uncaught Exceptions: Errors or exceptions that are not properly handled can cause the application to crash.
- Hardware Malfunctions: Failures in underlying hardware can affect application stability.
Improving Application Stability
To ensure stability and manage concurrent data access effectively, developers can adopt several strategies:
- Implement effective error handling and logging: This helps in understanding the causes of crashes or bugs and responding appropriately.
- Use load balancers to distribute traffic evenly across servers, preventing any single instance from becoming overwhelmed.
- Opt for a scalable architecture — like microservices — which allows parts of the application to scale as per demand.
- Deploy database management practices like setting appropriate isolation levels or using database clusters to handle large volumes of transactions efficiently.
Summary Table
| Issue | Description | Common Solutions |
| Concurrency Conflicts | When multiple users edit the same data simultaneously. | Locks, Version Control |
| Deadlocks | Several processes block each other, each holding a lock on the resource needed by another process. | Timeout mechanisms, Deadlock resolution |
| Resource Exhaustion | Running out of CPU, memory, or network resources. | Effective resource management, Load balancing |
| Uncaught Exceptions | Errors or bugs not covered by error handling leading to a crash. | Thorough error handling and testing |
Final Thoughts
Handling simultaneous data access and ensuring application stability requires careful planning, robust architecture decisions, and proactive management of resources and errors. Through diligent implementation of these strategies, applications can deliver both performance and reliability even under significant user load.

