I currently have a chatbot app in my django project that I would like to 
deploy.


I am confused as to whether I should use WebSockets or normal HTTP calls 
(AJAX) for it's implementation. This is what I have understood about the 
pros/cons of each(in the context of my use-case) till now after some 
internet research.
Reasons for using WebSockets over HTTP:
   
   1. WebSockets are recommended for chat applications because of low 
   overhead per user message once the connection has been established. HTTP 
   will have the overhead of establishing a connection each time a message is 
   sent (Also the header will be bigger in size, which will be sent with each 
   request/user message)
   2. WebSockets allow for real-time communication without *workarounds* like 
   polling in case of HTTP which can lead to many unnecessary requests from 
   the client.

Reasons for using HTTP over WebSockets:
   
   1. HTTP *just might* be okay for a chatbot(not human to human chat) 
   because the response of the chatbot is only triggered when the user 
   messages something i.e. The Bot isn't expected to message the user all of a 
   sudden at random intervals which would require real-time communication. The 
   Bot only sends replies to user messages.
   2. Will have to use django-channels and an ASGI server for the chatbot 
   part, which will require maintaining two servers (along with WSGI), which 
   will make the implementation a little bit complicated.

What should I go ahead with?

P.S. Someone suggested I look into services like Pusher 
<https://pusher.com/>, although it doesn't seem to have server side SDK for 
python

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d7611fcc-76a7-4533-9b2b-fa21891dd42d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to