简体   繁体   中英

Node.js doesn't serve more than 5 browser tabs

I am using Apache, Mysql and Node.js to run a dynamic website which uses the long polling to update the content.

The main language is PHP but for updating the content I use Node.js

I run the Node.js server on port 9000

Apache is running on port 80

I am proxying any request arrives to Apache (to the Node.js site) to port 9000, below is the sites-available portion for the website (www.example.com):

<VirtualHost *:80>
    .
    .
    ProxyPass /node  http://localhost:9000/
    ProxyPassReverse /node  http://localhost:9000/
    .
    .
</VirtualHost>

The Node.js website: www.example.com/node/

I noticed that Node.js can't serve more than 5 browser tabs ! It stops updating after that. I read that Node.js can serve thousand of connections! How can I achieve the high performance?

The Node.js is communicating with Mysql direct every 2 seconds to check for updates.

Shall I use Nginx instead of Apache? Running both Webserver and Node.js on port 80 is healthy? What is the best way/services to use? Please advise and many thanks.

I noticed that Node.js can't serve more than 5 browser tabs! It stops updating after that. I read that Node.js can serve thousand of connections! How can I achieve the high performance?

You are getting confused. Web browsers have a maximum number of concurrent connections they will open to a given server ("origin").

You cannot accurately test concurrency with a single browser. Try load testing tools like wrk or apache bench .

To quickly prove this, open multiple distinct browsers (chrome, firefox, IE, etc), and a few tabs in each browser and that should illustrate what is going on here.

You would also need to check your Apache configuration to help figure out why so few connections can be made. Depending on your configuration (such as using the Apache mpm-prefork module), you might only have 5 slots that Apache could have as possible connections - particularly on a development system.

Apache, with Mod-PHP is frequently setup on Apache with a forking model. On Ubuntu, for example, you can check in the /etc/apache2/mods-enabled directory, and see what mpm*.conf and mpm*.load systems are being used.

Long term, NginX will usually be a better host, and certainly for large number of connections.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM