# Running a huge site

**URL:** <https://www.ruby-forum.com/t/running-a-huge-site/108421>\
**Category:** Ruby\
**Created:** [July 3, 2007, 10:58am UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421 "2007-07-03T10:58:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee59a6/32.png) [@zaki](https://www.ruby-forum.com/u/zaki)\
**Post date:** [July 3, 2007, 10:58am UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421/1 "2007-07-03T10:58:50Z")

</div>

Hi everyone,

We are running apache with eruby to server .rhtml files. Every apache  
process loads eruby, thus every access makes a huge dent on memory. We  
have tried using mod\_ruby, and while memory usage got better, we had  
strange errors and performance didn’t increase either. There is no  
documentation on the web (i don’t regard a non-functioning forum and a  
jotted down bunch of notes from [modruby.net](http://modruby.net) documentation) and quite  
frankly noone seems too eager to share information about this.

Our config is  
AddType application/x-httpd-eruby .rhtml  
Action application/x-httpd-eruby /cgi-bin/eruby

Tried mod\_ruby with this too  
RubyRequire apache/eruby-run  
RubyRequire apache/erb-run  
RubyRequire eruby  
\<Files \*.rhtml\>  
SetHandler ruby-object  
RubyHandler Apache::ERubyRun.instance

My company has just lost a server recently due to the high load (~8 per  
second, WTF?) Former company (with PHP and Java), we used to serve  
hundreds of pages and neither language is very light.

We are not using rails, and unless rails is significantly changed to  
accommodate for japanese keitai sites, that is not going to change. FCGI  
is not entirely out of the question (although would mean a complete  
rewrite of the sites probably).

Our options are: Eruby (is this even maintained anymore?), Mod\_ruby (is  
this working well, is it performant?), FCGI (might work). What’s not an  
option: Mongrel (no ssl breaks the deal), Rails, Do nothing (either we  
can make ruby make faster and more scalable, or bye-bye ruby -  
personally, i love this language, would be a heartbreak to see it go,  
but business is business).

Any insights?

Zaki

---

<div class="post-metadata">

**Author:** ![zaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee59a6/32.png) [@zaki](https://www.ruby-forum.com/u/zaki)\
**Post date:** [July 3, 2007, 11:22am UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421/2 "2007-07-03T11:22:39Z")

</div>

On 7/3/07, Zoltan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Our config is  
>   
> Our options are: Eruby (is this even maintained anymore?), Mod\_ruby (is  
> this working well, is it performant?), FCGI (might work). What’s not an  
> option: Mongrel (no ssl breaks the deal), Rails, Do nothing (either we  
> can make ruby make faster and more scalable, or bye-bye ruby -  
> personally, i love this language, would be a heartbreak to see it go,  
> but business is business).
> 
> Any insights?

Just blind hints:

- FGCI will help you with the overhead of starting interpreter each  
time (maybe mod ruby will do that as well)

- erubis is an ERB implementation in C that claims is much faster

- caching parsed templates can help a lot as in my experiences with  
plain ERB parsing takes a significant part of running time (you may  
use ruby-prof to find out whether it is the case). In my case, with  
caching parsed templates time of a script dropped from 12 seconds to 6  
(it was a standalone script, not a webpage). Obviojusly, it depends on  
how many templates do you have, and how many times they are rendered.

- you should use mongrel behind something (apache, nginx,…) anyway,  
so maybe you can work around ssl somehow.

Take these as ideas to look at, that might or might not be helpful. I  
have not tested any of them, I even do not develop nor deploy webpages  
😉

J.

---

<div class="post-metadata">

**Author:** ![zaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee59a6/32.png) [@zaki](https://www.ruby-forum.com/u/zaki)\
**Post date:** [July 3, 2007, 12:24pm UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421/3 "2007-07-03T12:24:52Z")

</div>

Hi Zoltan,

I’m using a mongrel\_cluster behind an apache load balancer which works  
fine with SSL. Then you can do alot of performance stuff in Apache  
beforehand.  
If you want more performance think about using erubis instead of  
plain/old erb and imho you’re not forced to use the big ActiveRecord  
when you’re using Rails. Personally I like Sequel but you can do your db  
stuff with OG too.  
You can also define different database connections for your models which  
disburdens your DB server.

… ahhh, there are quite some performance tips for Rails out there. Or  
you use Camping or Merb which are significantly smaller, and so on…

Cheers  
Florian

---

<div class="post-metadata">

**Author:** ![zaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee59a6/32.png) [@zaki](https://www.ruby-forum.com/u/zaki)\
**Post date:** [July 4, 2007, 7:55pm UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421/4 "2007-07-04T19:55:41Z")

</div>

On Jul 3, 2007, at 1:58 AM, Zoltan D. wrote:

> option: Mongrel (no ssl breaks the deal), Rails, Do nothing (either we  
> can make ruby make faster and more scalable, or bye-bye ruby -  
> personally, i love this language, would be a heartbreak to see it go,  
> but business is business).

From what I’ve seen concerning performance issues, Apache proxying  
to a cluster of mongrels is the way to go. Your apache can handle the  
SSL connection and can load balance across any number of mongrel  
instances across any number of machines. Mongrel itself does not  
handle SSL, but put them behind your firewall and you’re set.

Do you have hardware limitations? (i.e. only one server etc?)

Another option that I had briefly experimented with was using a  
Lighttpd-fcgi stack that did way better than Apache-fcgi, although I  
haven’t seen much talk of Lighttpd lately.

[http://www.lighttpd.net/](http://www.lighttpd.net/)

–  
Craig B.

AIM: kreiggers

---

<div class="post-metadata">

**Author:** ![zaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee59a6/32.png) [@zaki](https://www.ruby-forum.com/u/zaki)\
**Post date:** [July 4, 2007, 10:10pm UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421/5 "2007-07-04T22:10:57Z")

</div>

On 7/3/07, Zoltan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> RubyHandler Apache::ERubyRun.instance
> 
> ```

You don’t say anything about the style of your application itself. Is it  
the  
kind of forms-driven site with a newly-developed domain model that is  
generally a good fit for Rails? Apart from a Japanese-language issue,  
you  
don’t say what has guided your choice of a framework (or no framework).  
If  
you have really decided to generate your dynamic content from Ruby  
unassisted by a framework, then there are several high-performance  
deployment options for you to consider.

I’d look at Kirk H.'s Swiftiply.

---

<div class="post-metadata">

**Author:** ![zaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee59a6/32.png) [@zaki](https://www.ruby-forum.com/u/zaki)\
**Post date:** [July 4, 2007, 10:07pm UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421/6 "2007-07-04T22:07:55Z")

</div>

Apache / Mongrel (or Pound / Mongrel) work much better than Lighttpd /  
FastCGI in at least 2 major Rails apps we’ve worked with, and I suspect  
that  
this is usually the case. Mongrel is just a wonderfully efficient Ruby  
server 🙂

I’m particularly fond of the Pound / Mongrel combo myself, and Pound  
does  
handle SSL. If you use Mongrel, you can easily scale as well, as you  
can  
have multiple machines running Mongrels with one Pound over them.

Robert

---

<div class="post-metadata">

**Author:** ![zaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee59a6/32.png) [@zaki](https://www.ruby-forum.com/u/zaki)\
**Post date:** [July 5, 2007, 3:00am UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421/7 "2007-07-05T03:00:24Z")

</div>

Francis C. wrote:

> You don’t say anything about the style of your application itself. Is it  
> the  
> kind of forms-driven site with a newly-developed domain model that is  
> generally a good fit for Rails? Apart from a Japanese-language issue,  
> you  
> don’t say what has guided your choice of a framework (or no framework).  
> If  
> you have really decided to generate your dynamic content from Ruby  
> unassisted by a framework, then there are several high-performance  
> deployment options for you to consider.
> 
> I’d look at Kirk H.'s Swiftiply.

Hi. It’s not like I had too much choice in the beginning. The company  
started using ruby in 2000 when rails was not an option. Since then a  
fairly large codebase was built bit-by-bit that generates sites for  
mobile sites. Unfortunately japanese mobile sites are anything but  
standards compliant (frankly, this whole mess is so wrong on so many  
levels, that i don’t even know where to start. You can forget about  
unicode and the only encoding all phones support is the one that is the  
least safe for every reason possible, then there is the problem of  
special characters built on top of this encoding (pictograms,  
emoticons), we have to take extra caution even on this base level - and  
the list of supported tags in html is so varying, they had to write a  
couple of books on the differences only - i hope japanese mobile  
providers will someday realize that using normal XHTML would be so much  
more beneficial to everyone. Then there’s the issue of authentication  
that is done differently for all carriers (we have to take the ID stored  
on the phone - forget login screens and clever sessions, cookies  
etc…). Finally (for this very short look into the abyss) there’s the  
problem of a certain provider that only supports apache with their  
proprietary download engine - which is probably built by 8-year-olds  
looking at the architecture, but that’s a different story entirely)

So for me - while I really really like it - rails does not seem to be an  
option unless i go in there and tweak the hell out of it myself, or  
fork/merge it - but regarding that we scarecely have enough time to  
finish our projects on time (again another issue completely) that’s  
highly unlikely 🙂  
Also, a constraint is that for one site, i can only have one server  
without a huge reorg - and with the risks involved, i’d doubt  
topmanagement would approve.

So thanks everyone for the comments. For now, I will be looking into the  
mongrel solution.

---

<div class="post-metadata">

**Author:** ![zaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee59a6/32.png) [@zaki](https://www.ruby-forum.com/u/zaki)\
**Post date:** [July 13, 2007, 11:21am UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421/8 "2007-07-13T11:21:10Z")

</div>

John J. wrote:

> Hey Zoltan, don’t worry much longer,  
> a few phones on the japanese market now display normal sites via Opera.  
> Thanks to the new pressure from iPhone you can expect handset makers  
> and service providers in Japan to be changing soon.  
> The special emoticons too are going to be thrown out or standardized,  
> there is already some translation of them between providers (not much  
> unfortunately).  
> But Unicode support has been a big problem in Japan and not just on  
> mobile sites, normal web sites as well.  
> Unicode support has been driven largely by Apple and Microsoft in  
> Japan, even though the JIS standards organization pushed to get SJIS  
> (shift-JIS) included as part of the Unicode standard. It’s coming.  
> faster than W3C initiatives. Luckily, market pressures on handset  
> makers in Japan is always strong so they’ve been fairly agile in  
> meeting demands. (they’ve got great engineers who work late every day)

Hi, John.

My view is that what is happening here is exactly the opposite. Unicode  
is supported by almost all newer phones and it is time to slowly phase  
out SJIS.

On the other hand, emojis are not only not going away, they are just  
getting worse. And by worse, I mean a lot. Recently softbank rolled out  
phones that support an entirely different set of emojis than before.  
They finally “standardized” their emoji sets to use the same kind of  
system as the other carriers. Previously they had a 5-byte character (a  
wtf in itself), now they have a SJIS character. That coincides with SJIS  
characters from other carriers.

Anything is faster than W3C standards, but there’s still hope we can see  
something 🙂

As for the engineers working late every day, my opinion - strictly  
biased - is that those engineers should stop working late. Everyone  
would be much better off that way.

But on a cheerful note:  
[http://shindaita.stiq.net/rdoc/mobile\_on\_rails/](http://shindaita.stiq.net/rdoc/mobile_on_rails/)

This made my day, hopefully others will find it useful too.

Zaki

---

<div class="post-metadata">

**Author:** ![zaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee59a6/32.png) [@zaki](https://www.ruby-forum.com/u/zaki)\
**Post date:** [July 20, 2007, 2:56am UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421/9 "2007-07-20T02:56:23Z")

</div>

On 7/13/07, Zoltan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> But on a cheerful note:  
> [http://shindaita.stiq.net/rdoc/mobile\_on\_rails/](http://shindaita.stiq.net/rdoc/mobile_on_rails/)
> 
> This made my day, hopefully others will find it useful too.

If you’re going to develop mobile applications for the Japanese market  
using rails , jpmobile by id:darashi has a more comprehensive feature  
set than Rakuto’s mobile on rails.

[http://jpmobile.rubyforge.org/](http://jpmobile.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![zaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee59a6/32.png) [@zaki](https://www.ruby-forum.com/u/zaki)\
**Post date:** [July 5, 2007, 4:14am UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421/10 "2007-07-05T04:14:20Z")

</div>

On Jul 4, 2007, at 8:00 PM, Zoltan D. wrote:

> > you have really decided to generate your dynamic content from Ruby  
> > levels, that i don’t even know where to start. You can forget about  
> > more beneficial to everyone. Then there’s the issue of authentication  
> > option unless i go in there and tweak the hell out of it myself, or
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Hey Zoltan, don’t worry much longer,  
a few phones on the japanese market now display normal sites via Opera.  
Thanks to the new pressure from iPhone you can expect handset makers  
and service providers in Japan to be changing soon.  
The special emoticons too are going to be thrown out or standardized,  
there is already some translation of them between providers (not much  
unfortunately).  
But Unicode support has been a big problem in Japan and not just on  
mobile sites, normal web sites as well.  
Unicode support has been driven largely by Apple and Microsoft in  
Japan, even though the JIS standards organization pushed to get SJIS  
(shift-JIS) included as part of the Unicode standard. It’s coming.  
faster than W3C initiatives. Luckily, market pressures on handset  
makers in Japan is always strong so they’ve been fairly agile in  
meeting demands. (they’ve got great engineers who work late every day)

---

<div class="post-metadata">

**Author:** ![zaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee59a6/32.png) [@zaki](https://www.ruby-forum.com/u/zaki)\
**Post date:** [July 25, 2007, 2:59am UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421/11 "2007-07-25T02:59:40Z")

</div>

Leonard C. wrote:

> [http://jpmobile.rubyforge.org/](http://jpmobile.rubyforge.org/)

Thank you! This is really great.

On a different note, i’ve done a brief benchmarking for ruby. Results  
are in no way scientific, just a very crude way of comparing different  
methods. Done with ab, i used t = 10, c = 10|50|100 and keepalive both  
on and off, so [10/10/o] should mean t = 10, c = 10, keepalive on, and  
[10/100/x] t=10 c=100 keepalive off

OS: CentOS 5.0  
Apache: 2.2.3  
Ruby: 1.8.5

Result values are requests/second  
Test page is a very very simple “hello world” type thing (just  
displaying the contents of a variable really)

HTML[10/10/o]: 6026  
HTML[10/50/o]: 5893  
HTML[10/100/o]: 5860  
HTML[10/10/x]: 896  
HTML[10/50/x]: 1021

Eruby(1.0.5)[10/10/o]:131  
Eruby(1.0.5)[10/50/o]:133  
Eruby(1.0.5)[10/100/o]:132  
Eruby(1.0.5)[10/10/x]:129  
Eruby(1.0.5)[10/50/x]:133  
Eruby(1.0.5)[10/100/x]:127  
Eruby(1.0.5)[30/200/o]:106  
Eruby(1.0.5)[30/200/x]:35

mod\_ruby(1.2.6)ERubyRun[10/10/o]:692  
mod\_ruby(1.2.6)ERubyRun[10/50/o]:738  
mod\_ruby(1.2.6)ERubyRun[10/100/o]:722  
mod\_ruby(1.2.6)ERubyRun[10/10/x]:766  
mod\_ruby(1.2.6)ERubyRun[10/50/x]:811  
mod\_ruby(1.2.6)ERubyRun[10/100/x]:759

rails(fastcgi)[10/10/o]:173  
rails(fastcgi)[10/50/o]:133

PHP(5.1.6)[10/10/o]:2993  
PHP(5.1.6)[10/50/o]:3027  
PHP(5.1.6)[10/100/o]:2954  
PHP(5.1.6)[10/10/x]:1058  
PHP(5.1.6)[10/50/x]:991  
PHP(5.1.6)[10/100/x]:1057  
PHP(5.1.6)[30/200/o]:2182  
PHP(5.1.6)[30/200/x]:546

Zaki

---

<div class="post-metadata">

**Author:** ![zaki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee59a6/32.png) [@zaki](https://www.ruby-forum.com/u/zaki)\
**Post date:** [July 26, 2007, 12:45am UTC](https://www.ruby-forum.com/t/running-a-huge-site/108421/12 "2007-07-26T00:45:58Z")

</div>

On Wed, 25 Jul 2007, Zoltan D. wrote:

> On a different note, i’ve done a brief benchmarking for ruby. Results  
> are in no way scientific, just a very crude way of comparing different  
> methods. Done with ab, i used t = 10, c = 10|50|100 and keepalive both  
> on and off, so [10/10/o] should mean t = 10, c = 10, keepalive on, and  
> [10/100/x] t=10 c=100 keepalive off
> 
> OS: CentOS 5.0  
> Apache: 2.2.3  
> Ruby: 1.8.5

Of course, it depends on the hardware, too, but here’s some additional  
numbers:

OS: Ubuntu 6.06  
Swiftiply: 0.6.0  
Ruby: 1.8.5  
Hardware: AMD Athlon X2 4200+

Keepalive is irrelevant since it’s not currently honored in the above  
setup.

(I ran 100k of each of these, 3 times, and averaged)  
HTML[10]: 8953  
HTML[50]: 9150  
HTML[100]: 9180

(I ran 10k of each of these, 3 times, and averaged)  
Iowa(0.99.3.5)[10]: 1152  
Iowa(0.99.3.5)[50]: 1112  
Iowa(0.99.3.5)[100]: 1065

Kirk haines
