Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Node.js, how do I make one server call a function on another server?

Let's say I have 2 web servers. Both of them just installed Node.js and is running a website (using Express). Pretty basic stuff.

How can Server-A tell Server-B to execute a function? (inside node.js)

Preferably...is there a npm module for this that makes it really easy for me?

like image 713
TIMEX Avatar asked May 12 '11 04:05

TIMEX


People also ask

How do you call one function from another node JS?

To call a function inside another function, define the inner function inside the outer function and invoke it. When using the function keyword, the function gets hoisted to the top of the scope and can be called from anywhere inside of the outer function.

Can a single node use multiple servers?

Each node is with one type of server. It shares the workload across servers on multiple nodes according to the requirement. This major benefit for the horizontal cluster is that the users are allowed to use the application if one node encounters the failure.

How node JS works on server-side?

Node. js is a server-side, packaged software that contains predefined processes to accomplish specific tasks. As a server-side runtime, every Node. js process is executed on a server; essentially working on the backend aspect of an application to manage data.


1 Answers

How can Server-A tell Server-B to execute a function?

You can use one of the RPC modules, for example dnode.

like image 101
yojimbo87 Avatar answered Oct 03 '22 03:10

yojimbo87