by
Agile Support Team
| Nov 20, 2012
While developing a modern web application, the target is always to have a huge business impact and success. Many-a-times this success is related to the number of users visiting and re-visiting the site and as the users increase so does the application’s load and performance demands. With a large number of concurrent users, applications get prone to concurrency issues some of which are :
Database deadlocks
Database deadlocks occur when two or more transactions wait for each other to release a lock and neither proceeds unless the other releases the lock.
Eg – P1 requires additional resource R1 and is in possession of resource R2.
P2 requires additional resource R2 and is in possession of R1 and neither process can continue.
Livelock
A LiveLock is similar to a DeadLock, except that processes are not blocked forever and they are being processed constantly by the CPU, but the system is extremely slow.
Thus a primary difference between Deadlock and Livelock is the fact that Livelock responds after long time and a Deadlock never does.
Starvation
Starvation is also similar to a deadlock and happens in OS's multi-task situation, where a process is perpetually denied necessary resources. Without the required resources, the program will starve and may not be able to finish its task. If there are too many high-priority threads, a lower priority thread may be starved.
Priority Inversion
Sometimes a very high priority process cannot proceed since a low priority process doesn't release the resources. This leads to starvation of high priority process. This situation is called 'Priority Inversion'.
Consider a task L, which has a low priority as compared to task H which has a high priority. Both of these tasks require resource R. Consider that L starts running before H and acquires R. Now H has to wait until L releases resource R.
Everything works as expected up to this point, but problems arise when a new task M (which does not use R), which has medium priority, starts during this time. Since R is in use by L, H cannot run and is a blocked task. Since M is the highest priority unblocked task, it will be scheduled before L. Since L has been preempted by M, L cannot release R. So M will run till it is finished, then L will run - at least up to a point where it can relinquish R and then H will run. Thus, in the scenario above, a task with medium priority ran before a task with high priority, effectively giving us a priority inversion.
Race Conditions
Race condition is an undesirable situation when two threads access a shared variable at the same time. It begins with first thread reading a variable. After that a second thread reads the same value from same variable. Then both these threads perform their operations on the variable value, and they race to see which thread writes the value last to the shared variable. The value of the thread that writes its value last is retained, since the thread is writing the value over the previous thread's value.
Unintentional infinite loops
An infinite loop or unproductive loop happens in computer programs when loops never end. This happens either due to the loop having no terminating condition, having one that can never be met, or one that causes the loop to start again. Infinite loop causes programs to consume all of the processor time and that causes systems to become unresponsive.
Here is one type of error message that user gets to see on browser when concurrency issues appear –
Such concurrency issues if addressed during testing phase show very less occurrence in production and significantly less business and image loss to the organizations. Such issues can be reproduced by doing real time concurrency tests. Very few load testing tools support such tests and AgileLoad is one of them. User has to use Rendezvous commands in the scripts. These commands/statements synchronize users to start an action at exactly same time, thus creating excessive load on application and on database at the same instant. Huge number of processes and query executions happen concurrently and the application gets thoroughly tested for its concurrency and load demands. More technical details about ‘How to user Rendezvous commands?’ can be found here –
Thus with AgileLoad, performance test team can successfully reproduce concurrency issues and thus address failures to make application more stable and successful in live environment.
Swaraj Gupta