Networking Forums

Networking Forums > Computer Networking > Linux Networking > Load balancing using SCHED_RR

Reply
Thread Tools Display Modes

Load balancing using SCHED_RR

 
 
abhi147@gmail.com
Guest
Posts: n/a

 
      08-07-2006, 07:46 AM
Hi ,

I have one client and two servers . I need to send messages on two
servers randomly or alternately to balance the load .
I m using SCHED_RR to do that . I am facing following problems :

1. My client is sending the message to the 2nd server only when there
is a failover of first server.
2. when only 2nd server is running from the beginning and 1st server
hasn't started at all , Client gives an error for sending and receiving
bytes .

The Client program is :
int main()
int i;
pthread_t threads[2];
pthread_attr_t attr_1, attr_2;
struct sched_param param_1, param_2;

pthread_attr_init(&attr_1);
pthread_attr_init(&attr_2);
pthread_attr_setinheritsched(&attr_1, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setinheritsched(&attr_2, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setdetachstate(&attr_1, PTHREAD_CREATE_JOINABLE);
pthread_attr_setdetachstate(&attr_2, PTHREAD_CREATE_JOINABLE);

/* set thread priority randomly and scheduling policy SCHED_RR for
socket_1 */
param_1.sched_priority = rand();
pthread_attr_setschedparam(&attr_1, &param_1);
pthread_attr_setschedpolicy(&attr_1, SCHED_RR);

pthread_create(&threads[0], &attr_1, send_1, NULL);

/* set thread priority randomly and scheduling policy SCHED_RR for
low thread */
param_2.sched_priority = rand();
pthread_attr_setschedparam(&attr_2, &param_2);
pthread_attr_setschedpolicy(&attr_2, SCHED_RR);

pthread_create(&threads[1], &attr_2, send_2, NULL);

for (i = 0; i < 2; i++)
{
pthread_join(threads[i], NULL);
}

printf ("Main(): Waited on 2 threads. Done.\n");

/* Clean up and exit */
pthread_attr_destroy(&attr_1);
pthread_attr_destroy(&attr_2);
pthread_exit(NULL);

}

void send_1(void *arg)
{
socket creation on port 2007
and sending the message to Server at port 2007
}
void send_2(void *arg)
{
socket creation on port 2008
and sending the message to Server at port 2008
}

Can anyne please tell me how load balancing can be achieved using
SCHED_RR. ??

Thanks !

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
load balancing Fixer Windows Networking 2 11-08-2007 06:37 AM
NLB on DC's for DNS load balancing BSweeney Windows Networking 10 07-25-2007 02:48 PM
NIC Load Balancing Chicho Windows Networking 2 02-20-2004 06:55 PM
FTP Load Balancing Windows Networking 0 01-27-2004 02:13 AM
Load Balancing Alex Windows Networking 0 12-22-2003 11:59 PM



1 2 3 4 5 6 7 8 9 10 11