Settings

Theme

Show HN: Top, but for Nginx

github.com

219 points by squiguy7 6 years ago · 71 comments

Reader

maxmalysh 6 years ago

Monitoring capabilities are missing from Nginx on purpose. They are not and will never be available for free because there is "NGINX Plus".

This is why I recommend switching to HAProxy.

  • heipei 6 years ago

    I'd love to just "switch to X", but there is no X which provides all of the above in one great package: Static file serving, load-balanced proxying (TCP/HTTP), fine-grained caching, automatic Let's Encrypt update, API-based configuration (for dynamic upstreams etc), monitoring. Maybe there shouldn't be such a tool. For all other use-cases I go with nginx since it at least provides decent proxying, caching and static file serving.

    • brightball 6 years ago

      Correct me if I’m wrong, but doesn’t Caddy 2 do almost all if that?

      • heipei 6 years ago

        Had to check, Caching is still missing from Caddy 2, everything else seems to be there [1]. Now if there's no missing minor feature that I rely on in nginx, I might be able to switch eventually, fingers crossed.

        [1] https://github.com/caddyserver/cache-handler/issues/1

      • 411111111111111 6 years ago

        You mean the software which wouldn't start when let's encrypts acme server was offline and which developers said this is working as intended?

        I mean, I'd definitely encourage people to use it for hobby projects, but if that's how the developers see their software, I would never trust them with anything serious.

        • mholt 6 years ago

          Someone's a little out of the loop.

          • 411111111111111 6 years ago

            I know it was "fixed" after thousands of people chimed in.

            Nonetheless, I still wouldn't be able to trust developers who think that's reasonable.

            if it had been an error and unintentional i wouldn't have been worried. mistakes happen to everyone. but it was an actual design decision. Without serious code review i'd be too worried the developers had any other bright ideas.

    • mmm_grayons 6 years ago

      Nginx does automatic let's encrypt? Since when?

    • jimjag 6 years ago

      X == Apache httpd 2.4

      • SEJeff 6 years ago

        I was thinking the exact same thing ironically.

        Static file serving? Sure!

        Load balanced proxying? mod_proxy_balancer is great!

        Fine grained caching? mod_disk_cache is also great

        Updating loadbalancer bits via the api?

        mod_proxy_balancer supports a balancer-manager endpoint for that to do live updates

        monitoring? mod_status + prometheus exporter or

        mod_prometheus_status

        native LE support? https://github.com/icing/mod_md is going to be rolled into upstream apache

        • cyberpunk 6 years ago

          Have you actually seen an apache in the wild in the last few years? No one picks it anymore, I'm not sure why.. Well, besides the fact that nginx is now nginx-ingress-controller and we all use k8.. :/

          • jimjag 6 years ago

            Why does no one pick it anymore? The reason is twofold: (1) the amount of FUD that surrounds it, based on old comparisons of nginx and Apache httpd 1.3 or 2.x using Prefork and (2) cool-kid syndrome. This thread itself is a perfect example.

          • SEJeff 6 years ago

            Apache still runs some really big websites that likely have more requests than many of these startups. Ticketmaster has used Apache for almost 15 years as their primary webserver (but they're fronted by layers of varnish / Akamai). They also maxed out dual 10G links with web traffic in 2007 or so when I worked for them.

            That said, netcraft says Apache still runs almost 25% of the internet, which is no small stake: https://news.netcraft.com/archives/category/web-server-surve...

          • mekster 6 years ago

            I still use it to have basic auth connected to LDAP.

            The weakness of nginx is that it can't have a dynamic module and if it's not compiled in, you need to roll your own build, which I won't do due to maintenance burden.

          • TechBro8615 6 years ago

            Maybe it‘s due to guilt-by-association with PHP and the LAMP stack...

          • jldugger 6 years ago

            Yes, but I know some of the apache.org SRE so maybe my view is biased.

            • SEJeff 6 years ago

              The most amazing guy who wrote the book on mod_rewrite (Rich Bowen) is from the same tiny town where I grew up in. The apache software foundation upstream folks are super good people.

        • fomine3 6 years ago
    • kawsper 6 years ago

      Do you know if it's the same with Openresty?

  • shockinglytrue 6 years ago

    Wish all distros shipped https://github.com/vozlt/nginx-module-vts by default. It's a minor pain to self-build

  • cinericius 6 years ago

    HAProxy also has an 'enterprise' offering[1], what makes this different from nginx plus?

    [1] https://www.haproxy.com/products/haproxy-enterprise-edition/

  • mklepaczewski 6 years ago

    I always wonder - why no one from open source community has created better stats module? Is there something in the license that prohibits creation of modules that overlap with Nginx Plus?

    • mekster 6 years ago

      I would assume it's the lack of dynamic module support for nginx and you need to compile your own build even if someone creates a module.

      • mklepaczewski 6 years ago

        That's true for any functionality provided by modules and there's plethora of them. Also, Nginx has support for dynamic modules. Recompiling Nginx always worked out of the box for me too, so it's not like a big issue.

        One thing that comes to my mind is that maybe this can't be solved by a module due to missing API in open source Nginx.

  • markstos 6 years ago

    And why others would recommend Nginx Plus.

gregoriol 6 years ago

Maybe not as lightweight, but GoAccess (https://github.com/allinurl/goaccess) does an awesome job at parsing the logs and displaying statistics, works for nginx and other webservers too

  • squiguy7OP 6 years ago

    I hadn't heard of this tool but it looks much more complete! Thanks for sharing.

  • guanzo 6 years ago

    Goaccess used to work perfectly, but recently when ever I try to run the real time HTML command, it exits without any error messages after ~2 million records. Maybe out of memory.. any ideas?

  • mekster 6 years ago

    Last time I tried it was a pain to set it up to keep up with log rotations and retain all the records.

    • joshyi 6 years ago

      For us it was literately an `apt install goaccess`, picked the COMBINED log format and it's been running for over a month in prod without issues (rotating weekly).

      You should post the issue on their https://github.com/allinurl/goaccess, they may be able to help you.

jrumbut 6 years ago

This is the tool I've wanted (and half written 3-4 times) my whole career. From reading the github it looks lightweight, not a big infrastructure addition, and that it helps you figure out wtf is going on with the web server.

Regarding the branding, for me top is a real-time tool rather than a logging tool. I was picturing something that may have been more useful for older style Apache httpd installs where you have several virtual hosts on a server and you'd want to know who is hogging the resources or causing the problems.

  • jluxenberg 6 years ago

    Pro tip: you can make any command into a real-time one with `watch`:

      watch bash -c "topngx < /path/to/access.log"
    
    Will run `topngx` against access.log every two seconds and display the output.
    • gregoriol 6 years ago

      That's not "real time"! And definitely won't behave well if the processing takes more than 2 seconds (imagine log files of many millions rows)

      • cyberpunk 6 years ago

        It'll just wait two seconds after the command returns, not spawn one every two seconds.....

  • squiguy7OP 6 years ago

    Thanks for the feedback. I wanted to capture the same idea as the original tool I listed in the README. In the future I hope to add functionality to tail a log file in real time and do live updates of the stats. This is where the idea of top comes from.

  • markstos 6 years ago

    Agreed. The defining feature of `top` is that it updates in real time.

randomstring 6 years ago

My last company had something like that and included response time percentiles (50th, 90th, 95th, 99th) and we had these values graphed and displayed on a big screen in our office. Along with a ton of other performance stats: queries per second, various measures of system load, etc.

Averages can lie, especially when something like an empty query can take close to zero time compared to a non-trivial transaction. If some robot or other artifact of your site is generating a some amount of null queries that will make your average response time look better than it actually is. Percentiles, particularly on the tail of 90th or above, tell a better story of how well and consistently you're responding to traffic under load.

  • harpratap 6 years ago

    How "recent" are your percentiles? I have found that calculating percentiles is a pretty CPU heavy task. And you if you have a giant Grafana querying every 30s it can stress out your prometheus/graphite whatever. But if you take small data size, like 95th percentile of latencies in the last 2minutes, it's not really a very accurate representation either.

    And ofcourse there is another problem of correctly storing all your latencies accurately which becomes pretty hard if you are using something like prometheus.

eterps 6 years ago

I wouldn't mind a screenshot before installing it.

jimjag 6 years ago

Hmmm... looks like nothing more than a weblog analyzer. Someone correct me if I'm wrong. It's not "real time" since it can only report on what the web-server has done not what it is doing. AFAIK, nginx has nothing like Apache httpd's mod_status... at least, nothing open source.

  • dijital 6 years ago

    If you're in a Kubernetes environment, the NGINX Ingress Controller has a pretty decent set of realtime metrics: https://kubernetes.github.io/ingress-nginx/user-guide/monito...

    Which presumably means those metrics are available in the OSS edition somehow...

  • oefrha 6 years ago

    Open source nginx has stub_status. It's just not very (very not) featureful.

    https://nginx.org/en/docs/http/ngx_http_stub_status_module.h...

  • cholmon 6 years ago

    What frustrates me about Apache's mod_status is that it's powered by a normal request handler. If all the child workers are busy, your request for a status report will timeout, even if you're running it locally from the command line. Not super helpful when you're troubleshooting in real time.

    Anyone know if there's a "deeper" way to get the same stats info about what Apache is doing without having to basically wait in line with all the other incoming requests?

  • mrits 6 years ago

    the latency between weblog and web server is a lot more real time than most things

hk__2 6 years ago

> This tool is a rewrite of ngxtop to make it more easily installed and hopefully quicker.

Why make a whole new tool with limitations instead of improving the existing one?

dheera 6 years ago

Interesting, but I would have thought "top" for nginx would be a tool that shows you all the connections, paths, and resource usage live, like the "top" command. Is there a tool that does that?

deft 6 years ago

How does this compare to goaccess? Similar tool that I've used briefly. One issue I had was how complicated it was, I'm assuming since this is nginx specific it's simpler.

madsmtm 6 years ago

I made something similar in Python [0], but for parsing the error_log directive. Just for the odd time you need to parse that.

[0] https://github.com/madsmtm/nginx-error-log

superkuh 6 years ago

>a rewrite of ngxtop to make it more easily installed and hopefully quicker.

What world does this guy live in that a program in Rust is easier to get running on any random machine than python script?

  • Kaze404 6 years ago

    I've never had issues shipping Rust binaries to people, unlike in Python where they usually have to install dependencies.

  • jblarneyforward 6 years ago

    I had the vague sense that it was as easy to cross-compile rust binaries as it is for go.

    Distributing single binary would be easier, but `cargo install xyz` seems harder than python script

  • squiguy7OP 6 years ago

    I made a new GitHub release with binaries for Mac and Linux pretty recently. In this sense, you can just download the binary and get up and running.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection