Fastest hashing algorithm?

H

howa

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.
 
M

Matt Humphrey

| 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?

I would assign each incoming user to the least busy server.
 
T

Tom Hawtin

howa said:
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...

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
 
M

Mark Space

Matt said:
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.
 
R

Roedy Green

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.
 
H

howa

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..
 
E

EricF

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.

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

Eric
 
T

Twisted

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...)?
 
R

Roedy Green

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top