# Chat app, Caching? Observe?

**URL:** <https://www.ruby-forum.com/t/chat-app-caching-observe/189425>\
**Category:** Rails\
**Created:** [May 31, 2010, 7:46pm UTC](https://www.ruby-forum.com/t/chat-app-caching-observe/189425 "2010-05-31T19:46:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/bc79bd/32.png) [@gregm](https://www.ruby-forum.com/u/gregm)\
**Post date:** [May 31, 2010, 7:46pm UTC](https://www.ruby-forum.com/t/chat-app-caching-observe/189425/1 "2010-05-31T19:46:11Z")

</div>

Hi,  
I am developping a little chat application with rails. On my chat page I  
make ajax request every 10 seconds to check if there are news messages.  
I think if I keep this thing with a lot of user my performance will get  
really low.

How can I improve this? Is is possible to observe when a row is added?  
Or how can I effeciently cache the messages?

Thanks,  
Greg

---

<div class="post-metadata">

**Author:** ![gregm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/bc79bd/32.png) [@gregm](https://www.ruby-forum.com/u/gregm)\
**Post date:** [May 31, 2010, 7:53pm UTC](https://www.ruby-forum.com/t/chat-app-caching-observe/189425/2 "2010-05-31T19:53:45Z")

</div>

You might have a look at node.js - I’ve heard recently of apps which  
combine  
node.js w/ redis pubsub to get a pretty nifty quick experience w/ no  
polling. From a scalability and performance point of view, this has a  
couple of drawbacks - susceptible to network latencies, quality (may be  
better suited for intranet), and second, each client may need it’s own  
port  
(this for node.js).

Here’s a pretty cool little app -

> **[LakTEK](https://www.laktek.com/)**
>
> Personal web site of Lakshan Perera

cheers,

m

---

<div class="post-metadata">

**Author:** ![gregm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/bc79bd/32.png) [@gregm](https://www.ruby-forum.com/u/gregm)\
**Post date:** [May 31, 2010, 8:18pm UTC](https://www.ruby-forum.com/t/chat-app-caching-observe/189425/3 "2010-05-31T20:18:33Z")

</div>

Greg Ma wrote:

> Hi,  
> I am developping a little chat application with rails. On my chat page I  
> make ajax request every 10 seconds to check if there are news messages.  
> I think if I keep this thing with a lot of user my performance will get  
> really low.

It shouldn’t if you structure your queries efficiently

> How can I improve this? Is is possible to observe when a row is added?

Perhaps, but pushing to the browser is difficult or impossible.

> Or how can I effeciently cache the messages?
> 
> Thanks,  
> Greg

You’re doing premature optimization. Worry about the bottlenecks when  
you can actually measure them, not when you’re just speculating.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![gregm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/bc79bd/32.png) [@gregm](https://www.ruby-forum.com/u/gregm)\
**Post date:** [June 1, 2010, 1:35pm UTC](https://www.ruby-forum.com/t/chat-app-caching-observe/189425/4 "2010-06-01T13:35:23Z")

</div>

Maybe you want to give this a try (there seems to be “no activity”  
currently, though…)

[http://code.google.com/p/canhaschat/](http://code.google.com/p/canhaschat/)
