-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Can Hibernate fix this synchronization/scalability problem?
PostPosted: Thu Mar 16, 2006 1:33 pm 
Newbie

Joined: Thu Mar 16, 2006 1:12 pm
Posts: 10
Hello,

I currently have an application that does not use Hibernate - and we are thinking of porting it to Hibernate for a couple reasons:
1. because it will give us more database independence
2. because it will solve a scalability issue we have with our current application.

While I *DO* believe that Hibernate can help us with our database independence issue, I do *NOT* believe it can solve our scalability issue - even though our application is really simple. I would love to be wrong on this.

Our server application is incredibly simple - it hands out tasks to clients. Each task has an id (primary key), a name, and an owner (foreign key to a client table). Everytime a client contacts the server it requests the "first available task" - where the first available task is defined as the task with the lowest primary key that has a null value in the owner column. The server application grabs this task, then updates that task to show that it is now owned by the calling client. The server application must make sure that no two clients are ever given the same task. Simple.

In order to implement this behavior, our current application LOCKS the task **TABLE**, finds the first available task (as defined above), updates that task to indicate the new owner based on the calling client, then commits the update - releasing the TABLE lock. This TABLE lock prevents another calling client from being given the same task. The system works very well - until we add a bazillion clients. At this point the TABLE locking we are doing is slowing the system down too much.

It seems to me that the model above has an inherent flaw in it that cannot be "overcome" by using Hibernate, Entity beans or any other technology. It seems that any technology placed "on top of" this model still is "database bound"...? In other words, the only solution that I can see to this particular problem, in the end, is serialization of access to the task table - hence the table lock.

Am I missing something obvious here? Can Hiberate really help with the performance with this model? Or do I just have to change the model itself? (I'm not sure what that model would look like). I need to manager customer expectations on this. They are all under the impression that if I just use Entity beans or Hibernate in a clustered environment, that we can just throw another server into the cluster if performance is lagging. I don't think so...

Any thoughts you might have would be greatly appreciated.

BTW: So far I'm finding my experimenting with Hibernate to be extremely fun.

-john


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 3:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
this is a user question not for the book ;)

(anyway: look into optimistic locking and only hand out the task if it succeeds in updating)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Past solution I used
PostPosted: Wed Mar 29, 2006 12:29 am 
Newbie

Joined: Tue Jan 06, 2004 3:15 pm
Posts: 3
I had a similar system and solved it via sql.

rather then lock the table, just execute and update query,
1) select id from job where owner=null order by id
2) update job set owner='MY CLIENT NAME' where id=? and owner=null

the update will only update one row if the owner record is null, and that can only happen once.

good luck


Top
 Profile  
 
 Post subject: Past solution I used
PostPosted: Wed Mar 29, 2006 12:35 am 
Newbie

Joined: Tue Jan 06, 2004 3:15 pm
Posts: 3
I had a similar system and solved it via sql.

rather then lock the table, just execute and update query,
1) select id from job where owner=null order by id
2) update job set owner='MY CLIENT NAME' where id=? and owner=null

the update will only update one row if the owner record is null, and that can only happen once.

good luck


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.