I have a small NodeJS app, with an Nginx front to serve the static files to increase performance.
The bundle.js
file takes around 1s with no load, however, add some concurrent users and the bundle.js
takes quite the hit!
This is running in k8s
, however it's a brand-new environment so there should be no other influences.
The CPU doesn't spike, the memory is at it's lowest useage, and I've tried all the usual send_file
tricks - is there anyway I can get some throughput here?
default.conf
server {
listen 80;
root /mnt/app;
index index.html index.htm;
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
access_log off;
open_file_cache max=2000 inactive=3600s;
open_file_cache_valid 3600s;
open_file_cache_min_uses 1;
open_file_cache_errors off;
location /public/ {
try_files $uri $uri/ =404;
}
location /Healthcheck/ {
proxy_pass http://localhost:8080;
}
location /auth/login/ {
proxy_pass http://localhost:8080;
}
location /auth/connect/ {
proxy_pass http://localhost:8080;
}
location /data/ {
proxy_pass http://localhost:8080;
}
}
http.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
connect-frontend-nginxpid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
sendfile_max_chunk 512;
# server_tokens off;
keepalive_timeout 65;
gzip on;
include /etc/nginx/conf.d/*.conf;
}
gzip.conf
## Compression.
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 1;
gzip_http_version 1.1;
gzip_min_length 10;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/x-icon application/vnd.ms-fontobject font/opentype application/x-font-ttf;
gzip_vary on;
gzip_proxied any; # Compression for all requests.
## No need for regexps. See
## http://wiki.nginx.org/NginxHttpGzipModule#gzip_disable
gzip_disable msie6;
## Serve already compressed files directly, bypassing on-the-fly
## compression.
##
# Usually you don't make much use of this. It's better to just
# enable gzip_static on the locations you need it.
# gzip_static on;
As per @Tim's comments - CURL output:
My Machine
10.244.0.1 - - [07/Jun/2018:08:15:45 +0000] "GET /Public/JS/Auth/bundle.js HTTP/1.1" 200 1007996 "http://51.144.234.135/auth/login/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36" request-time: 0.579 Upstream-time: - .
CURL localhost
127.0.0.1 - - [06/Jun/2018:15:04:37 +0000] "GET /Public/JS/Auth/bundle.js HTTP/1.1" 200 3081261 "-" "curl/7.60.0" "-"
CURL to IP - From host
10.244.0.1 - - [06/Jun/2018:15:04:57 +0000] "GET /Public/JS/Auth/bundle.js HTTP/1.1" 200 3081261 "-" "curl/7.60.0" "-"