Can I use Django and Node.Js?

I have a django backend created for user logins and user management, as well as the whole set of templates that website visitors use to display html files. However, I am trying to add real-time functionality to my site, and I found the perfect library in Node.Js that allows two users to enter a text box and display text on both screens. Can two backends be combined?

+8
source share
4 answers

It is absolutely possible (and sometimes extremely useful) to run several back-end for different purposes. Nevertheless, he opens several cans of worms, depending on what rigor your system expects, who is on your team, etc.:

  • State. You want session state to be shared across application servers. The easiest way to do this is to save the external state of the session within the framework of agnostic. I would suggest JSON objects in a key / value store, and you are likely to benefit from a JSON scheme.
  • Domains / routing. You need your login cookie to be accessible for both application servers, which means either a single domain routed by Apache / Nginx or separate subdomains routed through DNS. I would suggest separate subdomains for the following reason.
  • WebSockets I may be out of date, but as far as I know, neither Apache nor Nginx support website proxying, which means that if you want to use this, you will sacrifice the flexibility of using the http server as a proxy application and instead expose Node directly through the subdomain.
  • Not specified requirements. Functions such as monitoring, logging, error reporting, system builds, testing, continuous integration / deployment, documentation, etc. Must be expanded to support a new type of component.
  • Skills. You will have to pay on time or money for the skill sets needed to manage a more complex application architecture.

So, my advice would be to think carefully if you need it. It can be a lot of time and thought.

Update . In fact, there are companies specializing in adding real-time existing sites. I will not give any names, but if you are looking for β€œreal-time” in the market for platform hosting applications (such as Heroku), you will find them.

Update 2 : Nginx now supports website support

+10
source

You cannot combine them. You can send messages from Django to Node.Js through some queuing system like Reddis.

+2
source

If you really want to use two backends, you can use a database supported by both backends.

Although I would not recommend it.

0
source

Try Django, Node.js, Socket.io, and Reddis.

0
source

All Articles