Is it a good move to add nodejs server as a middle man between nginx and tomcat, mostly for get requests?
-
Currently I'm working on a mobile application whose API calls go to nginx which in turn passes that to tomcat server, where we have Java fetching data from mongoDB and sending the results back. Is it a good move to pass the requests from nginx to nodejs server which proxies it to tomcat server and owns the responsibility of sending back the ajax responses ? I'm not sure how much will I gain with this setup, but just wanted to try out and as I'm a Javascript developer, thought this would help get JS in the backend too.
-
Answer:
The short answer is: no, don't do it. Why? Because you're unnecessarily complicating your infrastructure. When something goes wrong, now you have to take additional steps to analyze and resolve the problem. Furthermore, Node.js is not purpose-built for reverse proxying -- that's what Nginx is for. You might as well install Nginx twice and do the same thing -- you'd probably get more benefit out of it, in fact, since Nginx is better at reverse proxying than Node. Node is probably more of a performance hit on handling requests than Tomcat (once you get past the initial memory requirements). Node won't handle requests any faster than Tomcat, and the JVM will have far better garbage collection. If you're looking for ways to improve the response time of your read requests, consider these options: Implement caching in your Java application, so that read requests go to the database less frequently. If you have a distributed architecture, look into a network cache such as memcached, so that you don't have copies of caches in local systems. Tune your nginx to improve and buffer read requests. Add workers (if you have more cores), open file handle limits, etc. Scale vertically. (That means, buy bigger hardware, whether it's in the cloud or not; more disposable RAM and CPU will always improve your response times by some amount, though returns may diminish if resources are under-utilized.) Tune your application code to improve processing performance. Store more stuff in memory (similar to caching).
Jonathan Fenocchi at Quora Visit the source
Related Q & A:
- Does anyone know a site where I can get a complete Man of La Mancha script for free?Best solution by Yahoo! Answers
- Does anyone know a good tubing location or how to find a good tubing location near Denver?Best solution by Yahoo! Answers
- What is a good camcorder to buy if you have a Mac?Best solution by Yahoo! Answers
- Where is a good place to take my Mother for a Vacation next year?Best solution by usatoday30.usatoday.com
- Was Feudalism a good system for the Middle Ages?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.