One Rails App - thousands of vHosts pointing to it

0 views
Skip to first unread message

Jeff Pritchard

unread,
Jul 27, 2008, 6:20:57 PM7/27/08
to rubyonrails...@googlegroups.com
I have a new client with a project that will be organized a lot like
"blogspot.com" (aka blogger) where there are a large number of content
providers, and each one of those people gets their own subdomain off the
main "blogger.com" domain.

The obvious (though perhaps not the best) way to do this is to have the
Rails app create a new virtual host block in the apache config for each
one of these content providers and their subdomain.

My concern is that the vHosts in Apache were probably designed as a way
to have two or three, maybe a half dozen or more separate things running
on the server...but a few thousand?!?!?!?!

Does anyone have any experience putting thousands of vHosts into an
apache config? Does this scale that high without creating some sort of
stability or speed problems? Do you need gobs 'o RAM for the apache
server to keep track of all those vHosts? Does it take hours for the
Apache server to start up?

Does anyone have a suggestion for a much better way to do this? Am I
re-inventing an existing wheel?

many thanks for your wisdom.

thanks,
jp
--
Posted via http://www.ruby-forum.com/.

Shawn Balestracci

unread,
Jul 27, 2008, 7:06:01 PM7/27/08
to rubyonrails...@googlegroups.com
You can use a wildcard in apache's configuration
ServerName blogger.com
ServerAlias *.blogger.com

Then in rails you can access the subdomain(s) via request.subdomains

A similar approach is spelled out at:
http://wiki.rubyonrails.org/rails/pages/HowToUseSubdomainsAsAccountKeys

Jeff Pritchard

unread,
Jul 27, 2008, 8:42:54 PM7/27/08
to rubyonrails...@googlegroups.com
Shawn Balestracci wrote:
> You can use a wildcard in apache's configuration
> ServerName blogger.com
> ServerAlias *.blogger.com
>
> Then in rails you can access the subdomain(s) via request.subdomains
>
> A similar approach is spelled out at:
> http://wiki.rubyonrails.org/rails/pages/HowToUseSubdomainsAsAccountKeys
>
> On Sun, Jul 27, 2008 at 3:20 PM, Jeff Pritchard

Very cool! Thanks Shawn!

I wonder, can you do *.* and also get the domain?

(naturally, he wants to allow some customers to register a domain name
and use that as well)

thanks again!

Tom Copeland

unread,
Jul 27, 2008, 8:52:27 PM7/27/08
to rubyonrails...@googlegroups.com

On Mon, 2008-07-28 at 00:20 +0200, Jeff Pritchard wrote:
> My concern is that the vHosts in Apache were probably designed as a way
> to have two or three, maybe a half dozen or more separate things running
> on the server...but a few thousand?!?!?!?!
>
> Does anyone have any experience putting thousands of vHosts into an
> apache config? Does this scale that high without creating some sort of
> stability or speed problems? Do you need gobs 'o RAM for the apache
> server to keep track of all those vHosts? Does it take hours for the
> Apache server to start up?

On RubyForge we have over 6000 virtual hosts configured inside one
Apache server and haven't seen any problems. Restarts take 10-15
seconds. The machine has 8 GB of RAM, but Apache doesn't use much of it
since the virtual hosts are mostly static content.

Yours,

Tom


Tom Copeland

unread,
Jul 27, 2008, 8:53:10 PM7/27/08
to rubyonrails...@googlegroups.com

That said, I think Shawn's suggestion is probably the way to go,

Yours,

Tom


Jeff Pritchard

unread,
Jul 27, 2008, 9:01:07 PM7/27/08
to rubyonrails...@googlegroups.com

Thanks Tom. Interesting that it can handle that many with ease.

May use Shawn's method for the subdomains and vHosts for all of the
user-registered domains.

Reply all
Reply to author
Forward
0 new messages