2

I am working on a RESTful web service which must support a high load of incoming connections. My curent design idea is to separate the server application in two ends:

  1. a front-end developed using Node.JS which listen to the incoming connections and call the appropriate routine of the back-end compiled as a shared library
  2. a back-end written in C/C++ which handles business logic, including interactions with the database.

But I have no idea if calling a shared library from Node.JS induces a latency which will make my effort in the performance of the backend useless.

What do you think of this architecture? Thanks!

EDIT: Given the answer below, what about using something like lighttpd with FastCGI compared to Node.JS?

1 Answer 1

1

Though it is theoretically possible to compile the "back-end" in C/C++ into nodejs I would not recommend this.

Reason: C/C++ node addons can (or will) block your main process furthermore they take resources on allocation and are hard to debug.

My advice is to write the complete back-end with nodejs. Nodejs will handle the load fine for you. The ROI on writing a back-end in C++ for incoming connections is quite low.

However if you still want to stick to the idea. Try to write the C++ backend as stand alone and let it use a HTTP, TCP or raw socket interface. This will allow communicating node async with your backend. However this would increase the effort even more on writing a proper backend.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank for this answer! And what about a front-end with lighttpd (or similar) using FastCGI compared to a nodejs-only server application?
Hmm I have no experience with traditional web servers (except nginx as reverse proxy). However I still believe that if you will run into performance problems with node you will run in long term with every environment in performance problems. The solution towards this is always the same: Use a load balancer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.