Load balancing using SCHED_RR



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 !

.



Relevant Pages

  • Re: Unable to print to networked printer - get access denied messa
    ... Check the permissions on the server assuming the client has a true RPC ... How is the Standard TCP/IP port configured for the device? ...
    (microsoft.public.windowsxp.print_fax)
  • Re: interfaces lo:1 lo:2 lo:3? (for remote ssh tunnels)
    ... That's the problem tunneling (port forwarding) solves. ... >>can't get past the client firewall. ... > I don't understand why the server would be making the ... server initiates another connection to the client -- in this ...
    (Debian-User)
  • Re: .Net Scalability problem
    ... LoadRunner will peak out a server with a few virtual users. ... To get an idea of load, ... Fire off the test client and watch the number of ... > So I think that the MTC generate concurrent connection and per ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Remote Connection Issue
    ... through port number 3389 and a workstation on the LAN through port number ... I understand that you want to allow a LAN client ... and you have configured server publishing rule ... > By default Terminal Server and Windows 2000 Terminal Services uses TCP ...
    (microsoft.public.windows.server.sbs)
  • Re: RealVNC
    ... Default listening port for RealVNC server that runs on the machine on which ... Then there is default Java listening port on port 5800 on the client machine ...
    (microsoft.public.windows.server.sbs)