Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

web application concurrent access

 
jacob deiter
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A web application is connected to a database (for example oracle),if many user access the web application and try to insert data in same table at time ,

1) how the application behaves?

 
Paul Clapham
Sheriff
Pie
Posts: 20715
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends. Do you have a more specific question? Yours really doesn't provide any basis for a meaningful answer.
 
Alpesh Padra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to design your application in such a way that concurrent db access should not happen.

Make you connection class thread-safe or use connection pooling. so that at a time only specific number of user will going to access your DB.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to design your application in such a way that concurrent db access should not happen.

There's nothing wrong with concurrent DB access. Simultaneous inserts into a table pose no particular issue (simultaneous updates do). Any DB write access should be guarded by transactions, of course.

Make you connection class thread-safe or use connection pooling. so that at a time only specific number of user will going to access your DB.

All code must be thread-safe, and DB transactions must be used. Then it doesn't matter if there are 2 simultaneous users or 2000.
 
Scott Bravo
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All code must be thread-safe, and DB transactions must be used. Then it doesn't matter if there are 2 simultaneous users or 2000.


I guess in this case Application response time would increase if it is 2000 users ... Best is make only that part of code as thread safe which is critical for transactions.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott Bravo wrote:Best is make only that part of code as thread safe which is critical for transactions.

No. *All* code must be thread-safe. That 2000 users put a higher strain on a system than 2 users goes without saying, but that's not a concurrency issue, that's a load/performance issue.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
+1

@Scott: don't confuse "thread-safe" with "having to do something". For example, a method that accesses no data outside of its own state is thread-safe by definition. Issues arise only when accessing state that other threads may also access.
 
jacob deiter
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

if the user access the same table ,I do not want to make them wait till the current user release the Lock,that is ,all the user update same table as they wish.

How to handle this scenario?


 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jacob deiter wrote:Hi all

if the user access the same table ,I do not want to make them wait till the current user release the Lock,that is ,all the user update same table as they wish.

How to handle this scenario?




Why would you lock the table for an update? Locks in databases happen at a lower level than the table itself - can't you just rely on this out the box behaviour?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what transactions are for.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic