Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

Fastest hashing algorithm?

Thread view: 
howa - 12 Jun 2007 19:40 GMT
conside an example like...

you have 5 Servers, one user queue, and you want to distribute the
users to these 5 servers, users come at different time, assume truely
random

a simple algorithm is to use Random to generate index 0..4 and assign
the server.

but think about it, if user come at random, why you need to use radnom

i don't know the implementation of Random, but seems a little bit
overkill the requirements...

a simple approach is to `mod` the current time and assign the server,
what do you abt this suitation?

thanks.
Matt Humphrey - 12 Jun 2007 19:44 GMT
| conside an example like...
|
[quoted text clipped - 12 lines]
| a simple approach is to `mod` the current time and assign the server,
| what do you abt this suitation?

I would assign each incoming user to the least busy server.
Mark Space - 13 Jun 2007 05:47 GMT
> I would assign each incoming user to the least busy server.

I'm with Matt.  I'm sure there's a simple way to get the load from a
server, depending on your OS.

A simpler interim solution might just be to keep track of how many user
connections you have currently to each server.  (This assumes users
leave their connection "open" I guess.)  Assign new users to the server
with the least number of users connected.
howa - 13 Jun 2007 16:53 GMT
> I would assign each incoming user to the least busy server.

I agree, but sometime checking the server status introduce some
overheads.

e.g. the JSP page need to store all the servers status into a
persistent storage and check for every requests.

So that's why many people still using DNS round-robin kind of for load
balacing..
Tom Hawtin - 12 Jun 2007 19:56 GMT
> you have 5 Servers, one user queue, and you want to distribute the
> users to these 5 servers, users come at different time, assume truely
[quoted text clipped - 7 lines]
> i don't know the implementation of Random, but seems a little bit
> overkill the requirements...

Handling a user request is a relatively *HUGE* operation. Think how many
cycles that will cost you, and guess how much creating a psuedo-random
number costs.

You can easily look at the implementation of Random. It's in the src.zip
file in your JDK. Notice that (in recent versions) it doesn't so much as
use a lock. Indeed, you could allocate round-robin. Just use a
java.util.concurrent.atomic.AtomicInteger, and no need for locks.

Tom Hawtin
Roedy Green - 13 Jun 2007 06:31 GMT
>you have 5 Servers, one user queue, and you want to distribute the
>users to these 5 servers, users come at different time, assume truely
>random

Before you waste effort optimising, you must measure the time taken to
make sure you are chewing at the bottleneck.

Almost certainly optimising this will have no noticeable effect unless
you were doing task scheduling inside the OS.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
EricF - 14 Jun 2007 05:24 GMT
>>you have 5 Servers, one user queue, and you want to distribute the
>>users to these 5 servers, users come at different time, assume truely
[quoted text clipped - 5 lines]
>Almost certainly optimising this will have no noticeable effect unless
>you were doing task scheduling inside the OS.

I missed the original post but I do agree with Roedy. Are all the user tasks
similar in resource usage and run time?

Eric
Twisted - 14 Jun 2007 06:01 GMT
> I missed the original post but I do agree with Roedy. Are all the user tasks
> similar in resource usage and run time?

And are all the servers comparable in capacity (similar RAM, similar
CPU, similar bandwidth...)?
Roedy Green - 15 Jun 2007 10:51 GMT
>you have 5 Servers, one user queue, and you want to distribute the
>users to these 5 servers, users come at different time, assume truely
>random

why would random do better than round robin?

If you want to get clever, I think you need a measure of who is most
lightly loaded and give the new user to that server.

On Vista there is a measure of disk and CPU time utilisation that even
desk gadgets can get hold of.  You would need a little JNI to gather
those stats for your servers.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.