Thursday, 3 March 2016

A rather silly question about a basic node concept

Let's imagine I have a node app as follows (pseudocode):receive POST request & accept data open connection to RabbitMQ channel send data to message queue respond with HTTP 200 or 404 or whatever I expect to receive 100 POST requests to the above app over the next 5 minutes.Based on the above code, every time a POST request is received, I open a connection to the RabbitMQ channel.Does it make sense to open the connection to the RabbitMQ channel every time a POST request is received? Or should the connection be opened once (at the beginning of the app code), and this is enough to maintain an open channel so I can fire off messages to RabbitMQ at will?Basically I'm used to PHP where you generally have to do everything every time the PHP script is called (open DB connection, insert, close DB connection). But with node am I right in thinking the DB connection gets opened when the app is launched, so you only have to do the insert every time the app is called?Sorry if this is silly or I'm making no sense.

Submitted March 03, 2016 at 03:45PM by MEAN_questions

No comments:

Post a Comment