Chat application in Django

470 views
Skip to first unread message

Shamail Tayyab

unread,
Aug 31, 2010, 7:31:55 AM8/31/10
to django...@googlegroups.com
Hi,

I am working on a chat application in Django, how can I ensure that I
do not have to poll the server for any chat data.

Possible approaches that I've been to:

1. BAD - use polling.

2. Use long polling - bad approach afa browser support is concerned.

3. Using sockets in flash - makes the application flash dependent.

Is there some good way to do this? Or if there is something Django
specific? Something like HTTPBinding or any 3rd party tested libraries?
I am expected to provide support till IE6. :-(

Correct me if I am wrong, flash is available on 95% of the systems, this
approach looks like safest bet, is it good to go?

Btw, how does Gmail and FB chat works?

Thanks

Shamail Tayyab

unread,
Aug 31, 2010, 7:34:43 AM8/31/10
to django...@googlegroups.com
Hi,

Thanks

--
Shamail Tayyab
Blog: http://shamail.in/blog

Jeff Bell

unread,
Aug 31, 2010, 8:08:18 AM8/31/10
to django...@googlegroups.com

Pretty sure fb uses Erlang for chat.

> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

Alexandre González

unread,
Aug 31, 2010, 8:18:34 AM8/31/10
to django...@googlegroups.com
I've seen this project: http://code.google.com/p/django-chat/ but I don't test it... perhaps the code can helps you.

What about use a free protocol as XMPP (jabber) and write a "client" for django?
--
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt and/or .pptx

David Koblas

unread,
Aug 31, 2010, 12:03:08 PM8/31/10
to django...@googlegroups.com, Shamail Tayyab
Funny you should ask --

The basic challenge with any chat application is the long polling bit,
django by default isn't really designed to handle that. Other servers
(Tornado, etc.) are much better at handling the long polling cycle that
typical web chat applications require.

I was just finishing an exploration of Django+Tornado -- building a chat
application -- which I've now pushed up to github.

http://github.com/koblas/django-on-tornado

The only "trick" at the moment is that a response that is returned via
the async Tornado handler isn't passed back up the middleware stack,
pondering good ways to deal with that. But in the mean time, here's a
functional chat application to play with if you're interested.

--koblas

reduxdj

unread,
Aug 31, 2010, 2:27:22 PM8/31/10
to Django users
Check this out: It's pretty awesome and works with tornado on flash
and serves AMF objects.

ebry1

unread,
Aug 31, 2010, 7:53:38 PM8/31/10
to Django users
I am interested in this problem too, I need to pass some additional
data along side chat messages.

Why did you decide to abandon polling? I was thinking of thinking of
using it and updating about twice a second.

Shamail Tayyab

unread,
Sep 1, 2010, 1:33:24 AM9/1/10
to django...@googlegroups.com
Hi,

@Jeff, Erlang! Pretty surprised to see that.
@Alexander, doesn't work :( - or might be I am not able to get it..
@David, cool I'll try this, but will this work using mod_python / Apache?
@ebry1,
Imagine 10000 people live chatting, that means 10000 requests per
second, but in real world, only 3000 messages might have been
delivered. (as example). Polling will bring your net throughput of the
server to almost one tenth.

@all,
Can you suggest me the side effects of using Sockets via 1x1px flash
applet embedded on the page? Apart from the fact that flash is
required.

Thanks

> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>

--

David Koblas

unread,
Sep 1, 2010, 9:30:57 AM9/1/10
to django...@googlegroups.com, Shamail Tayyab
Two challenges with long polling and Apache/mod_python -

* First is that you'll need to have N-user connections open at a minimum
based on the number of users you have using the system simultaneously.
Thus your memory footprint and performance is going to suffer as the
number of users increases.

* Second - the demo app I have assumes a single process model for
handling communications (e.g. all notification is done via callbacks).
So you would need to build some kind of server who maintains state if
you ran things under apache (multi-process dispatch model).

--david

yves_s

unread,
Sep 1, 2010, 10:05:48 AM9/1/10
to Django users

Ivan Uemlianin

unread,
Sep 1, 2010, 6:03:01 PM9/1/10
to Django users
Dear Shamail

As well as the resources already mentioned, I mention a few on this
comment on a similar thread in May:

http://groups.google.com/group/django-users/browse_thread/thread/6032003efcf2c2df/0575d5b54ecd5254#0575d5b54ecd5254

Hotdot (django, orbited and twisted) is good for realtime chat, and
easy to set up. Whether Twisted is a pro or a com I leave up to you.

Speeqe is a hybrid system with django collaborating with an ejabberd
server for the realtime content. In the long run this is probably
more robust (however, I'm afraid I haven't got round to testing it
myself).

Do let us know how you got on.

Best wishes

Ivan

On Sep 1, 3:05 pm, yves_s <yves.serr...@gmail.com> wrote:
> I also looking for realtime messaging for django and found this two
> links.
>
> http://www.clemesha.org/blog/realtime-web-apps-python-django-orbited-...
>
> http://bitshaq.com/2010/07/30/a-simple-experiment-with-hookbox/
>
> yves

Salman (shaq) Haq

unread,
Sep 3, 2010, 9:43:29 AM9/3/10
to Django users
Hi guys,

I am the author of a 'A simple experiment with Hookbox' (see below).

Just wanted chime in and say that Hookbox is under development right
now
but it is looking very promising. A few people have deployed chat
applications
for high traffic websites using it already. The simplicity of Hookbox
is a major strength.

Hotdot is based on Orbited, which is also a framework by the author of
Hookbox.

A new feature coming up in Hookbox is the 'private message api' which
allows
messages to be passed from one client to another client rather simply.
I've been following
the mailing and people have already started posting demo code using
this feature.

Hope this helps.

Best,
Shaq

On Sep 1, 10:05 am, yves_s <yves.serr...@gmail.com> wrote:
> I also looking for realtime messaging for django and found this two
> links.
>
> http://www.clemesha.org/blog/realtime-web-apps-python-django-orbited-...
>
> http://bitshaq.com/2010/07/30/a-simple-experiment-with-hookbox/
>
> yves

Shamail Tayyab

unread,
Sep 3, 2010, 10:02:20 AM9/3/10
to django...@googlegroups.com
Hi Ivan,

This looks promising, could you also throw some light on how hosting
friendly this set up will be?

Thanks

Ivan Uemlianin

unread,
Sep 4, 2010, 9:42:08 AM9/4/10
to Django users
Dear Shamail

It depends on your host. Serving real-time content over the web
requires a web server that can do server push (e.g., Twisted, Tornado,
ejabberd, etc.). If your host will let you install your own web
server, you're fine.

If your host insists on apache, ... I think server push is possible
with apache, ... If you're sharing web server resources, your hosts
might not be too friendly about your doing server push.

If you can't run these systems with your current host, try them out on
your own machine while you're looking for a new host;)

Best wishes

Ivan


On Sep 3, 3:02 pm, Shamail Tayyab <pleoma...@gmail.com> wrote:
> Hi Ivan,
>
>   This looks promising, could you also throw some light on how hosting
> friendly this set up will be?
>
> Thanks
>
> > For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Preston Holmes

unread,
Sep 4, 2010, 12:06:14 PM9/4/10
to Django users


On Aug 31, 4:31 am, Shamail Tayyab <pleoma...@gmail.com> wrote:
> Hi,
>
>    I am working on a chat application in Django, how can I ensure that I
> do not have to poll the server for any chat data.
>
> Possible approaches that I've been to:
>
> 1. BAD - use polling.
>
> 2. Use long polling - bad approach afa browser support is concerned.
>
> 3. Using sockets in flash - makes the application flash dependent.
>
> Is there some good way to do this? Or if there is something Django
> specific? Something like HTTPBinding or any 3rd party tested libraries?
> I am expected to provide support till IE6. :-(

You might want to check out: http://hookbox.org/

-Preston
Reply all
Reply to author
Forward
0 new messages