From: Joe Van Dyk Date: 2005-05-01T01:43:36+09:00 Subject: Re: drb question On 4/29/05, Ilmari Heikkinen wrote: > > On 30.4.2005, at 03:43, Joe Van Dyk wrote: > > > On 4/29/05, Joe Van Dyk wrote: > >> 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. > > > > 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.