3

I'm really interested in systems written in node.js. Specifically using it to create an MVC application.

I was thinking about the differences between designing a node.js MVC and doing the same in PHP. Since PHP is loaded and interpreted at runtime, a change to one of my controllers or views will be reflected in live server performance as soon as the file on the server changes.

I'm wonderring though, since node.js is compiled, is an application restart required every time you push changes?

If not, does MVC effect server performance overall, since the server has to read the files at request-time versus having the whole application sitting in memory? Or do perhaps have it all wrong and I'm missing the point entirely? (if so please educate me 'cause I'm dying to know!).

Thanks! - A

Alex C
  • 16,624
  • 18
  • 66
  • 98

2 Answers2

6

Check out Express for a take on Node framework development. You can see some MVC there. The HTTP url parsing available in Node really makes writing a router easy for tossing requests to 'controllers' and requiring in models is easy.

Node can use a variety of databases from SQL (Postgres, etc) to No-SQL (CouchDB, Mongo, etc)

Here is an example of an already available "restart-node-on-changes" add-on

Here is a list of plugins/modules for Node

Richard Holland
  • 2,663
  • 2
  • 21
  • 35
  • Oh my! Richard that link to the restart-on-changes is *so* welcome :) Thanks. Just this last weekend I was working on a Node project and was running into the problem that I had to search "TOP" for the process ID, kill the proc, then restart the server. That's a real godsend. – Alex C Apr 04 '11 at 19:51
3

A typical node.js MVC application would store the model data in memory and on some kind of saved database like mongoose.

Every time a model changes it goes through your js and saves to the database. It shouldn't need restarting at all.

If you change your code you do indeed have to restart the server. I presume there are various programs out there to stop this from happening.

Although it's not Recommended

These are also Relevant: EventedIO

Community
  • 1
  • 1
Raynos
  • 166,823
  • 56
  • 351
  • 396