eugene
eugene

Reputation: 41745

communication method between django <-> application server (node.js)?

A client talks to Django, and django uses node.js to do some javascript related work to give back the client a http response.

I wonder how I should set up the link(?) between the django and node.js.

Simply, I could use python's requests library and talk http, but is this best I can do?

If I were to build the communication link in c++, I would create non-block socket with Send/Recv Thread and use mutex(or similar) between the django view code and the send/recv thread.

I guess that's what is called asynchronous io in node.js world.

Is there a similar thing in python so that I could use on django side to talk to another server?

I heard many big companies use Thrift, would it fit here?
I also see gevent might be relevant keyword here, but not sure.

Upvotes: 1

Views: 813

Answers (1)

AdelaN
AdelaN

Reputation: 3536

I am not sure if my answer is still relevant, but I'll give it a try. IMHO, the best solution for you would be to have a RESTful API for your Django app. This has several advantages:

  • it provides a lot of decoupling between your Django app and your Node.js one, so in case you ever want to reuse any of them or to replace one of them, it will be easy
  • it allows you to design an API for each of them and to hide the rest of your implementation (your Django app should not care how Node.js does its job, but only the response that it provides)
  • there are many great frameworks out there that can help you quickly build your APIs (at leat for Django there is Django REST framework)

If you don't want to build a RESTful API, python's request library is probably the best and easiest way.

Good luck.

Upvotes: 1

Related Questions