Discussion:
Pool
(too old to reply)
Leandro Delamare
2004-11-30 17:45:26 UTC
Permalink
Hello group..

I Have a problem,
Im my program I have one pool.QueueRequest in 3 server
and this return for me the faster server.

But this don't work with proxy.. How can I make this work with proxy
Have no problem in change this code to use a function of WiniNet

Please, someone can help me..
Regards

The code is :

CThreadPool<CompanySServer> pool;

bool ret = true;

InterlockedExchange(&EzNav_lCurrId, -1);
InterlockedExchange(&EzNav_lServer, 0);
EzNav_IndexId = NULL;
EzNav_SSeek = true;

EzNav_Servers.RemoveAll();

HRESULT hr = pool.Initialize((void*)321, THREADPOOL_SIZE);

if ( SUCCEEDED( hr ) )
{
int timeout = 0;

pool.QueueRequest( (CompanySServer::RequestType)
"http://server1.company.com" );
pool.QueueRequest( (CompanySServer::RequestType)
"http://server2.company.com" );
pool.QueueRequest( (CompanySServer::RequestType)
"http://server3.company.com" );

while (Company_lServer != 2 && timeout++ < 100)
{
Sleep(500);
}

pool.Shutdown();
}
Malcolm Ferguson
2004-12-02 13:20:45 UTC
Permalink
Why not offload this responsibility to the server? The cheapest way
would be with round-robin DNS. You can scale it with a load-balancer,
which will also allow you to maintain per client sessions to keep them
on the same server if you need server-side state. Latency and server
responsiveness can change from second to second. If you have a lot of
clients and they all decide in one go that the same server is the
fastest... they could affect it by all connecting to it at the same
time. It's also much easier to update your logic if you do this server
side.

Now if your servers are geographically distributed and you're trying to
contact the nearest one... I'd have to think about that. What about
checking the TTL on packets and choosing a server the fewest number of
hops away? Probably not very reliable. Perhaps put the logic on the
server and do a redirect to a different sub-domain...

Malc
Post by Leandro Delamare
Hello group..
I Have a problem,
Im my program I have one pool.QueueRequest in 3 server
and this return for me the faster server.
But this don't work with proxy.. How can I make this work with proxy
Have no problem in change this code to use a function of WiniNet
Please, someone can help me..
Regards
CThreadPool<CompanySServer> pool;
bool ret = true;
InterlockedExchange(&EzNav_lCurrId, -1);
InterlockedExchange(&EzNav_lServer, 0);
EzNav_IndexId = NULL;
EzNav_SSeek = true;
EzNav_Servers.RemoveAll();
HRESULT hr = pool.Initialize((void*)321, THREADPOOL_SIZE);
if ( SUCCEEDED( hr ) )
{
int timeout = 0;
pool.QueueRequest( (CompanySServer::RequestType)
"http://server1.company.com" );
pool.QueueRequest( (CompanySServer::RequestType)
"http://server2.company.com" );
pool.QueueRequest( (CompanySServer::RequestType)
"http://server3.company.com" );
while (Company_lServer != 2 && timeout++ < 100)
{
Sleep(500);
}
pool.Shutdown();
}
Leandro Delamare
2004-12-06 18:08:02 UTC
Permalink
I make this only to make a round from my servers,
One time a day the program need to run this function only to divide the
traffic.
is not a high level of information, but I realy need a code to make this ?

Can you help me with the code ?
regards
Why not offload this responsibility to the server? The cheapest way would
be with round-robin DNS. You can scale it with a load-balancer, which
will also allow you to maintain per client sessions to keep them on the
same server if you need server-side state. Latency and server
responsiveness can change from second to second. If you have a lot of
clients and they all decide in one go that the same server is the
fastest... they could affect it by all connecting to it at the same time.
It's also much easier to update your logic if you do this server side.
Now if your servers are geographically distributed and you're trying to
contact the nearest one... I'd have to think about that. What about
checking the TTL on packets and choosing a server the fewest number of
hops away? Probably not very reliable. Perhaps put the logic on the
server and do a redirect to a different sub-domain...
Malc
Post by Leandro Delamare
Hello group..
I Have a problem,
Im my program I have one pool.QueueRequest in 3 server
and this return for me the faster server.
But this don't work with proxy.. How can I make this work with proxy
Have no problem in change this code to use a function of WiniNet
Please, someone can help me..
Regards
CThreadPool<CompanySServer> pool;
bool ret = true;
InterlockedExchange(&EzNav_lCurrId, -1);
InterlockedExchange(&EzNav_lServer, 0);
EzNav_IndexId = NULL;
EzNav_SSeek = true;
EzNav_Servers.RemoveAll();
HRESULT hr = pool.Initialize((void*)321, THREADPOOL_SIZE);
if ( SUCCEEDED( hr ) )
{
int timeout = 0;
pool.QueueRequest( (CompanySServer::RequestType)
"http://server1.company.com" );
pool.QueueRequest( (CompanySServer::RequestType)
"http://server2.company.com" );
pool.QueueRequest( (CompanySServer::RequestType)
"http://server3.company.com" );
while (Company_lServer != 2 && timeout++ < 100)
{
Sleep(500);
}
pool.Shutdown();
}
Malcolm Ferguson
2004-12-02 13:24:14 UTC
Permalink
BTW, if you're going to do this, you should consider doing at least two
request per server. There's a certain amount of over-head just setting
things up. Ever notice how ping commands often indicate high latency on
the first packet, but all subsequent attempts are quicker? Don't forget
to consider DNS latency. A fast server might appear slower if the first
name look-up takes a long time.

Malc
Post by Leandro Delamare
Hello group..
I Have a problem,
Im my program I have one pool.QueueRequest in 3 server
and this return for me the faster server.
But this don't work with proxy.. How can I make this work with proxy
Have no problem in change this code to use a function of WiniNet
Please, someone can help me..
Regards
CThreadPool<CompanySServer> pool;
bool ret = true;
InterlockedExchange(&EzNav_lCurrId, -1);
InterlockedExchange(&EzNav_lServer, 0);
EzNav_IndexId = NULL;
EzNav_SSeek = true;
EzNav_Servers.RemoveAll();
HRESULT hr = pool.Initialize((void*)321, THREADPOOL_SIZE);
if ( SUCCEEDED( hr ) )
{
int timeout = 0;
pool.QueueRequest( (CompanySServer::RequestType)
"http://server1.company.com" );
pool.QueueRequest( (CompanySServer::RequestType)
"http://server2.company.com" );
pool.QueueRequest( (CompanySServer::RequestType)
"http://server3.company.com" );
while (Company_lServer != 2 && timeout++ < 100)
{
Sleep(500);
}
pool.Shutdown();
}
Continue reading on narkive:
Loading...