Performance compared to nginx?

Hey, i am using caddy on my personal server, i moved from nginx and caddy and it was an amazing experience to migrate from nginx to caddy. Great job on that :blush:

My question is, does anyone know how caddy performances compared to nginx in a production environment?

haven’t been able to find any comparison for v2. hence why i am asking.

Caddy is written in Go. It will perform just as well as any other Go web servers.

Google, Netflix, Cloudflare, Fastly, and other large network companies deploy Go on their edge. You can too.

Here are a couple observations:

Side anecdote: did some benchmarking a week or 2 ago with Nginx, ~1k req/s pegged an 8 core machine at 100%.

Out-of-the box caddy did 1k req/s with ~5% CPU load. We were even questioning if the test was running.

We ran 20,000 clients / second (over 15 seconds) on our reverse proxy. Touched about 20% CPU and the bottleneck was cold starts on our serverless infrastructure, haha. Caddy did just fine. More than good enough for us. We’re not quite doing 72,000,000 page views per hour :wink:

In 2020, your web server will not be your bottleneck. Heck, python’s SimpleHTTPServer is probably fast enough for you. Your real bottlenecks are going to be network, storage/disk, (lack of) hardware acceleration for crypto instructions, and memory/CPU as number of sites and certificates grows with a growing customer base – those kinds of things.

Benchmarks don’t generalize well. Only rigorous profiling is helpful in making performance optimizations (see how the Go team improves the standard lib performance in their CLs). All performance results depend on hardware, virtualization, system tuning, OS, software updates, power supply, ambient temperature, monitors plugged in, and butterflies near the South Pole. There are thousands – millions – of parameters which affect benchmarks, which are largely futile. (Web servers are complicated.) It’s not like benchmarking a fibonacci tail call or something.

Deploy Caddy and see how it fares for you. Chances are it will perform as well or better than nginx or Apache. (Plus, you get the memory safety of a Go program, rather than fragile C programs.)

2 Likes

I did notice Caddy is written in Go, so is k8, Docker, Terraform and Go :slight_smile: so there is no doubt in that. Was just looking at production to get a general idea of other peoples experience with it, web servers are indeed complicated, but is also part of the fun

I am looking forward to deploying Caddy in the near future. :slight_smile:

1 Like

No in production, but local dev testing for HTTP/2 HTTPS I did quick benchmarks for my Nginx custom builds versus Caddy v2 outlined at GitHub - centminmod/centminmod-caddy-v2. You can jump straight to benchmarks section here.

I will update with HTTP/3 HTTPS comparison tests later on in section here.

1 Like

Caddy vs Nginx benchmarks for HTTP/2 and HTTP/3 HTTPS Caddy v2 HTTP/2 & HTTP/3 Benchmarks :slight_smile:

1 Like

as matt said, it’s hard to generalize the benchmark due to so many factors which plays into it, but i appreciate it.

Matt linked to a tweet, there someone saw 100% CPU load on nginx and only ~5% on caddy, how was your system resources utilized?

I never knew Nginx has reuseport directive!

I’m curious if worker_connections was set too?

Didn’t really intend to do resource usage tests until I moved off the virtualbox/laptop setup to a proper server, but did a quick HTTP/3 HTTPS test anyway and had to change h2load test parameters to duration based instead of request based tests to more accurately measure resource usage over time. Results at https://community.centminmod.com/threads/caddy-v2-versus-centmin-mod-nginx-http-2-http-3-https-benchmarks.19700/#post-83743 and centminmod-caddy-v2/h2load-duration-tests-http3-may10-2020.md at master · centminmod/centminmod-caddy-v2 · GitHub

Yes reuseport has been around since May 2015 with Nginx 1.9.1 release Module ngx_http_core_module :slight_smile:

Centmin Mod Nginx’s worker_connections setting for 123.09beta01 is at centminmod/nginx.conf at 123.09beta01 · centminmod/centminmod · GitHub but the base defaults for Nginx, PHP-FPM and MariaDB are automatically and dynamically adjusted at initial Centmin Mod install time based on detected server resources i.e. cpu model/cpu flags supported, cpu cores, memory, disk size and speed and even based on kernel supported features.

