# Simple solution to the 'twitter' scaling problem

**URL:** <https://www.ruby-forum.com/t/simple-solution-to-the-twitter-scaling-problem/92222>\
**Category:** Rails\
**Created:** [April 17, 2007, 7:58am UTC](https://www.ruby-forum.com/t/simple-solution-to-the-twitter-scaling-problem/92222 "2007-04-17T07:58:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 17, 2007, 7:58am UTC](https://www.ruby-forum.com/t/simple-solution-to-the-twitter-scaling-problem/92222/1 "2007-04-17T07:58:03Z")

</div>

By now i’m sure we’ve all read the comments bouncing around in blogs  
about the twitter scaling problem: namely they were worried about how to  
use rails against multiple cloned database backends.

Well, whats wrong with having a pair (or more) of cloned database hosts,  
and editing the tcpip ‘hosts’ file on your different rails servers so  
that half your rails servers are pointing at one database, and half are  
pointing at the other?

Wouldn’t that be pretty simple and do the job? Or am i missing  
something?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 17, 2007, 9:02am UTC](https://www.ruby-forum.com/t/simple-solution-to-the-twitter-scaling-problem/92222/2 "2007-04-17T09:02:34Z")

</div>

On 4/17/07, chris hulbert [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Wouldn’t that be pretty simple and do the job? Or am i missing  
> something?

You couldn’t do this, because you would get ID conflicts from  
auto-increment. Two inserts on the same table on each DB would  
conflict.

However, there are facilities for multi-master replication in some  
databases, such as Mysql 5 [1] You need to have some sort of code to  
handle connections, at least to watch for dead servers and failover.  
Also, you’d want to designate some read-only servers pretty early on  
because writing across many masters would get expensive quickly. So  
then you are back to square one, as need to handle writing to certain  
databases and reading from others. Nic’s plugin would handle that, I  
believe.

In other words, scaling can start simple but it gets complicated quick  
:).

1 -

> **[Radar - O’Reilly](https://www.oreilly.com/radar/)**
>
> Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology

- Rob

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 18, 2007, 12:50am UTC](https://www.ruby-forum.com/t/simple-solution-to-the-twitter-scaling-problem/92222/3 "2007-04-18T00:50:01Z")

</div>

I think you got it right here:

Rob S. wrote:

> because writing across many masters would get expensive quickly.
