Digital Ocean graphs after moving from Nginx to Caddy

(Sudarsh) #1

Hi, just thought I’d show some graphics on CPU usage from DO after moving from Nginx to Caddy.

The Nginx machine had two GB of RAM and 2 CPU cores. The Caddy machine has 1 core and 2 GB of RAM.

Load is largely the same – about 1-3 connections per second (and multiple files give out via each connection)

The switch happend at 4:45 PM.

Nginx CPU graph:

Caddy graph:

Note that the CPU use on caddy is very smooth. I have no idea why. Nginx was self-compiled with pagespeed module (the latest stable version).

Also, I don’t notice any quic requests, even though quic is enabled (I tested using Chrome). All requests seem to be http2. Any idea why that’s so? This server basically serves static content (mostly images).

(Matt Holt) #2

Very interesting! It could have something to do with the fact that Caddy doesn’t have a pagespeed equivalent, so perhaps it’s doing less work in that sense.

Might also have to do with the fact that Go’s garbage collector runs concurrently and in very, very quick, short, and possibly frequent intervals. Would be interesting to see what your Caddyfile is like, to know which middlewares are being invoked.

A better explanation could be given by profiling; you might also enable the pprof and expvar directives to gain insights.

(George) #3

definitely a possibility as ngx_pagespeed module does on the fly image optimisations i.e. converting jpg/png to webp as well as optimise css/js assets on the fly so depending on nginx pagespeed filters configured/enabled, cpu load could be higher. The more image heavy your pages accessed through ngx_pagespeed optimised filters, the more cpu usage it would involve though it can be tuned via ngx_pagespeed settings as well.

old youtube video explaining what nginx pagespeed/ apche mod_pagespeed modules do

ngx_pagespeed speeds up your site and reduces page load time. This open-source nginx server module automatically applies web performance best practices to pages, and associated assets (CSS, JavaScript, images) without requiring that you modify your existing content or workflow.

ngx_pagespeed improves web page latency and bandwidth usage by changing the resources on that web page to implement web performance best practices. Each optimization is implemented as a custom filter in ngx_pagespeed, which are executed when nginx serves the website assets. Some filters simply alter the HTML content, and other filters change references to CSS, JavaScript, or images to point to more optimized versions.

The real comparison would be doing tests without ngx_pagespeed enabled/integrated and/or doing page load speed tests via for comparison of nginx + ngx_pagespeed versus caddy in this case. I wrote a guide on how to use for pagespeed testing that @elos42 could test if you still have access to both old nginx server and current caddy server configs

Also check the memory usage too.

(Sudarsh) #4

It’s just a static file server. So there are practically no middleware being called I think.

root /var/www/wordpress
tls /etc/ssl/caddy/fullchain.pem /etc/ssl/caddy/privkey.pem
rewrite {
        r   \.(php|conf|ini)
        to  /403.html
log /var/log/caddy/caddy.log
header / Strict-Transport-Security "max-age=31536000;"

It’s probably pagespeed module. I’ve kept the default settings. I don’t think it converts to webp on default settings. Not sure.