[Gluster-devel] Question about random and rr scheduler
Craig.Tierney at noaa.gov
Tue Mar 4 15:39:54 UTC 2008
Amar S. Tumballi wrote:
> On Mon, Mar 3, 2008 at 4:27 PM, Craig Tierney <Craig.Tierney at noaa.gov>
>> I setting up Gluster (1.3.7) with two servers. I first
>> tried configuring the clients as round-robin (rr). When I try and write
>> to the filesystem for the first time, all of the files go
>> to the first brick. Subsequent writes will alternate between
>> the two bricks. When I try random, the first file is always
>> created on the first brick. Subsequent writes always go to
>> the first brick (never the second).
> As the name suggests 'random' scheduler just calls random() and it just does
> % with the number of clients. Hence, not much control over it by user side
> right now.
>> What I want is round-robin, or a working random. However,
>> for round-robin to work for me, I need the chosen server to
>> be random, not always the first one.
>> In the long-term, it wouldn't really matter because everything
>> would average out. However, I am creating filesystems that
>> will be temporary, so I need the right behavior in the short term.
>> Should random do what I need? Should I look in the code
>> and see how to get the Round-Robin schedule to start with
>> a random index?
> Just initialize index variable in rr scheduler to start with a random
> number. should not be much of a work..
I modified the rr scheduler to use a random index at initialization.
I like the behavior much better.
--- glusterfs-1.3.7/scheduler/rr/src/rr.c 2007-10-05 05:57:12.000000000 +0000
+++ ../glusterfs-1.3.7/scheduler/rr/src/rr.c 2008-03-04 14:53:10.191215255 +0000
@@ -49,7 +49,10 @@
trav_xl = trav_xl->next;
rr_buf->child_count = index;
- rr_buf->sched_index = 0;
+ srandom(time(NULL)); /* Initialize the seed */
+ rr_buf->sched_index = random()%index; /* Randomize the initial index */
rr_buf->array = calloc (index + 1, sizeof (struct rr_sched_struct));
trav_xl = xl->children;
index = 0;
Craig Tierney (craig.tierney at noaa.gov)
More information about the Gluster-devel