drb question

J

Joe Van Dyk

class Player
def initialize
@player_attributes = { :some_key => "some value", :another_key =>
"another_value" }
@player_id = 2
end
end

Say there's 100 Player objects running. They're stored in an array.

DRb clients need access to the data stored in each Player. The Player
objects get updated every second with new data.

What's the best way of doing so? @player_attributes contains about
20-30 keys and values, if it matters.

Thanks,
Joe
 
J

Joe Van Dyk

class Player
def initialize
@player_attributes = { :some_key => "some value", :another_key =>
"another_value" }
@player_id = 2
end
end

Say there's 100 Player objects running. They're stored in an array.

DRb clients need access to the data stored in each Player. The Player
objects get updated every second with new data.

What's the best way of doing so? @player_attributes contains about
20-30 keys and values, if it matters.

Thanks,
Joe

Oh, and the DRb clients (there's probably only one or two of them at a
time) have to use all the values in each Player's attribute list every
second or so.
 
I

Ilmari Heikkinen

Oh, and the DRb clients (there's probably only one or two of them at a
time) have to use all the values in each Player's attribute list every
second or so.

Depends on the amount of data and the bandwidth of the link. If the
attributes are roughly 50 bytes per attribute, the player list takes
150KB of space, and requires about 1.5Mbps connection to wholly update
every second. Twice that for two clients.

If your server can sustain the 3Mbps, you can just send the player
array over.

If the link is slow or you don't want to use that much bandwidth, you
could use some diff algorithm to send only the values that have
changed.

Anyhow, you probably want to minimize the amount of DRb calls, as these
introduce some overhead. So send the changeset with a single call.

Maybe this was of assistance, maybe not :-I

Cheers,
Ilmari Heikkinen
 
J

Joe Van Dyk

Depends on the amount of data and the bandwidth of the link. If the
attributes are roughly 50 bytes per attribute, the player list takes
150KB of space, and requires about 1.5Mbps connection to wholly update
every second. Twice that for two clients.

If your server can sustain the 3Mbps, you can just send the player
array over.

If the link is slow or you don't want to use that much bandwidth, you
could use some diff algorithm to send only the values that have
changed.

Anyhow, you probably want to minimize the amount of DRb calls, as these
introduce some overhead. So send the changeset with a single call.

Maybe this was of assistance, maybe not :-I

The player attributes aren't quite 50bytes.. probably a max of 10 or so.

I decided to get rid of DRbUndumped and just Marshal the array of
Players and send it over.

Can someone explain why I couldn't just return the array of Players
through DRb, and why I had to Marshal the array? I'm confused on this
point. If I returned the array, then I got an array of DRbUnknown
objects (I think, I tried it a couple days ago). But If I marshaled
the array and returned that string and then used Marshal.load, it
worked fine.
 

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

No members online now.

Forum statistics

Threads
474,171
Messages
2,570,935
Members
47,472
Latest member
KarissaBor

Latest Threads

Top