Skip to content

Performance vs. Zitros nodeJS Proxy

Dennis Paul edited this page Aug 26, 2020 · 1 revision

I had following docker-compose setup:

version: '2'

services:
  web:
    image: nginx:latest
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./dhparam.pem:/etc/nginx/dhparam.pem:ro
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
      - /etc/letsencrypt:/etc/letsencrypt:ro
    environment:
      - TZ=Europe/Berlin
  gtmproxy:
    image: blaumedia/go-gtm-ga-proxy:latest
    restart: always
    environment:
      - ENABLE_DEBUG_OUTPUT=true
      - JS_MINIFY=true
      - ENABLE_PLUGINS=false
      - ENDPOINT_URI=HIDDEN
      - JS_SUBDIRECTORY=/js/
      - GTM_FILENAME=inject.js
      - GTM_A_FILENAME=inject_a.js
      - GA_FILENAME=catcher.js
      - GADEBUG_FILENAME=catcher_debug.js
      - GTAG_FILENAME=tag.js
      - GA_PLUGINS_DIRECTORYNAME=/links/
      - GA_COLLECT_ENDPOINT=/fetch
      - GA_COLLECT_REDIRECT_ENDPOINT=/fetch_r
      - GA_COLLECT_J_ENDPOINT=/fetch_j
      - ENABLE_SERVER_SIDE_GA_COOKIES=true
      - GA_SERVER_SIDE_COOKIE=_gggp
      - COOKIE_DOMAIN=HIDDEN
      - COOKIE_SECURE=true
      - PROXY_IP_HEADER=X-Forwarded-For
      - PROXY_IP_HEADER_INDEX=0
      - GA_CACHE_TIME=3600
      - GTM_CACHE_TIME=3600
  zitrosgtmproxy:
    image: zitros/analytics-saviour:latest
    restart: always

and nginx.conf:

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;

        ssl_certificate /etc/letsencrypt/live/HIDDEN/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/HIDDEN/privkey.pem;

        ssl_protocols TLSv1.2;
        ssl_dhparam /etc/nginx/dhparam.pem;
        ssl_ciphers EECDH+AESGCM:EDH+AESGCM;
        ssl_prefer_server_ciphers on;

        ssl_ecdh_curve secp384r1;

        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";

        ssl_stapling on;
        ssl_trusted_certificate /etc/letsencrypt/live/HIDDEN/chain.pem;
        ssl_stapling_verify on;

        resolver 8.8.8.8;

        root /code;

        etag on;

        index index.html index.htm;

        server_name HIDDEN;

        location / {
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header  X-Forwarded-Host $proxy_add_x_forwarded_for;

                proxy_pass http://gtmproxy:8080/;
                proxy_redirect off;
        }

        location /zitros/ {
                proxy_set_header  X-Real-IP $remote_addr;
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header  X-Forwarded-Host $proxy_add_x_forwarded_for;

                proxy_pass http://zitrosgtmproxy:80/;
                proxy_redirect off;
        }

        location ~ /\. {
                deny all;
        }

        location ~ /\.ht {
                deny all;
        }
}

server {
        listen 80;
        listen [::]:80;

        server_name HIDDEN;

        rewrite     ^   https://$server_name$request_uri? permanent;
}

Analytics (analytics.js)

Siege Comparison (Top: GoGtmGaProxy/Bottom: Zitros)

Siege Comparison While Zitro's proxy can handle nearly 5700 queries, the GoGtmGaProxy can handle nearly 5000 more. The longest query took 1.87 seconds with Zitro's proxy, while the GoGtmGaProxy took only 0.71 seconds. The fastest response sent by the proxy from Zitros took 0.79 seconds, which is not only slower than the slowest query to the GoGtmGaProxy, but also the fastest response from the GoGtmGaProxy is significantly better at 0.22 seconds.

CPU usage GoGtmGaProxy

GoGtmGaProxy CPU

CPU usage Zitros

Zitros CPU Zitro's proxy server blocks an entire core of the server, while the GoGtmGaProxy does not even need a fifth.

GTM (gtm.js?id=GTM-NNQ5LT)

Siege Comparison (Top: GoGtmGaProxy/Bottom: Zitros)

Siege Comparison

CPU usage GoGtmGaProxy

GoGtmGaProxy CPU

CPU usage Zitros

Zitros CPU