El 09-12-2010, a las 0:56, Leif Hedstrom escribió: > On 12/08/2010 08:45 PM, Leif Hedstrom wrote: >> On 12/08/2010 08:36 PM, Victor Lucero wrote: >>> Hi. >>> Im writing a plugin to implement Load balancing. im facing some problem >>> doing it with a remap plugin because its looks like when i alter new_host >>> its also alter the "host" header in the http petition (and i dont want that) >>> I need a way to alter the conection to Original Server and change the ip(so >>> i can select between the servers in the pool). but there is no hook in this >>> step. >> >> >> You have two options: > > > Well, there's a third option, I meant to say there are "two options" if you > want to do this as a remap plugin (which makes a fair amount of sense, since > you might want to easily configure this plugin per remap rule). > > The third option is to use "trunk", which has a few changes to the hooks and > APIs. In particular, there are two useful hooks (one is merely renamed, but > still): > > TS_HTTP_PRE_REMAP_HOOK > TS_HTTP_POST_REMAP_HOOK > >
the problem in the remap plugin is that not every request end in OS and the balance will not get homogeneus. > In addition, there's a new, very useful API (when running as a reverse proxy > only): > > tsapi TSReturnCode TSSkipRemappingSet(TSHttpTxn txnp, int flag); > > > All three of my "suggestions" probably suffers from the fact that changing > the destination "url" also affects the cache key (if the content is > cacheable). In most cases, that would be undesirable, so you should also look > into using this API to control the cache key: > > tsapi TSReturnCode TSCacheUrlSet(TSHttpTxn txnp, const char *url, int > length); > > > As a side note, for real load balancing, we need a way to intercept all DNS / > hostDB lookups in a plugin. So, you'd do something like > > map http://www.example.com/ http://real.example.com/ > > > and when real.example.com is looked up in our hostDB / DNS (on every > request), you would intercept it with a plugin (new hook required, there's no > way to do this now afaik) that allows you to return an IP based on your own > code. It's unclear to me right now how such a hook would interact with > hostDB, and the existing code we have for marking IPs as down etc. (i.e. it's > important for the core to communicate connect failures to a plugin in a new > hook like this). It's something we should noodle about (I'll file a bug > later), it'd be great to get core changes in before v3.0. > > Cheers, > editing the response of the dns will do a better trick , also adding some health test code (in the plugin. nothing really complicated) and adding a hook near the connection to the OS for stats (also needed if i want to implement least weight algorithm.) thanks. > -- leif > -Victor Lucero.