couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Filipe Manana (JIRA)" <>
Subject [jira] Commented: (COUCHDB-855) New host manager
Date Thu, 20 Jan 2011 23:43:46 GMT


Filipe Manana commented on COUCHDB-855:

Yep, I agree it's really late to -1 it. I never noticed before about this gen_server synchronous
Nevertheless the -1 is only because of this specific implementation. The features are unquestionably
useful and +1 for that.

Like Paul said, it would be interesting to know how much time is spent fetching the configs
from couch_config, doing the necessary parsing and matchings, etc. I think to have a good
idea about it something like this is ok:

T0 = erlang:now(),
% do the vhost stuff
T1 = erlang:now(),
io:format("time spent doing vhost stuff:  ~pus", [timer:now_diff(T1, T0)])

Measuring the whole time of the request, in a similar fashion, grabbing T0 at the very beginning
of the request handler loop and T1 at the very end would allows us to have a better idea of
the relative time spent doing the vhosts stuff. Basically similar to what I did for COUCHDB-913

I would say a cache is only worth if those values are significant, maybe if they're > 5
- 20ms or > 5 - 10% of the total time spent for the request. Cache lookup times might not
be much lower than the time spent doing the vhosts stuff (independently of having the cache
implemented with a protected/public ets or a gen_server).

> New host manager
> ----------------
>                 Key: COUCHDB-855
>                 URL:
>             Project: CouchDB
>          Issue Type: Improvement
>    Affects Versions: 1.1
>            Reporter: Benoit Chesneau
>            Assignee: Benoit Chesneau
>             Fix For: 1.1
>         Attachments: 0001-New-vhost-manager.-allows-dynamic-add-of-vhosts-with.patch,
> New vhost manager. allows dynamic add of vhosts without restart, wildcard in vhost and
specific functions in erlang by kind of domain. It also fix issue in etap test (160) .
> Find attached to this ticket the patch. It is also available in my github repo :
> more details :
> This gen_server keep state of vhosts added to the ini and try to
> match the Host header (or forwarded) against rules built against
> vhost list. 
> Declaration of vhosts take place in the configuration file :
> [vhosts]
> = /example
> * = /example
> The first line will rewrite the rquest to display the content of the
> example database. This rule works only if the Host header is
> '' and won't work for CNAMEs. Second rule on the other hand
> match all CNAMES to example db. So or
> will work.
> The wildcard ('*') should always be the last in the cnames:
>      "* = /"  will match all cname on top of db
> examples to the root of the machine. (for now no rewriting is
> possible).
> By default vhosts redirection is handle by the function
> couch_httpd_vhost:redirect_to_vhost, but you could pass per vhost a
> specific function :
>      "*" = {Module, Func}"
> The function take the Mochiweb Request object and should return a new
> Mochiweb Request object.
> You could also change the default function to handle request by
> changing the setting `redirect_vhost_handler` in `httpd` section of
> the Ini:
>       [httpd]
>       redirect_vhost_handler = {Module, Fun}
> The function take 2 args : the mochiweb request object and the target
> path. 

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message