Regardless of web server used, it’s not what you use but how you use it too. Not all Caddy or Nginx servers will be built or configured the same. So best to do your own testing for your own usage cases too. For me I mainly use it for Wordpress and vBulletin, Xenforo and Invision Board forum sites as that is where my stack’s user base are for sites where high traffic and user concurrency are important factors as well as page speed i.e. in Alexa Top 5,000/10,000 and ~10% of all the largest Xenforo forums online.

Regardless of web server used, it’s not what you use but how you use it too. Not all Caddy or Nginx servers will be built or configured the same. So best to do your own testing for your own usage cases too. For me I mainly use it for Wordpress and vBulletin, Xenforo and Invision Board forum sites as > that is where my stack’s user base are for sites where high traffic and user concurrency are important factors as well as page speed i.e. in Alexa Top 5,000/10,000 and ~10% of all the largest Xenforo forums online.

That’s true, same as Matt said :slight_smile:

Looked at your graphs, looks good. but i wonder why nginx started with a lot of used memory and then just free-falls. haven’t done much benchmarks when it comes to web servers. i am much more used when it comes to software.

Also when you post the benchmark for a real server setup for your use cases (which i hope you will), it would be nice if you post nginx and caddy graphs side by side of in the same graph so it’s easier to compare the two and change the x-axis to be how long the test ran for, instead of the current minute in the hour.

I would also be posting my benchmarks, when i get to do them, i am properly gonna focus they each perform when they are in a stack and not as a single unit.

I haven’t done much testing with Cloudflare’s Nginx HTTP/3 patch so not sure if it’s related to that as the tests were with HTTP/3 HTTPS. Probably will investigate and compare with HTTP/2 HTTPS later. Also my Nginx server is built against jemalloc memory allocator and not glibc so memory usage within Nginx might not be same as other Nginx servers.

The charts are generated on the fly right after tests via my forked sarviewer which uses sysstats/sar GitHub - centminmod/sarviewer at cmm so done one test session at a time, so not data you can as easily put 2 test session’s data on the same chart with. Though the raw data is there, just need to figure out how to plot them together. My gnuplot-fu is basic at best but will see :slight_smile:

If you don’t mind to run another test with default Nginx that came with Linux distro for benchmark since majority of the community would have not spent their time optimize with your performance tweaks, it would be a fair comparison.

p.s. I have been using your benchmark as an authoritative source for years.

Will see, no promises as I haven’t used distro Nginx in nearly 10yrs due to me rolling my own Nginx server.

  • CentOS 7 uses OpenSSL 1.0.2 so native distro CentOS 7 Nginx won’t support TLSv1.3 which came with OpenSSL 1.1.1. Guess you can say these are some of the pro Caddy factors for some folks :slight_smile:
  • OpenSSL 1.1.1’s ECDSA cipher performance is ~40% faster than that of OpenSSL 1.0.2 too. Actually haven’t really checked Caddy’s differences for ssl cipher choices for HTTPS performance yet.
  • Native distro CentOS 7 won’t be able to support HTTP/3 so no Nginx HTTP/3 tests either.
  • CentOS 7 distro Nginx would be build against older GCC ~4.8 compilers. Which means distro CentOS 7 Nginx is way behind in performance and features as soon as you do a yum install nginx on CentOS 7 !
  • It’s why I build and roll my own Nginx builds which support a variety of crypto libraries that end users can choose from themselves, LibreSSL, OpenSSL 1.0.2/1.1.1, BoringSSL and BoringSSL/Cloudflare Quiche (for HTTP/3) and can be compiled using Clang or GCC 4.8 or newer GCC 7.3, 8.3, or 9.2 compilers. So you can pair your target Nginx binaries with specific cpu models being used.

Guess it goes back to what I said early, it’s not what you use but how you use it that matters :smiley:

Nice glad my work has been useful to you :slight_smile:

The charts are generated on the fly right after tests via my forked sarviewer which uses sysstats/sar https://github.com/centminmod/sarviewer/tree/cmm so done one test session at a time, so not data you can as easily put 2 test session’s data on the same chart with. Though the raw data is there, just need to figure out how to plot them together. My gnuplot-fu is basic at best but will see

it should be possible as in theory you just need the data and figure out how to do it in gnuplot, but i haven’t used gnuplot before i tend to do plots programmatic in python. but showing them side by side should be possible by just using markdown on github.

1 Like

This topic was automatically closed after 180 days. New replies are no longer allowed.