# Two Controllers vs One Big Controller with many actions

**URL:** <https://www.ruby-forum.com/t/two-controllers-vs-one-big-controller-with-many-actions/48286>\
**Category:** Rails\
**Created:** [November 18, 2005, 4:09pm UTC](https://www.ruby-forum.com/t/two-controllers-vs-one-big-controller-with-many-actions/48286 "2005-11-18T16:09:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![virgild](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/77aa72/32.png) [@virgild](https://www.ruby-forum.com/u/virgild)\
**Post date:** [November 18, 2005, 4:09pm UTC](https://www.ruby-forum.com/t/two-controllers-vs-one-big-controller-with-many-actions/48286/1 "2005-11-18T16:09:37Z")

</div>

I have two controllers with about 12 actions each, and since the two are  
very closely related, I’m trying to merge them into just one controller.  
What is the effect of this in terms of performance? I’m really not  
trying to  
do some deep optimization here, just want to find out if it will matter  
in  
case performance becomes an issue later.

---

<div class="post-metadata">

**Author:** ![virgild](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/77aa72/32.png) [@virgild](https://www.ruby-forum.com/u/virgild)\
**Post date:** [November 18, 2005, 4:24pm UTC](https://www.ruby-forum.com/t/two-controllers-vs-one-big-controller-with-many-actions/48286/2 "2005-11-18T16:24:49Z")

</div>

Vurg wrote:

> I have two controllers with about 12 actions each, and since the two are  
> very closely related, I’m trying to merge them into just one controller.  
> What is the effect of this in terms of performance? I’m really not trying to  
> do some deep optimization here, just want to find out if it will matter in  
> case performance becomes an issue later.

There will probably be no noticable speed difference, unless both have  
differing filter needs. Potentially you could end up with twice as many  
filters, or complicated :exclude, :include filter conditions. This could  
slow your app down a bit.

– stefan kaes

PS: [http://railsexpress.de/blog](http://railsexpress.de/blog) talks about Rails performance issues.  
Subscribe 😉

---

<div class="post-metadata">

**Author:** ![virgild](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/77aa72/32.png) [@virgild](https://www.ruby-forum.com/u/virgild)\
**Post date:** [November 20, 2005, 10:19pm UTC](https://www.ruby-forum.com/t/two-controllers-vs-one-big-controller-with-many-actions/48286/3 "2005-11-20T22:19:55Z")

</div>

I’ll take note of that.

Another thing that comes to my mind is a bigger controller class will be  
slower to instantiate than one with less methods. But I’m not sure about  
this yet.

“Stefan K.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote in message  
news:removed\_email\_address@domain.invalid…

---

<div class="post-metadata">

**Author:** ![virgild](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/77aa72/32.png) [@virgild](https://www.ruby-forum.com/u/virgild)\
**Post date:** [November 20, 2005, 10:35pm UTC](https://www.ruby-forum.com/t/two-controllers-vs-one-big-controller-with-many-actions/48286/4 "2005-11-20T22:35:59Z")

</div>

Methods don’t matter in regards to instantiation as most OO  
languages–e.g. Java–implement instances in a ‘flyweight’ fashion.

To be clearer, non-static (or in ruby, non-class) methods are really  
just static methods (from an implementation perspective) with an  
associated context (instance variable values).

That being said, I’m not sure Ruby does this–although I would be  
surprised to hear otherwise.

I don’t think merging things for performance reasons makes sense (even  
if it did lead to slightly better performance, which it probably  
wont). I’d recommend keeping semantics as the primary driver for  
collocating stuff, as hardware is so much cheaper than manpower these  
days.
