Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy nodejs server on reverse proxy nginx is slow #8

Open
SudoDios opened this issue Nov 19, 2021 · 3 comments
Open

Deploy nodejs server on reverse proxy nginx is slow #8

SudoDios opened this issue Nov 19, 2021 · 3 comments

Comments

@SudoDios
Copy link

I create a nodejs http server and using autocannon to loadtest.
When I use this node server without a nginx proxy, the requests reach 137k per second.
But when I use it with nginx reverse proxy, it reaches 60k per second.
Why ????
please help me.🙏

@jarebear6expepjozn6rakjq5iczi3irqwphcvb

Can you post config for the reverse proxy?

@SudoDios
Copy link
Author

user www-data;
worker_processes auto;
worker_rlimit_nofile 900000;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
	worker_connections 400000;
	use epoll;
        multi_accept on;
}

http {

	##
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 10;
	#types_hash_max_size 2048;
	# server_tokens off;

	# server_names_hash_bucket_size 64;
	# server_name_in_redirect off;

	include /etc/nginx/mime.types;
	default_type application/octet-stream;

	##
	# SSL Settings
	##

	ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
	ssl_prefer_server_ciphers on;

	##
	# Logging Settings
	##

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	##
	# Gzip Settings
	##
	
	gzip on;
        gzip_min_length 10240;
        gzip_comp_level 1;
        gzip_vary on;
        gzip_disable msie6;
        gzip_proxied expired no-cache no-store private auth;


	##
	# Virtual Host Configs
	##

	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;

	access_log off;
	
	auth_basic "Auth ...";
        auth_basic_user_file /etc/nginx/.htpasswd;
        
	
        server {
	   listen myIP:80;
	   
	   client_max_body_size 1g;
	  
	   location / {
	      root /home/sudodios/banoo;
	   }
	   location /api/ {
		proxy_pass http://localhost:2000/;
	   }
	}
}

http://localhost:2000/ is my node server.

@aminvakil
Copy link

aminvakil commented Dec 29, 2021

@SudoDios
You may have reached the kernel security limits and nginx -t may give you a hint about it, or you may have reached max tcp connections, can nodejs listen on unix sockets?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants