I am writing a small web server in node.js, and I've managed to integrate a scripting language into it. Currently, it generates the code and feeds it into the interpreter through spawn
, and quite frankly works like a charm. However, I am afraid that spawning a seperate process just to run the server-side code is a performance bottleneck. What would be the best approach to invoke the interpreter (one thought I had was somehow embedding the interpreter, but I really don't know)?
0
votes
If you're only spawning a few such processes (<= the number of cores on your machine), your concern is likely unwarranted.
– ChrisCM
It would spawn it for each page request (multiple times if their are linked files)
– bobbybee
If I were doing it, I would implement it in Node, and have the client keep track of its own state, so that launching a process for each client wasn't necessary. It's an I/O vs CPU tradeoff, but in this case, I think more I/O makes the most sense. The suggestion about C++ addon is also solid. Don't know enough about your use case to have a real informed opinion on the matter.
– ChrisCM
1 Answers
0
votes
1) You can implement the interpreter in node directly, using javascript or any other language that node runs.
2) You can implement the interpreter in some native language and include it as a node addon: http://nodejs.org/api/addons.html